Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have this code which so far it will only show the sheet metal parts and weldments within the top level on the assembly.
Dim oAssyDoc As AssemblyDocument
Dim oComp As ComponentOccurrence
Dim oPartDoc As PartDocument
Dim oSheetMetalDef As SheetMetalComponentDefinition
Dim oWeldmentDef As WeldmentComponentDefinition
oAssyDoc = ThisApplication.ActiveDocument
' Iterate through each component in the assembly
For Each oComp In oAssyDoc.ComponentDefinition.Occurrences
' Skip suppressed components
If oComp.Suppressed = False Then
' Check if the component is a part document
If TypeOf oComp.Definition.Document Is PartDocument Then
' Try to cast the document to PartDocument
oPartDoc = oComp.Definition.Document
' Check if the part is a sheet metal part
If Not oPartDoc.ComponentDefinition Is Nothing Then
If TypeOf oPartDoc.ComponentDefinition Is SheetMetalComponentDefinition Then
' Show sheet metal part
oComp.Visible = True
Else
' Hide non-sheet metal parts
oComp.Visible = False
End If
End If
ElseIf TypeOf oComp.Definition Is WeldmentComponentDefinition Then
' Show weldments, even if it's an assembly
oComp.Visible = True
ElseIf TypeOf oComp.Definition Is AssemblyComponentDefinition Then
' Hide other assemblies
oComp.Visible = False
End If
End If
NextI want to include within the code that any sub assemblies that contain sheet metal components or weldments will only show there as well. I would prefer that the documents are not opened and the visibility is only at the top level. Like at the active edit level verse opening a document and making the changes.
The goal for this is I'm trying to nest sheet metal and weldments, but I don't want to have an assembly with alot of parts that can't be nested.
Any insight would be appreciated.
Solved! Go to Solution.