Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Reference same or common parts in multiple sub assemblies to BOM

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
Andy20002
618 Views, 9 Replies

Reference same or common parts in multiple sub assemblies to BOM

How do you reference say for example part 1, 2 and 4 etc which is used on assembly A or F to be in BOM or custom ipropeties.

Is there any ilogic to implement this? Or instant properties to able to reference which parts is used on different sub assemblies.

9 REPLIES 9
Message 2 of 10
A.Acheson
in reply to: Andy20002

Hi @Andy20002 

Sub Assemblies will hold the information of parts within (suboccurrences) top down approach. I would suggest not to track the sub assemblies location within the part as it will prevent reuse. You could use instance properties if this is required within the assembly. Can you give some more insight as to the information you would like to track? 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 10
Andy20002
in reply to: Andy20002

As shown in the BOM below:

Cross Bar 8 & 9 is reference to Assembly Frame A,D,F which is the assy ref column. I had to manually write this to custom iproperty and add this to the BOM part list. Is there any way to automate this method through ilogic or by any other quicker method?

Snip Forum 1.png

Message 4 of 10
A.Acheson
in reply to: Andy20002

Hi @Andy20002 

 

The way you did it manually in the parts list is probably the most straight forward way.

Doing so by ilogic Involves:

  • Ensure a unique "AssyRef" iproperty exist in each subassembly.
  • Loop through the Main Assemblies looking for subassemblies
  • Create an iproperty in every child part called "AssyRef" 
  • Look at the parent occurrence of the part occurrence and read the iproperty from the parent and place into the child.
  • Add "AssyRef" as iproperty column in the partslist
  • Read the iproperty in the partlist

This works great until you roll up the parts using their part number and the readable iproperty goes to Varies!

Another solution is to forget about adding an iproperty to the part itself but rather record it's assembly iproperty in a dictionary and then input this value into each row of the partslist. 

 

See below:

Sub Main 
	If Not ThisApplication.ActiveDocumentType = DocumentTypeEnum.kDrawingDocumentObject Then
		 MessageBox.Show("Not a drawing! Exiting") 
		 Return
	End If
	
	Dim DrawDoc As DrawingDocument = ThisDoc.Document
	Dim activeSheet As Sheet = DrawDoc.ActiveSheet
	Dim prtList As PartsList = activeSheet.PartsLists.Item(1)
	Dim asmDoc As AssemblyDocument = prtList.ReferencedDocumentDescriptor.ReferencedDocument
	
	For Each plRow As PartsListRow In prtList.PartsListRows
		Dim dBomRow As DrawingBOMRow = plRow.ReferencedRows.Item(1)
		Dim rowDoc As Document = dBomRow.BOMRow.ComponentDefinitions.Item(1).Document

		TraverseAssembly(asmDoc.ComponentDefinition.Occurrences)
		
		For Each key As String In dict.Keys
			 If rowDoc.FullFileName = key Then
				 Dim AssyRef As PartsListCell = plRow.Item("AssyRef")
				 AssyRef.Value = dict.Item(key)
			 End If
		Next
	Next
End Sub

'Create a dictionary to store the part filename along with the assembly reference
Dim dict As New Dictionary(Of String, String)
	
Private Sub TraverseAssembly(occs As ComponentOccurrences)

   For Each occ As ComponentOccurrence In occs
		If occ.DefinitionDocumentType = DocumentTypeEnum.kPartDocumentObject Then
			Dim partDoc As PartDocument = occ.Definition.Document
			Try
				If partDoc.IsModifiable AndAlso Not occ.ParentOccurrence Is Nothing Then  
					Dim parentDoc As AssemblyDocument = occ.ParentOccurrence.Definition.Document
					Dim partFileName As String = partDoc.FullFileName
					Dim assyRef As String = parentDoc.PropertySets.Item(4).Item("AssyRef").Value
					
					If dict.ContainsKey(partFileName) Then 
						If dict.Item(partFileName) <> "" AndAlso Not dict.Item(partFileName).Contains(assyRef) Then
							dict.Item(partFileName) = dict.Item(partFileName) & "," & assyRef
						End If
					Else
						dict.Add(partFileName, assyRef)
					End If
				End If
			Catch
			End Try
		End If
    
        If occ.DefinitionDocumentType = kAssemblyDocumentObject Then
            TraverseAssembly(occ.SubOccurrences)
        End If
    Next
