Set item digit as last word/digit as part number.

Set item digit as last word/digit as part number.

jesserop
Advocate Advocate
295 Views
3 Replies
Message 1 of 4

Set item digit as last word/digit as part number.

jesserop
Advocate
Advocate

Hi all,

 

Is there a vba macro available that sets the last part of a partname as the itemnr in the bomlist?

It only has to change the item in the bomlist in 2D drawing, nothing to the part his bomstatus itself.

vba.PNG

0 Likes
Accepted solutions (2)
296 Views
3 Replies
Replies (3)
Message 2 of 4

dalton98
Collaborator
Collaborator
Accepted solution

Heres rough example that worked for me. If all of your part numbers have the same format then you could look into formatting strings. Might be cleaner working with it that way.

On Error Resume Next
Dim oDDoc As DrawingDocument = ThisDoc.Document
Dim oPartsList As PartsList = oDDoc.ActiveSheet.PartsLists(1)
Dim partnumber As String = "12141-1123-95-MASTER"
For Each oRow As PartsListRow In oPartsList.PartsListRows
	Dim ItemDigit() As String = oRow.Item(3).Value.Split("-")
	
	oRow.Item(1).Value = ItemDigit(ItemDigit.Count - 2) & "-" & ItemDigit(ItemDigit.Count - 1)
	oRow.Item(3).Value = oRow.Item(3).Value.Split(ItemDigit(ItemDigit.Count - 2) & "-" & ItemDigit(ItemDigit.Count - 1))(0)
Next
0 Likes
Message 3 of 4

jesserop
Advocate
Advocate

Thanks a lot! One little question. 
The part number in the partslist has an override now, so it doesn't update with changes. 
Is there any way to leave the part number by default? 

0 Likes
Message 4 of 4

dalton98
Collaborator
Collaborator
Accepted solution

You can just comment out the line that changes the row for the part number if you don't want it to change. Or making sure the cell value isnt static:

oRow.Item(3).Static = False  

 

0 Likes