Announcement
December 5, 2014

Posted on December 5, 2014 by Mark Lancaster, Synergis Product Support Specialist
When it comes to opening Inventor drawings, I always like to see my drawings on sheet 1, at full extents (zoom all) and the browser tree fully collapsed (basically it’s neat and tidy). However, I didn’t always remember to do these things prior to saving my drawing.
A few years ago, I stumbled across this iLogic code from Curtis Waguespack that would sort, collapse, and perform a zoom all on the Inventor assembly file. I set out to adapt his code into performing my required housekeeping chore on my drawings.
This is what I ended up with after I pieced together his code and other snippets that I had used in the past:
”***************************************************
‘ Set a reference to the document
Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument
”*********************************
‘ Set a reference to the top node of the active browser
Dim oTopNode As BrowserNode
oTopNode = oDoc.BrowserPanes.ActivePane.TopNode
Dim oNode As BrowserNode
”**********************************
For Each oNode In oTopNode.BrowserNodes
‘ If the node is visible and expanded, collapse it.
If oNode.Visible = True And oNode.Expanded = True Then
oNode.Expanded = False
End If
Next
”**********************************
‘ Loop through all drawing sheets and zoom all
For Each sheetX As Sheet In ThisDrawing.Document.Sheets
ActiveSheet = ThisDrawing.Sheet(SheetX.Name)
ThisApplication.CommandManager.ControlDefinitions.Item(“AppZoomAllCmd”).Execute
Next
”***********************************
‘ Activate drawing sheet 1 and zoom all
ActiveSheet = ThisDrawing.Sheet(“Sheet:1″)
ThisApplication.ActiveView.Fit
”***********************************
You can also take the next step and apply this code to run (iLogic event triggers) anytime the file is closed.
Until next time.
Have a question for  our technical staff? Contact us or visit the Synergis website.