Enabling Parts and Subassemblies in One Operation

Enabling Parts and Subassemblies in One Operation

mateusz_baczewski
Advocate Advocate
133 Views
1 Reply
Message 1 of 2

Enabling Parts and Subassemblies in One Operation

mateusz_baczewski
Advocate
Advocate

Hi,

 

Is there a way to enable all the parts and subassemblies in within a single operation? Right now, I'm creating a list of parts and subassemblies to enable and disable, then iterating through these elements to turn them on or off accordingly:

 

Logger.Info("_______Unsuppress_________")
For Each element As ComponentOccurrence In objectToUnsuppress
	Logger.Info(element.Name)
	element.Unsuppress
Next
Logger.Info("_______Suppress_________")
For Each element As ComponentOccurrence In objectToSuppress
	Logger.Info(element.Name)
	element.Suppress
Next

 

Additionally, I want to enable/disable elements at different levels, meaning both in the main

assembly and within subassemblies. In another project, I'm using:

 

If(oSelectSet.Count>0)
	ThisApplication.CommandManager.ControlDefinitions("AssemblyCompSuppressionCtxCmd").Execute2(True)
	oSelectSet.Clear
End If

 

However, all the elements I enable or disable are in the main assembly, which works fine. But if the parts are at different levels, it no longer works.

Do you know of a way to accomplish this in a single operation? I want to do this because it significantly speeds up rule execution.

If you found it helpful, a "Like" would be much appreciated!
If this post solved your problem, please mark it as "Solution.".

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

C_Haines_ENG
Collaborator
Collaborator

This is a very basic script, but it should put you on the right path. The trick is to access the components in the context of their respective assemblies. This will suppress everything in the document by the way.

 

Dim oAsm As AssemblyDocument = ThisDoc.Document

For Each oComp As ComponentOccurrence In oAsm.ComponentDefinition.Occurrences

	Dim DocType As DocumentTypeEnum = oComp.Definition.Document.DocumentType

	If DocType = kPartDocumentObject

		oComp.Suppress

	ElseIf DocType = kAssemblyDocumentObject

		Dim oSubAsm As AssemblyDocument = oComp.Definition.Document

		For Each oSubComp As ComponentOccurrence In oSubAsm.ComponentDefinition.Occurrences

			oSubComp.Suppress

		Next

	End If

Next

 

 

0 Likes