Community
I think my problem is in one of these:
SyntaxEditor Code Snippet
'look at all of the components in the assembly Dim oCompDef As Inventor.ComponentDefinition = openDoc.ComponentDefinition 'define the first level components collection Dim oCompOcc As Inventor.ComponentOccurrence
they're used in the bit of code that sets visibility for parts in an assembly but I need it to work on parts in a subassembly.
Is there a way to fix those so I can work with parts that are at least one level down?
Hi, from what you've posted you'r code would continue like this, right? For the top level components:
' Look at all of the components in the assembly Dim oCompDef As Inventor.ComponentDefinition = openDoc.ComponentDefinition ' Define the first level components collection Dim oCompOcc As Inventor.ComponentOccurrence For Each oCompOcc In oCompDef.Occurrences ' Toggle the top component's visibility oCompOcc.Visible = Not oCompOcc.Visible
' Skip if it isn't assembly If Not oCompOcc.DefinitionDocumentType.ToString = "kAssemblyDocumentObject" Then Continue For ' Here we can continue deeper: Dim oOcc As Inventor.ComponentOccurrence
For Each oOcc In oCompOcc.Definition.Occurrences ' Toggle the sub component's visibility oOcc.Visible = Not oOcc.Visible Next Next
Sorry, I ran out of time and had to brute force it.
When this job is done and I have some time I will play around with a dummy assembly (or the next job) and see how it works.
Thanks for the effort.
Can't find what you're looking for? Ask the community or share your knowledge.