Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get active Level of Detail (string value) in iLogic

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
astarnes
1828 Views, 5 Replies

Get active Level of Detail (string value) in iLogic

My intention is to have a rule that will run through each pattern in an assembly containing a certain string value, and then suppress all it's components only when a certain level of detail is active.  I've seen on these forums how to activate an LOD using iLogic, but I want the opposite where I get the LOD string value rather than set it.

 

When I change to a larger member in my iAssembly and then activate a level of detail suppressing all my Patterns for screws, inventor wont recognize the newly generated components within each pattern to need to be suppressed like the others.  So far I have a rule written to find and suppress these pattern, but i dont know how to have the rule automiatically run ONLY IF the level of detail "Steel_Frame" is selected.

 

Where it says <Insert LOD Code> below is where I need to declare the Level of Detail and use an If statement on the whole thing to run only IF LOD = "Steel_Frame"

 

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

'<Insert LOD Code>

If LOD = "Steel_Frame" Then
    Dim oPattern As OccurrencePattern
    Dim oList As New ArrayList
    
    For Each oPattern In oAsmCompDef.OccurrencePatterns
        If oPattern.Name.Contains("Screw") Then
            Dim oElement As OccurrencePatternElement
            For Each oElement In oPattern.OccurrencePatternElements
                Dim oComp As ComponentOccurrence
                oComp = oElement.Occurrences.Item(1)
                oComp.Suppress
            Next
        End If
    Next
End If
 
5 REPLIES 5
Message 2 of 6

Hi astarnes,

 

You can use the ActiveLevelOfDetailRepresentation property for this. Here's a quick example.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

'define document
oDoc= ThisDoc.Document
'define LOD rep 
Dim oLODRep As LevelOfDetailRepresentation
'define rep manager
Rep_Man =oDoc.ComponentDefinition.RepresentationsManager
'get active LOD 
oLODRep = Rep_Man.ActiveLevelOfDetailRepresentation
MessageBox.Show("The Active LOD is called: " & oLODRep.Name, "iLogic")

 

 

Edit: Using what you already have with the component definition, this would work also:

 

'define the ComponentDefinition
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
'define LOD rep 
Dim oLODRep As LevelOfDetailRepresentation
'define rep manager
Rep_Man =oAsmCompDef.RepresentationsManager
'get active LOD 
oLODRep = Rep_Man.ActiveLevelOfDetailRepresentation
MessageBox.Show("The Active LOD is called: " & oLODRep.Name, "iLogic")

 

 

 

Message 3 of 6

Thanks Curtis!

 

Thats exactly what i'm looking for.

Message 4 of 6

Is there a good way to trigger a rule when you change the level of detail?  I've tried using the parameter trigger (iTrigger0) and an event trigger (Any component change or suppression), and both seem to not trigger the rule.  Currently I have it set to where it will trigger before saving.

Message 5 of 6

 

Hi astarnes,

 

Unfortunately, I can't think of a way to do that based on the user switching LODs.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Message 6 of 6

Thanks Curtis - I also found this code useful in some iLogic for inserting CoG work points for various levels of detail.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report