Hi Brian,
i'm writing a layer Synchronisation program for our sales department.
The environment is an Inventor Drawing.
The program must do the following:
1) expand the browsernodes in the drawing from the first view till the first assembly (this i have working)
2) user selects in browserpane the parts which must be changed by layer (this i'm searching for)
3) select in all other views the same selected parts
4) for all the selected parts -> call Select Edges
5) change layer of all the selected items
This is the code i've so far:
Dim oINVDrawingDoc As Inventor.DrawingDocument = m_inventorApplication.ActiveDocument
'collapse browser of first view en first assembly
Dim oTopBrowserNode As Inventor.BrowserNode
oTopBrowserNode = oINVDrawingDoc.BrowserPanes.ActivePane.TopNode
Dim oBladBrowserNode As Inventor.BrowserNode = oTopBrowserNode.BrowserNodes("Blad:1")
For Each oViewBrowserNode As Inventor.BrowserNode In oBladBrowserNode.BrowserNodes
If oViewBrowserNode.FullPath.Contains("VIEW") Then
For Each oAsmBrowserNode As Inventor.BrowserNode In oViewBrowserNode.BrowserNodes
Dim oAsmBrowserNodeDefinition As Inventor.BrowserNodeDefinition = oAsmBrowserNode.BrowserNodeDefinition
If oAsmBrowserNodeDefinition.Label = (Replace(oTopBrowserNode.FullPath, "dwg", "iam")) Then
oAsmBrowserNode.Expanded = True
GoTo SelectItems
End If
Next
End If
Next
SelectItems:
'select items in browser
Dim comps As Inventor.ObjectCollection = m_inventorApplication.TransientObjects.CreateObjectCollection
Dim comp As Object
While True
comp = m_inventorApplication.CommandManager.Pick(Inventor.SelectionFilterEnum.kAllEntitiesFilter, "Select items in the browser!")
' If nothing gets selected then we're done
If IsNothing(comp) Then Exit While
comps.Add(comp)
End While
' If there are selected components we can do something
For Each comp In comps
If comp.Type <> Inventor.ObjectTypeEnum.kBrowserFolderObject Then Continue For
MessageBox.Show(comp.Name)
Next
'loop through first view and assembly to get the selected items
'Dim oTopBrowserNode As Inventor.BrowserNode
'oTopBrowserNode = oINVDrawingDoc.BrowserPanes.ActivePane.TopNode
Dim assemblyName As String = (Replace(oTopBrowserNode.FullPath, "dwg", "iam"))
'Dim oBladBrowserNode As Inventor.BrowserNode = oTopBrowserNode.BrowserNodes("Blad:1")
Dim oListOfSelectedBrowserNodeNames As New List(Of String)
For Each oViewBrowserNode As Inventor.BrowserNode In oBladBrowserNode.BrowserNodes
'select first view
If oViewBrowserNode.FullPath.Contains("VIEW") Then
Dim oFirstViewBrowserNode As Inventor.BrowserNode = oViewBrowserNode
For Each oAsmBrowserNode As Inventor.BrowserNode In oFirstViewBrowserNode.BrowserNodes
Dim oAsmBrowserNodeDefinition As Inventor.BrowserNodeDefinition = oAsmBrowserNode.BrowserNodeDefinition
If oAsmBrowserNodeDefinition.Label = assemblyName Then
oAsmBrowserNode.Expanded = True
'get selected browsernodes and set name in list
For Each oBrowserNode As Inventor.BrowserNode In oAsmBrowserNode.BrowserNodes
If oBrowserNode.Selected = True Then
Dim browserNodeName As String = oBrowserNode.BrowserNodeDefinition.Label
oListOfSelectedBrowserNodeNames.Add(browserNodeName)
End If
Next
Exit For
End If
Next
End If
Next
'loop through other views and select the same items items
For Each oViewBrowserNode As Inventor.BrowserNode In oBladBrowserNode.BrowserNodes
'1e view level
If oViewBrowserNode.FullPath.Contains("VIEW") Then
'check of view is shaded -> dan overslaan
Dim oDrawingView As Inventor.DrawingView = oViewBrowserNode.NativeObject
If oDrawingView.ViewStyle <> Inventor.DrawingViewStyleEnum.kShadedDrawingViewStyle Then
For Each oSubViewBrowserNode As Inventor.BrowserNode In oViewBrowserNode.BrowserNodes
'2e view level
If oSubViewBrowserNode.FullPath.Contains("VIEW") Then
For Each oSub2ViewBrowserNode As Inventor.BrowserNode In oSubViewBrowserNode.BrowserNodes
'3e view level
If oSub2ViewBrowserNode.FullPath.Contains("VIEW") Then
'3e view level assembly
SelectItemsInAssemblyBrowserNode(oSub2ViewBrowserNode, assemblyName, oListOfSelectedBrowserNodeNames)
End If
Next
'2e view level assembly
SelectItemsInAssemblyBrowserNode(oSubViewBrowserNode, assemblyName, oListOfSelectedBrowserNodeNames)
End If
Next
End If
End If
Next
'change layer of selected items