custom item numbers

custom item numbers

bsnyderACLUW
Enthusiast Enthusiast
477 Views
3 Replies
Message 1 of 4

custom item numbers

bsnyderACLUW
Enthusiast
Enthusiast

Hi everyone,

 

I am looking to make a program that will re-number all of the Item Numbers for an assembly BOM. (I use Structured BOM's) Below is what I have come up with so far. Basically i want the last four numbers in the part number to be the new item number and for any parts that are "PURCHASED PARTS" I want a sequential numbering scheme. (an example of this is bellow) Ultimately I need help with the If statement and the sequential numbering. I have done a ton of googling and searching this forum and tried many things i thought might work but have gotten no where. any help will be appreciated. 

 

thanks you,

Dim oDrawing As DrawingDocument = ThisDrawing.Document
Dim oCount As Array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
For Each oSheet As Sheet In oDrawing.Sheets
	For Each oPartsList As PartsList In oSheet.PartsLists
		For Each oRow As PartsListRow In oPartsList.PartsListRows
			For Each oBOMRows As DrawingBOMRow In oRow.ReferencedRows
				'oCell = oPartsList.PartsListRows.Item(I).Item("Material")
				'If  oCell.Value = "PURCHASED PART" Then
					i = "SA-" & oCount
					oBOMRows.BOMRow.ItemNumber = i 
				'Else If oCell.Value <> "PURCHASED PART"
					'Dim oPnum As String = oBOMRows.BOMRow.ComponentDefinitions(1).Document.PropertySets.Item("Design Tracking Properties") _
					'.Item("Part Number").Value
					'oBOMRows.BOMRow.ItemNumber = oPnum.Substring(oPnum.Length - 4)
				'End If 
			Next
		Next
	Next
Next

bsnyderACLUW_0-1608754365616.png

 

0 Likes
478 Views
3 Replies
Replies (3)
Message 2 of 4

bradeneuropeArthur
Mentor
Mentor

Why you don't add a custom property to the parts already with that number. For example CustomItem = 2002. Then use this CustomItem property in your ballooning instead of Item!

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 4

bsnyderACLUW
Enthusiast
Enthusiast

Hi @bradeneuropeArthur ,

 

Thank you for the idea. Unfortunately I don't think that will be reasonable for me to do. I would need to incorporate this into all the current project we have (hundreds of projects with thousands of parts per project). Even if I was able to make an iLogic rule to do this, it would take a considerable amount of time to complete. Also this won't solve my problem of sequential numbering of the purchased parts. These are used across many projects and there are hundreds of purchased parts that are not used in every project. 

 

I did, how ever,  find the solution to the sequential numbering of the SA-# for the standard parts. as the code stands each part if the If statement work independently of each other but I still cant get the if statement to work. I get an error "The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))". I am assuming this has to do with the value stored in the MATERIAL cell I am calling. I don't know why so I don't know how to fix or if there is a fundamental I am missing. 

 

Thanks,

Dim oDrawing As DrawingDocument = ThisDrawing.Document
Dim oCount As Long
For Each oSheet As Sheet In oDrawing.Sheets
	For Each oPartsList As PartsList In oSheet.PartsLists
		For Each oRow As PartsListRow In oPartsList.PartsListRows
			For Each oBOMRows As DrawingBOMRow In oRow.ReferencedRows
				oCell = oPartsList.PartsListRows.Item(I).Item("MATERIAL")
				If  oCell.Value = "PURCHASED PART" Then
					oCount = oCount + 1
					i = "SA-" & oCount
					oBOMRows.BOMRow.ItemNumber = i 
				Else If oCell.Value <> "PURCHASED PART"
					Dim oPnum As String = oBOMRows.BOMRow.ComponentDefinitions(1).Document.PropertySets.Item("Design Tracking Properties") _
					.Item("Part Number").Value
					oBOMRows.BOMRow.ItemNumber = oPnum.Substring(oPnum.Length - 4)
				End If 
			Next
		Next
	Next
Next
0 Likes
Message 4 of 4

bsnyderACLUW
Enthusiast
Enthusiast

final working solution, is dependent on the material type to be labeled as Purchased Part. for anyone that can find use for it.

 

thanks,

Dim oDrawing As DrawingDocument = ThisDrawing.Document
Dim oCount As Long
For Each oSheet As Sheet In oDrawing.Sheets
	For Each oPartsList As PartsList In oSheet.PartsLists
		For Each oRow As PartsListRow In oPartsList.PartsListRows
			For Each oBOMRows As DrawingBOMRow In oRow.ReferencedRows
				Dim oCell As String = oBOMRows.BOMRow.ComponentDefinitions(1).Document.PropertySets.Item("Design Tracking Properties").Item("MATERIAL").Value
				oBOMRows.BOMRow.ItemNumber = oCell.Substring(oCell.Length - 4)
				If  oCell = "PURCHASED PART" Then
					oCount = oCount + 1
					i = "SA-" & oCount
					oBOMRows.BOMRow.ItemNumber = i 
				Else If oCell <> "PURCHASED PART"
					Dim oPnum As String = oBOMRows.BOMRow.ComponentDefinitions(1).Document.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value
					oBOMRows.BOMRow.ItemNumber = oPnum.Substring(oPnum.Length - 4)
				End If 
			Next
		Next
	Next
Next
0 Likes