Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
JhoelForshav
in reply to: Anonymous

Hi @Anonymous 

Assuming that the main partslist is the first partslist of the first sheet in the document, and the itemnumber is the first cell of each row in your partslist style, this should at least make it look right. I couldn't find a way to change the start index of the partslists for the individual parts, but you can override the value with a static value.

There are a lot of loops in this code but at least it worked when I tried it :grinning_face_with_smiling_eyes:

 

Dim oDrawing As DrawingDocument = ThisDoc.Document
Dim oMainPartsList As PartsList = oDrawing.Sheets(1).PartsLists(1)
For Each oRow As PartsListRow In oMainPartsList.PartsListRows
	For Each oBOMrow As DrawingBOMRow In oRow.ReferencedRows
		For Each oDef As ComponentDefinition In oBOMrow.BOMRow.ComponentDefinitions
			For Each oSheet As Sheet In oDrawing.Sheets
				For Each oPartsList As PartsList In oSheet.PartsLists
					If oPartsList IsNot oMainPartsList
						If oPartsList.ReferencedDocumentDescriptor.ReferencedDocument Is oDef.Document _
						Then oPartsList.PartsListRows.Item(1).Item(1).Value = oBOMrow.BOMRow.ItemNumber
					End If
				Next
				oSheet.Update
			Next
		Next
	Next
Next