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.
Solved! Go to Solution.
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.
Solved! Go to Solution.
Solved by Andy20002. Go to Solution.
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?
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?
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?
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?
Hi @Andy20002
The way you did it manually in the parts list is probably the most straight forward way.
Doing so by ilogic Involves:
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
Hi @Andy20002
The way you did it manually in the parts list is probably the most straight forward way.
Doing so by ilogic Involves:
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
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:
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:
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
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
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?
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?
Hi @Andy20002
I made one mistake it should include a "Not"
If Not occ.ParentOccurrence Is Nothing Then
Hi @Andy20002
I made one mistake it should include a "Not"
If Not occ.ParentOccurrence Is Nothing Then
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.
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.
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.
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.