Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I have a rule that changes part material assignments from the assembly level (handy). I works by creating an object collection based on manual selections by the user, Ive added in a highlight set as well for usability. My only issue is that I would like something to be removed from the object collection and highlight set if it selected again (i.e. typical way you would un-select something).
Anyone got any hints? Ive attached my code below as well.
Dim oAsset As Asset
Dim oHighlight As Inventor.HighlightSet
oHighlight = ThisDoc.Document.CreateHighlightSet
oHighLight.Color = ThisApplication.TransientObjects.CreateColor(255,105,180)
Dim oAsset_Array As New ArrayList
For Each oAsset_Array_X In ThisApplication.ActiveMaterialLibrary.MaterialAssets
oAsset_Array.Add(oAsset_Array_X.DisplayName)
oAsset_Array.Sort()
Next
'present the user with the list to choose from
oAsset_Array_Selected = InputListBox("CHOOSE MATERIAL FROM ABOVE LIST", oAsset_Array, oAsset_Array.Item(1), "MATERIAL SELECTION", "LIST OF MATERIALS",600,0)
If oAsset_Array_Selected = "" Then
Return
End if
Dim comps As ObjectCollection
Dim comp As Object
comps = ThisApplication.TransientObjects.CreateObjectCollection
While True
comp = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select a component. Press ESC to end selection")
' If nothing gets selected then we're done
If IsNothing(comp) Then Exit While
comps.Add(comp)
Call oHighlight.AddItem(comp)
End While
' If there are selected components we can do something
For Each comp In comps
Dim oDef As PartDocument
oDef = comp.Definition.Document
Dim oRenderStyle As String
oRenderStyle = oAsset_Array_Selected
oDef.ActiveMaterial.DisplayName = oRenderStyle
iLogicVb.UpdateWhenDone = True
Next
oHighlight.Clear
Solved! Go to Solution.