How to select all the same (same files) parts in assembly

How to select all the same (same files) parts in assembly

bradeneuropeArthur
Mentor Mentor
722 Views
6 Replies
Message 1 of 7

How to select all the same (same files) parts in assembly

bradeneuropeArthur
Mentor
Mentor

Hi,

 

How can I quick select all same parts within an assembly.

Dim s As Inventor.ComponentOccurrence = ThisApplication.CommandManager.Pick(Inventor.selectionfilterenum.kAssemblyLeafOccurrenceFilter,"select")
	
	'MsgBox(s.Name)
	Dim f As Array = Split(s.Name, ":")
	'MsgBox (f(0))
	Dim a As Inventor.AssemblyDocument = ThisDoc.Document
	Dim d As Inventor.SelectSet = a.SelectSet


	For Each c As Inventor.ComponentOccurrence In a.ComponentDefinition.Occurrences.AllLeafOccurrences
		If c.Name.Contains (f(0)) Then

			d.Select(c)
			
			End If
		Next

End Sub

 

The above works to slow.

 

Regards

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Accepted solutions (2)
723 Views
6 Replies
Replies (6)
Message 2 of 7

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

Maybe this is a faster way.

Dim s As Inventor.ComponentOccurrence = ThisApplication.CommandManager.Pick(Inventor.SelectionFilterEnum.kAssemblyLeafOccurrenceFilter,"select")

Dim f As Array = Split(s.Name, ":")
Dim a As Inventor.AssemblyDocument = ThisDoc.Document
Dim d As Inventor.SelectSet = a.SelectSet

Dim oOccEnum As ComponentOccurrencesEnumerator = a.ComponentDefinition.Occurrences.AllReferencedOccurrences(s.Definition) 
Dim oObjColl As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
For Each oOcc As ComponentOccurrence In oOccEnum
	oObjColl.Add(oOcc)
Next

d.SelectMultiple(oObjColl)

R. Krieg
RKW Solutions
www.rkw-solutions.com
Message 3 of 7

bradeneuropeArthur
Mentor
Mentor

Thanks that works quicker.

Do you know how to suppress these items too?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 4 of 7

Ralf_Krieg
Advisor
Advisor

Hello

 

If you only want to suppress, there's no need to add to SelectSet. You can use the Occurrences in the enum.

Dim s As Inventor.ComponentOccurrence = ThisApplication.CommandManager.Pick(Inventor.SelectionFilterEnum.kAssemblyLeafOccurrenceFilter,"select")

Dim f As Array = Split(s.Name, ":")
Dim a As Inventor.AssemblyDocument = ThisDoc.Document
Dim d As Inventor.SelectSet = a.SelectSet

Dim oOccEnum As ComponentOccurrencesEnumerator = a.ComponentDefinition.Occurrences.AllReferencedOccurrences(s.Definition) 
Dim oObjColl As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
For Each oOcc As ComponentOccurrence In oOccEnum
	oOcc.Suppress 
	'oObjColl.Add(oOcc)
Next

'd.SelectMultiple(oObjColl)

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 5 of 7

bradeneuropeArthur
Mentor
Mentor

But that works slow.

If i suppress thecollection it works fast.

How yo do that with code?

 

Thanks anyway 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 6 of 7

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

Using the ControlDefinition?

Dim s As Inventor.ComponentOccurrence = ThisApplication.CommandManager.Pick(Inventor.SelectionFilterEnum.kAssemblyLeafOccurrenceFilter,"select")

Dim f As Array = Split(s.Name, ":")
Dim a As Inventor.AssemblyDocument = ThisDoc.Document
Dim d As Inventor.SelectSet = a.SelectSet

Dim oOccEnum As ComponentOccurrencesEnumerator = a.ComponentDefinition.Occurrences.AllReferencedOccurrences(s.Definition) 
Dim oObjColl As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
For Each oOcc As ComponentOccurrence In oOccEnum
	'oOcc.Suppress 
	oObjColl.Add(oOcc)
Next

d.SelectMultiple(oObjColl)

ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyCompSuppressionCtxCmd").Execute 

R. Krieg
RKW Solutions
www.rkw-solutions.com
Message 7 of 7

bradeneuropeArthur
Mentor
Mentor

Thanks.

That I did not think about that!

That will work.

Are there also other methods then using the control definition?

Thanks again @Ralf_Krieg 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes