Sub Main Dim oDoc As Inventor.Document = ThisDoc.Document Dim bIsAssembly As Boolean = (oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject) Dim bIsPart As Boolean = (oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject) Dim oModelPane As Inventor.BrowserPane = GetModelBrowserPane(oDoc) Dim oCD As Inventor.ComponentDefinition = Nothing Dim oWPlane As WorkPlane, oSBD As SketchBlockDefinition, oBody As SurfaceBody Dim oMA As ModelAnnotation, oDVR As DesignViewRepresentation Dim oOriginFolder, oBlocksFolder, oBodiesFolder, oViewsFolder, oAnnotationsFolder As Inventor.BrowserNode If bIsAssembly OrElse bIsPart Then oCD = oDoc.ComponentDefinition oWPlane = oCD.WorkPlanes.Item(1) Dim oRepsMgr As RepresentationsManager = oCD.RepresentationsManager Dim oDVRs As DesignViewRepresentations = oRepsMgr.DesignViewRepresentations For Each oVRep As DesignViewRepresentation In oDVRs 'make sure it is not a Transient type (changes made in it, but not saved yet) If oVRep.DesignViewType = DesignViewTypeEnum.kPrimaryDesignViewType Then oDVR = oVRep Exit For End If Next Dim oMAs As ModelAnnotations = oCD.ModelAnnotations If oMAs.Count > 0 Then oMA = oMAs.Item(1) End If If bIsPart Then Dim oBodies As SurfaceBodies = oCD.SurfaceBodies If oBodies.Count > 0 Then oBody = oBodies.Item(1) Dim oSBDs As SketchBlockDefinitions = oCD.SketchBlockDefinitions If oSBDs.Count > 0 Then oSBD = oSBDs.Item(1) End If 'Origin folder - working If oWPlane IsNot Nothing Then oOriginFolder = oModelPane.GetBrowserNodeFromObject(oWPlane).Parent Try : oOriginFolder.Expanded = True : Catch : Logger.Error("OriginFolder Failed") : End Try End If 'Solid Bodies folder - not working If oBody IsNot Nothing Then Dim oBodyNodeDef As NativeBrowserNodeDefinition = Nothing Try oBodyNodeDef = oDoc.BrowserPanes.GetNativeBrowserNodeDefinition(oBody) If oBodyNodeDef Is Nothing Then Logger.Debug("oBodyNodeDef Is Nothing") oBodiesFolder = oModelPane.TopNode.AllReferencedNodes(oBodyNodeDef).Item(1).Parent oBodiesFolder.Expanded = True Catch Logger.Error("Expand Bodies Folder Attempt 1 Failed") End Try Try Dim oBodyNode As BrowserNode = oModelPane.GetBrowserNodeFromObject(oBody) If oBodyNode Is Nothing Then Logger.Debug("oBodyNode Is Nothing") oBodyNode.EnsureVisible Catch Logger.Error("Expand Bodies Folder Attempt 2 Failed") End Try Try oBodiesFolder = oModelPane.GetBrowserNodeFromObject(oBody).Parent If oBodiesFolder Is Nothing Then Logger.Debug("oBodiesFolder Is Nothing") oBodiesFolder.Expanded = True Catch Logger.Error("Expand Bodies Folder Attempt 3 Failed") End Try End If 'Views folder - not working If oDVR IsNot Nothing Then 'oViewsFolder = oModelPane.GetBrowserNodeFromObject(oDVR).Parent 'Try : oViewsFolder.Expanded = True : Catch : Logger.Error("Views Failed") : End Try Dim oViewNode As Inventor.BrowserNode = oModelPane.GetBrowserNodeFromObject(oDVR) If oViewNode Is Nothing Then Logger.Debug("oViewNode Is Nothing") Try : oViewNode.EnsureVisible : Catch : Logger.Error("Views Failed") : End Try End If 'Blocks folder - working If oSBD IsNot Nothing Then oBlocksFolder = oModelPane.GetBrowserNodeFromObject(oSBD).Parent Try : oBlocksFolder.Expanded = True : Catch : Logger.Error("Blocks Failed") : End Try End If 'Annotations folder - woking If oMA IsNot Nothing Then oAnnotationsFolder = oModelPane.GetBrowserNodeFromObject(oMA).Parent Try : oAnnotationsFolder.Expanded = True : Catch : Logger.Error("Annotations Failed") : End Try End If End Sub Function GetModelBrowserPane(oDoc As Document) As BrowserPane For Each oPane As BrowserPane In oDoc.BrowserPanes If oPane.BuiltIn AndAlso oPane.TreeBrowser AndAlso _ (oPane.InternalName = "AmBrowserArrangement" Or _ oPane.InternalName = "DlHierarchy" Or _ oPane.InternalName = "PmDefault") Then Return oPane Next : Return Nothing End Function