End Sub	

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 5 of 10
Andy20002
in reply to: A.Acheson

I have run this ilogic code at the drawing level and its working for standard parts only, I think this code doesn't work on frame generator parts within the assemblies. Is there a way to get this code to work with frame generator/content centre parts.

 

See below:

Andy20002_0-1687764108543.png

 

Message 6 of 10
A.Acheson
in reply to: Andy20002

Hi @Andy20002 

You can remove these words within the if statement. This is a true or false check previously used for checking part document access for writing iproperties. It is no longer needed. 

 

Remove only these words from 

partDoc.IsModifiable AndAlso

 Modified line looks like

If occ.ParentOccurrence Is Nothing Then

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 7 of 10
Andy20002
in reply to: A.Acheson

 

 

Sub Main 
	If Not ThisApplication.ActiveDocumentType = DocumentTypeEnum.kDrawingDocumentObject Then
		 MessageBox.Show("Not a drawing! Exiting") 
		 Return
	End If
	
	Dim DrawDoc As DrawingDocument = ThisDoc.Document
	Dim activeSheet As Sheet = DrawDoc.ActiveSheet
	Dim prtList As PartsList = activeSheet.PartsLists.Item(1)
	Dim asmDoc As AssemblyDocument = prtList.ReferencedDocumentDescriptor.ReferencedDocument
	
	For Each plRow As PartsListRow In prtList.PartsListRows
		Dim dBomRow As DrawingBOMRow = plRow.ReferencedRows.Item(1)
		Dim rowDoc As Document = dBomRow.BOMRow.ComponentDefinitions.Item(1).Document

		TraverseAssembly(asmDoc.ComponentDefinition.Occurrences)
		
		For Each key As String In dict.Keys
			 If rowDoc.FullFileName = key Then
				 Dim AssyRef As PartsListCell = plRow.Item("ASSY REF")
				 AssyRef.Value = dict.Item(key)
			 End If
		Next
	Next
End Sub

'Create a dictionary to store the part filename along with the assembly reference
Dim dict As New Dictionary(Of String, String)
	
Private Sub TraverseAssembly(occs As ComponentOccurrences)

   For Each occ As ComponentOccurrence In occs
		If occ.DefinitionDocumentType = DocumentTypeEnum.kPartDocumentObject Then
			Dim partDoc As PartDocument = occ.Definition.Document
			Try
				If occ.ParentOccurrence Is Nothing then  
					Dim parentDoc As AssemblyDocument = occ.ParentOccurrence.Definition.Document
					Dim partFileName As String = partDoc.FullFileName
					Dim assyRef As String = parentDoc.PropertySets.Item(4).Item("ASSY REF").Value
					
					If dict.ContainsKey(partFileName) Then 
						If dict.Item(partFileName) <> "" AndAlso Not dict.Item(partFileName).Contains(assyRef) Then
							dict.Item(partFileName) = dict.Item(partFileName) & "," & assyRef
						End If
					Else
						dict.Add(partFileName, assyRef)
					End If
				End If
			Catch
			End Try
		End If
    
        If occ.DefinitionDocumentType = kAssemblyDocumentObject Then
            TraverseAssembly(occ.SubOccurrences)
        End If
    Next
End Sub	

I have tried changing the code to suit the changes mentioned in the previous post, but the BOM does not change to reflect the content centre parts. Do I need to add anything else to the code to get it to work with the content centre parts?

Message 8 of 10
A.Acheson
in reply to: Andy20002

Hi @Andy20002 

I made one mistake it should include a "Not"

If Not occ.ParentOccurrence Is Nothing Then
If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 9 of 10
Andy20002
in reply to: A.Acheson

I have run it again, it is still not working. It only works on the normal parts but stop once it hit the back cross bar, front cross bar and all other member of the content centre.

Message 10 of 10
Andy20002
in reply to: Andy20002

I have found out the solution, I had to fill in the assy ref within the frame generator frame assembly as well the sub-assemblies for it to work.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report