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: 

iLogic code to Suppress Components based on Color (or other property)?

1 REPLY 1
Reply
Message 1 of 2
djgrooster
620 Views, 1 Reply

iLogic code to Suppress Components based on Color (or other property)?

I am currently using Autodesk Inventor Professional 2012.

I'm looking for an iLogic code which I can run in my Assembly File which will suppress any component that is not the selected color.
I thought it would go somewhat along the lines of:

If Component.Color()="Red" Then
Component.IsActive() = True
Else Component.IsActive()= False
End If
Next

 

Which gives errors because I'm not defining the name of each individual component.So I assume I need a way to tell it to procedurally check the color of each component, which is where I'm stumped.
The application is my assembly has multiple isolated systems in the same assembly, and I'm trying to create a Level of Detail for each Isolated system within the assembly, without having to suppress each component one at a time.

 

Any help is appreciated, thank you

1 REPLY 1
Message 2 of 2
pcrawley
in reply to: djgrooster

Try this.  

 

I use it all the time for tasks that involve running through an assembly and "doing things" to the components.  I'd love to take credit for it, but it's come from a variety of sources over time.  So thanks to everyone!

 

Look in the comments for clues.  If you run it "as is" on an assembly, it'll give you a message box that reads the Part Number of each component.

 

Peter

 

fmgr = ThisApplication.Filemanager
For Each file In fmgr.files
    doc = ThisApplication.Documents.ItemByName (file.fullfileName)
    compdef = doc.ComponentDefinition
    If (doc.documenttype = 12291) Then 'Found an ASSEMBLY    
        For Each occ In compdef.Occurrences
            If (occ.definition.type = 83886592) Then 'Found a PART                
                'Add whatever you like here for the PART file                'Remember to add the occ.Name into everything to catch the part file itself                'If you forget it, you'll get the host Assembly                MessageBox.Show("Part name: " & iProperties.Value(occ.Name, "Project", "Part Number"))
            
            End If
        Next occ
    End If
Next file

InventorVb.DocumentUpdate() 'Update 
Peter

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

Post to forums  

Autodesk Design & Make Report