I found an iLogic rule that suppresses a placed component in all LOD's not currently in use. This is verry close to what I need but not quite. I want to be able to specify one other LOD to show the component. I could then tweak the code for each component type to show in the LOD its needed in.
We typically do our modeling in Master ISO LOD instead of switching back and forth between LOD's, so this rule does not work for us as is.
Example: If I add this rule to a wall panel and place the panel in the master ISO LOD it needs to show in Master ISO LOD and it also needs to show in the wall's layout LOD but none of the others.
Is there a way for me to add a section in the code that lets me specify an LOD to be left out of the suppression?
Here is what I have to start with:
' Suppress in non-active levels.
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
' Find all selected components and add them to an ObjectCollection.
Dim oSelected As ObjectCollection
oSelected = ThisApplication.TransientObjects. _
CreateObjectCollection (oDoc.SelectSet)
'define LOD rep
Dim oLODRep As LevelOfDetailRepresentation
'define rep manager
Rep_Manager =ThisApplication.ActiveDocument. _
ComponentDefinition.RepresentationsManager
'define an arraylist to hold the list of LOD rep names
Dim NameList As New ArrayList()
'look at the LOD reps in the assembly
For Each oLODRep in Rep_Manager.LevelOfDetailRepresentations
'add the LOD names to the array list
NameList.add(oLODRep.Name)
Next
Dim myLOD as LevelOfDetailRepresentation
'get the name of the active LOD
myLOD = Rep_Manager.ActiveLevelOfDetailRepresentation
'remove active LOD from list
NameList.remove(myLOD.name)
'remove standard LODs from list
NameList.remove("Master")
NameList.remove("All Components Suppressed")
NameList.remove("All Parts Suppressed")
NameList.remove("All Content Center Suppressed")
'step through the LOD list
'and suppress the selected components
Dim sName as String
For Each sName in NameList
'Activate the LOD
Rep_Manager.LevelOfDetailRepresentations(sName).Activate
For Each oObject in oSelected
Try
'suppress component
Component.IsActive(oObject.Name) = False
Catch ' catch any errors
End Try
Next
ThisDoc.Save
Next
Hi @Welbilt_Designer_3. I attempted to create an alternate iLogic rule code for you, but I am unable to test it because I am using 2024 version which no longer has LOD's, and the iLogic rule editor window no longer suggests them either in its Intellisense system either. You can give this example a try and see if it works any better for you if you want.
Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim oSS As SelectSet = oDoc.SelectSet
If oSS.Count = 0 Then Return
Dim oOccsToSuppress As New List(Of Inventor.ComponentOccurrence)
For Each oObj In oSS
If TypeOf oObj Is ComponentOccurrence Then
Dim oSelOcc As ComponentOccurrence = oObj
oOccsToSuppress.Add(oSelOcc)
End If
Next
If oOccsToSuppress.Count = 0 Then Return
Dim oRepMgr As RepresentationsManager = oDoc.ComponentDefinition.RepresentationsManager
Dim oLODs As LevelOfDetailRepresentations = oRepMgr.LevelOfDetailRepresentations
Dim oActiveLOD As LevelOfDetailRepresentation = oRepMgr.ActiveLevelOfDetailRepresentation
Dim oLOD As LevelOfDetailRepresentation
For Each oLOD In oLODs
If oLOD Is oActiveLOD Then Continue For
If oLOD.LevelOfDetail <> LevelOfDetailEnum.kCustomLevelOfDetail Then Continue For
oLOD.Activate
For Each oOcc In oOccsToSuppress
Try
oOcc.Suppress 'similar to Component.IsActive = False
Catch
End Try
Next 'oOcc
Next 'oLOD
If oRepMgr.ActiveLevelOfDetailRepresentation IsNot oActiveLOD Then
oActiveLOD.Activate
End If
If oDoc.RequiresUpdate Then oDoc.Update2(True)
If oDoc.Dirty Then oDoc.Save2(True)
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield
(Not an Autodesk Employee)
Can't find what you're looking for? Ask the community or share your knowledge.