Not applicable
06-14-2017
08:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Can I do the following with iLogic, C#, VB.NET, ...?
I now have code to loop through all occurrences, but this would be a faster way to obtain the same result.
The reason for this is that I only want to keep the items visible with a custom property (SPL_Simple).
With this I could select all those items very quick.
I just can't find a way to do this in code:
My current code to loop (iLogic -> slow solution and not always correct):
Sub Main() InventorVb.DocumentUpdate() iLogicVb.UpdateWhenDone = True Dim oAsmCompDef As AssemblyComponentDefinition oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition SetRepresentation(oAsmCompDef) Iterate(oAsmCompDef,1,False) End Sub Sub SetRepresentation(ByVal oAsmCompDef As AssemblyComponentDefinition) Try Dim oViewRep As DesignViewRepresentation For Each oViewRep In oAsmCompDef.RepresentationsManager.DesignViewRepresentations If oViewRep.Name = Globals._headRepresentation Then oViewRep.Activate oViewRep.HideAll() End If Next Catch End Try End Sub Sub Iterate(ByVal oAsmCompDef As AssemblyComponentDefinition, ByVal top As Integer, ByVal visibleParam As Boolean) Dim oOccurrence As ComponentOccurrence For Each oOccurrence In oAsmCompDef.Occurrences Globals._countOcc(0) = Globals._countOcc(0) + 1 Dim oOccName As String = oOccurrence.Name Try Dim doc = oOccurrence.Definition.Document Dim propSet = doc.propertySets(Globals._propSet) Dim isVisible As Boolean = visibleParam For Each prop In propSet If prop.Name = Globals._param Then If prop.Value.ToString = Globals._paramVal Then isVisible = True Exit For End If End If Next If isVisible = True oOccurrence.Visible = True Try Component.Visible(oOccurrence.Name) = True Catch ex As Exception End Try 'Component.InventorComponent(oOccurrence.Name).Visible = True -> Not Working Propper If TypeOf oOccurrence.Definition Is AssemblyComponentDefinition Then oAsmCompDef = oOccurrence.Definition Iterate(oAsmCompDef,2,False) End If Else oOccurrence.Visible = False If TypeOf oOccurrence.Definition Is AssemblyComponentDefinition Then oAsmCompDef = oOccurrence.Definition Iterate(oAsmCompDef,2,False) End If End If Catch ex As Exception End Try Next If top = 1 Then Globals._countLoop(0) = Globals._countLoop(0) + 1 End If End Sub Friend NotInheritable Class Globals Public Shared _countOcc = New Integer() {0} Public Shared _countLoop = New Integer() {0} Public Shared _headRepresentation As String = "Default" Public Shared _param As String = "SPL_Simple" Public Shared _paramVal As String = "True" Public Shared _propSet As String = "Inventor User Defined Properties" End Class
Solved! Go to Solution.
Link copied