iLogic or VBA - List all reference part within a assmbly model

iLogic or VBA - List all reference part within a assmbly model

Anonymous
Not applicable
668 Views
1 Reply
Message 1 of 2

iLogic or VBA - List all reference part within a assmbly model

Anonymous
Not applicable

Hi all

 

has anyone tried to check and list all the reference parts within a 3D assembly model?

like check if all my parts at set to BOM structure Default instead of Reference

 

be nice if there a way to pop up a window to show the parts set to reference

this routine will save me a lot of time

 

thanks

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

ianteneth
Advocate
Advocate

Hi! I know this is an old post, but in case this helps anyone in the future here is a simple iLogic script to list components in an assembly that have a BOM structure set to reference. Note that this script won't check parts inside of sub assemblies.

 

Sub Main()
	
    ' Get current assembly. Assume an assembly is open
    Dim assembly As Inventor.AssemblyDocument = ThisDoc.Document
	
	' Variable to store the results
	Dim output As String = ""
	
	' Loop through each component in the assembly
	For Each occurrence As Inventor.ComponentOccurrence In assembly.ComponentDefinition.Occurrences
		
		' Determine the BOM structure and see if it is referenced
		If occurrence.BOMStructure = Inventor.BOMStructureEnum.kReferenceBOMStructure Then
			
			' Add component to output since the BOM structure is referenced
			output += occurrence.Name & vbNewLine
		End If
	Next occurrence
	
	' Pop up a window with the results
	MessageBox.Show(output)
	
End Sub
0 Likes