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: 

Using ilogic to delete all invisible components in assembly

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Skwiggle
1550 Views, 2 Replies

Using ilogic to delete all invisible components in assembly

I am looking for code to delete all components in an assembly that are not set to be visible. Any help would be greatly appreciated.
2 REPLIES 2
Message 2 of 3
cwhetten
in reply to: Skwiggle

Hi and welcome to the forum!

 

What have you tried so far?

 

Here is a basic chunk of code:

 

oComps = ThisDoc.Document.ComponentDefinition.Occurrences

For Each oComp In oComps
    If Not oComp.Visible Then
        oComp.Delete
    End If
Next

 

This will not work for invisible components that are in subassemblies--only components at the top level.  You could copy this into each subassembly that needs it, or re-write the code to account for multiple levels of components, but this would become much more complicated.

 

Also, I'm not sure how well this works on components inside of a pattern, but I suspect it would have to be re-written to account for patterns.

 

Please click "Accept as Solution" if this response answers your question.

Cameron Whetten
Inventor 2014

Message 3 of 3
Skwiggle
in reply to: cwhetten

Thank you, that works fine.

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

Post to forums  

Autodesk Design & Make Report