Looping through all sub assemblies to delete invisible parts & patterned parts

Looping through all sub assemblies to delete invisible parts & patterned parts

Damian_LeeF852L
Explorer Explorer
114 Views
1 Reply
Message 1 of 2

Looping through all sub assemblies to delete invisible parts & patterned parts

Damian_LeeF852L
Explorer
Explorer

I am trying to find some ilogic code to loop through my sub assemblies to delete all parts and patterns that are set to invisible. I have tried several things but so far I have not managed to achieve the desired result.

 

Any help would be greatly appreciated.

0 Likes
115 Views
1 Reply
Reply (1)
Message 2 of 2

C_Haines_ENG
Collaborator
Collaborator

Heres a simple solution:

 

Sub Main
	
	Dim oAsm As AssemblyDocument = ThisDoc.Document
	
	For Each oPattern As OccurrencePattern In oAsm.ComponentDefinition.OccurrencePatterns
		
		If oPattern.Visible = False Then oPattern.Delete
		
	Next
	
	For Each oComp As ComponentOccurrence In oAsm.ComponentDefinition.Occurrences.AllLeafOccurrences
		
		If oComp.Visible = False Then oComp.Delete
		
	Next
	
End Sub
0 Likes