Friday 14 July 2017

Align Drawing Views

So.. What’s happening? Not much! decided to give a hand on Inventor Forum so I was quite busy there but good things emerge like this post about how to align drawing views.

In this case, the user wanted to place multiple parts on the same drawing and align them left side for visual comparison.

                When is this useful? How about progressive die sheet metal parts?

                Of course, you can place them in a common assembly constrain them and then create a view of that but that’s not what the user wanted.

                The other common technique is to create each bend as a separate unfold/refold operation and convert the model to an iPart where you document each step of the process by suppressing fold/unfolds. You can then place multiple members on each drawing and the views will be aligned (should be because they share the same model..)

                The next code will get the X position of the first view and align the rest according to it. Views on drawing are positioned by Center so you need to get the Width of the view and divide it by 2 but it’s all in the code.

                You need to take care of the vertical Y position of the view and the code will align on X


Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oView As DrawingView

Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet

' Process the rule, wrapping it in a transaction so the 
' entire process can be undone with a single undo operation. 
Dim trans As Transaction 
trans = ThisApplication.TransactionManager.StartTransaction( _ 
        oDrawDoc, "Alig Views")
        oFirstView = oSheet.DrawingViews.Item(1)
        'views are processed by center so we need to get center X and substract half view
        Dim XPos As Double
        XPos = oFirstView.Position.X - (oFirstView.Width/2)
        Dim oPoint2D As Inventor.Point2D
        'view position is XPos + half of each view
        For Each oView In oSheet.DrawingViews
            oPoint2D = ThisApplication.TransientGeometry.CreatePoint2D(XPos + (oView.Width/2),oView.Position.Y)
            oView.Position = oPoint2D
'finish the transaction



photo credit: Simon & His Camera Reflected Wings On A Steel Butterfly - London City Office Life 2017 Version (license)

No comments:

Post a Comment