Thursday 29 January 2015

Renumber drawing views



                If you deal with large drawings, multiple sheets, multiple views, you must have seen this one. For every view you place Inventor assigns a name “A” “B” etc. But if you start moving views around, or if for any reason you delete some of them, like doing temporary sections to check for interferences, the view name increments from the last used character. So by the time I finish the drawing I have un-sequenced drawing view names like:  “A”, “F” “M”. I finally got tired of explaining this in the workshop every time so I’ve stripped bits of code together in order to fix this.

                Here’s the code, add your own approved letters for the drawing views.


'------------------START CODE--------------- 
' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oSheets As Sheets
Dim oSheet As Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView

'set your view labels here
MyText = "ABCDEFHJKLMNP"
'You could have single digits numbers
'MyText = "123456789"
'have it reverse
'MyText = "z9y8x7v6u5"
'multiple characters, labels or strings
'MyText = New String(){"1","2","10","ADS","FIRST","SECOND","YOUR NAME","ETC."}

Dim i As Long
i=0

For Each oSheet In oDrawDoc.Sheets
'For Each oSheet In oSheets
    oViews = oSheet.DrawingViews
    For Each oView In oViews
        'Show the view label
        oView.ShowLabel = True
        oView.Name = "View " & MyText(i)
        i = i + 1
      Next
Next

'------------------End CODE--------------- 


Till next time,
ADS.

No comments:

Post a Comment