Suppress all not SheetPart in assembly and sup assembly via iLogic

Suppress all not SheetPart in assembly and sup assembly via iLogic

BirkirSnaerS
Explorer Explorer
134 Views
1 Reply
Message 1 of 2

Suppress all not SheetPart in assembly and sup assembly via iLogic

BirkirSnaerS
Explorer
Explorer

Hi

 

I have just started trying to use iLogic, I was hoping I could make a rule that suppressed all NOT sheetpart both in the main assembly and also sup assembly.

Is that difficult to figure out?

   

0 Likes
Accepted solutions (1)
135 Views
1 Reply
Reply (1)
Message 2 of 2

ryan.rittenhouse
Advocate
Advocate
Accepted solution

Like a lot of things in iLogic, it's not hard to figure out once you know the API. That'll take some practice. Here's some code that should get you going. I've tried to build and comment the code in a way that help you use the parts of it in the future to build more tools. Let me know if it doesn't work for you or if you have questions.

 

Sub Main()
	
	'Call The Sub w/ the True argument and it'll go all the way through the model tree
	SuppressNonSheetMetalComps(ThisDoc.Document, True)
	
	'Call the Sub w/ False or No extra argument, and it will only do the top level
	SuppressNonSheetMetalComps(ThisDoc.Document)
		
End Sub 'Main

Sub SuppressNonSheetMetalComps(doc As AssemblyDocument, Optional recurse As Boolean = False)
	
	'Loop through all components at the top level of the given document
	For Each comp As ComponentOccurrence In doc.ComponentDefinition.Occurrences
		
		'Ignore things that are already suppressed
		If comp.Suppressed Then Continue For
		
		'Determine what to do base on the Name of the component definition type
		Select Case TypeName(comp.Definition)
			
			'Ignore Sheet Metal and Virtual Components
			Case "SheetMetalComponentDefinition", "VirtualComponentDefinition"
				
			'If recursion is enabled, call this sub for the sub Assembly
			Case "AssemblyComponentDefinition"
				If recurse Then Call SuppressNonSheetMetalComps(comp.Definition.Document, recurse)
			
			'Suppress everything Else
			Case Else
				comp.Suppress
			
		End Select
		
	Next comp
	
End Sub 'SuppressNonSheetMetalComps
If this solved your problem, or answered your question, please click Accept Solution.