Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
jesserop
249 Views, 3 Replies

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

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

Labels (1)
3 REPLIES 3
Message 2 of 4
dalton98
in reply to: jesserop

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
Message 3 of 4
jesserop
in reply to: dalton98

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? 

Message 4 of 4
dalton98
in reply to: jesserop

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  

 

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

Post to forums  

Autodesk Design & Make Report