How to Override BOM ItemNumber without Parent Prefix

How to Override BOM ItemNumber without Parent Prefix

CamperUnhappy
Advocate Advocate
2,702 Views
10 Replies
Message 1 of 11

How to Override BOM ItemNumber without Parent Prefix

CamperUnhappy
Advocate
Advocate

I've done about as much searching as I can and I cannot find an answer to the problem I'm having.

 

The design firm I work for is small and pretty much all of our projects are One-Off's.  As such, we don't create part numbers for our clients drawings we only list items by Item, Qty, Description, and Material.  Currently there is no way inside of inventor to add a parts Item Number tag to a drawing view label.  Because of this, I've had to create my own Custom Property called #ITEM for each part.  Currently I've been testing this out on my own before releasing it to all of the other designers here, but as such....I've been trying to make it more fool-proof and user friendly.

 

Currently I have a button on my add-in that updates the BOM "Item" column to each parts "#ITEM" property, however, I've run into a bit of a snag....

 

 

If I have 2 of the same part that is used in 2 different assemblie (ie. mirrored assemblies with all the same sub-components), then basically whichever part comes last is what values the #ITEM property gets set to.  So I wrote a comparison function to compare values using regular expressions to see which is the lowest item number to use.  All works great up to this point.   The problem is, that I want to update the BOM ItemNumber field to match the #ITEM, but whenever I try to override the BOM ItemNumber in the Structured BOM, the new ItemNumber ALWAYS uses the parent assembly's ItemNumber as a prefix.

 

 

Check out my image...

 

2 different assemblies with identical parts.  But Dummy Prt1 and Dummy Prt2 are named after item 2.1 and 2.2.   If I try to renumber the BOMRow for 2.1, no matter what I do, I always get the prefix "2." on my new name.   I've even tried wiping out the ItemNumber before renaming in my subroutine.

 

BOMRow(2).Childrows(1).ItemNumber = ""

This would give me an Item Number = "2."

 

If I tried BOMRow(2).Childrows(1).ItemNumber = "1.1"

I would get ItemNumber = "2.1.1"

 

That being said, inside of the BOM, I can manually change a BOMRow ItemNumber and it sticks.....  without the prefix.

 

The only way I can think of dealing with this issue is leaving the BOM numbers alone and combining #ITEM numbers like 1.1/2.1.  This seems like such a stupid problem to have for a piece of software that SHOULD have this functionality inside of it already.  I feel like I'm constantly fighting this software because we don't do things exactly the way Autodesk thinks we should and I spend the vast majority of my day trying to find work-arounds.  And then when I finally think I have a solution.....I find another problem because things don't behave as expected (as is my discoverer with changing a BOM Row Item number with the API).

 

2,703 Views
10 Replies
Replies (10)
Message 2 of 11

bradeneuropeArthur
Mentor
Mentor
You could merge the bom by your item nr.
Found in the top of the bom.

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 11

CamperUnhappy
Advocate
Advocate

You cannot merge a BOM by any column you want.  Row merge only works for the Part Number field which is not helpful.

 

 

The problem is the items are in separate assemblies, so how would being able to merge rows even help me unless I used the Parts Only BOM?  Maybe I'm just not quite understanding your suggestion.

 

 

The problem is Inventor won't allow me to have the Item Number tag in a view label like I used to be able to do in AutoCAD, so I found a work-around.  But now the work-around is causing me grief because if I try to override the BOM Item Number it won't let me.

 

 

If I had a part that was 2 assemblies deep, the part number could be 2.3.1.   Say this part is also used in sub assembly 5.3, I i try to renumber the BOM Row number to 2.3.1 I will get 5.3.2.3.1 because there is something going on in the background that concatenates the Parent Assembly Prefix to the newly inserted .ItemNumber property.  IMO this is just stilly....   WHY???   Why would there not be a separate method to override the BOM Row ItemNumber without the part number prefix.  Kind like how you have a Save, Save2 method on documents.....etc.

0 Likes
Message 4 of 11

chandra.shekar.g
Autodesk Support
Autodesk Support

Hello @CamperUnhappy,

 

Try below iLogic code to create custom iProperty(BOM_Item_Number) of part and assigns initial item number of BOM. If already custom iProperty exists, item number of BOM will not be updated. Need to run this iLogic rule in assembly document.

 

Dim oAssDoc As AssemblyDocument
Dim oAssDef As AssemblyComponentDefinition
Dim oBOM As BOM
Dim oBOMView As BOMView
Dim oBOMRow As BOMRow
Dim oCompDef As ComponentDefinition
Dim oCustomProps As PropertySet
Dim oBOMNoProperty As Inventor.Property
Dim sItemNo As String
Const sPropName As String = "BOM_Item_Number"

oAssDoc = ThisDoc.Document
oAssDef = oAssDoc.ComponentDefinition
oBOM = oAssDef.BOM

oBOM.PartsOnlyViewEnabled = True
oBOMView = oBOM.BOMViews.Item("Structured")

For Each oBOMRow In oBOMView.BOMRows
    oCompDef = oBOMRow.ComponentDefinitions(1)
    sItemNo = oBOMRow.ItemNumber
    oCustomProps = oCompDef.Document.PropertySets("User Defined Properties")
    Try
        oBOMNoProperty = oCustomProps.Item(sPropName)        
    Catch
        oBOMNoProperty = oCustomProps.Add(sItemNo, sPropName)
    End Try    
Next

 

Please feel free to contact if there is any queries.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,

 

 

 

 

 


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 5 of 11

CamperUnhappy
Advocate
Advocate

Hi, thanks for the code......however, I already have something similar to this.

 

The problem I'm having isn't writing a custom property or updating the custom property.....   The problem is I cannot update the actually BOM Row Item number properly.  Please re-read my posts, as I went into great detail explaining what the issue is.

 

 

I'll try to visualize it further in a mockup BOM....

 

 

Item      Qty        Part Number      #ITEM

  1           1          Assembly1              1

  1.1        1          Part1                       1.1

  1.2        1          Part2                       1.2

 

   2          1          Assembly1_MIR       2

   2.1       1          Part1                       1.1

   2.2       1          Part2                       1.2

 

 

The custom iProperty "#ITEM" works great for item tags and view labels......however, as you can see the BOM Item number no longer matches the #ITEM field if a part is re-used in a different sub-assembly......like small gusset or something similar.  That being said, I lose a lot of functionality in the BOM environment with sorting/renumbering etc.  I want/need to use the BOM Item Number field.  Using #ITEM in Parts Lists was just a temporary work-around.

 

To get around this for now, I've been substituting the #ITEM field in my Parts Lists and Balloons, however, this ends up being a lot of extra work and I would have to train all of the designers here how to use this method for the BOMs (which I don't want to do and shouldn't have to do).  What my ultimate goal would be is to have an "Update #ITEM Tags" button on my addin that just goes through and matches the #ITEM and ItemNumber fields.

 

Here is the current workflow I'm working on for my code.  I won't post all the code because it's quite long and split into separate functions and subroutines for iterating BOMRows/ChildRows recursively as well as comparing current and previous values.

 

  1. In an assembly or dwg, get a reference to the top-level assembly (in dwg, by using a pick selection).
  2. For all referenced parts in assembly, check for #ITEM custom property and set to ""   (this clears everything for a fresh rename)
  3. For each BOM Row in Structured BOM, get ItemNumber and send through comparison function for #ITEM/ItemNumber
  4. If #ITEM = "" then #ITEM = ItemNumber
  5. If #ITEM <> "" then compares strings and chooses lowest value as winner.  (ie.  3.2.1 would be replaced by 2.3)
  6. If new ItemNumber is lower than previous number, function is Returns True indicating that the BOM Row ItemNumber field should be updated to match #ITEM.  (THIS IS WHERE THE PROBLEM IS)
  7. If function returns false, look through ChildRows and repeat previous steps for new group.

 

There are a few reasons why this whole thing is causing problems.

 

  1. The biggest is that Inventor will not allow you to us an Item Number as a tag or a view label which is absolutely ridiculous considering this whole company started from AutoCAD.
  2. The second is there are no Occurrence level custom properties (other than the name) that I could use to store the Item Number for each occurrence.
  3. I am not able to override a BOM Row ItemNumber without it MAKING me use the top-level assembly's Item Number as a prefix.

 

 

 

0 Likes
Message 6 of 11

chandra.shekar.g
Autodesk Support
Autodesk Support

Hello @CamperUnhappy,

 

Hoping that BOMRow.ItemNumberLocked Inventor API would help to edit BOMRow.ItemNumber.

 

http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-FA8B8AE0-85E3-46C9-87FA-73DB49F08AE9

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 7 of 11

CamperUnhappy
Advocate
Advocate

Haha, nope.....  I tried that already.  Converting an Item Number to "locked" before trying to write a new value to it throws an error.  I'm assuming that's because it changes the ItemNumber property to "read-only"

0 Likes
Message 8 of 11

MechMachineMan
Advisor
Advisor

3 points:

 

1. What do you think is easier - changing the way a company has 1 of their very many large applications programmed, or changing the way YOU use their programs? I would suggest taking a closer look at the latter - you are bound to get better results in a way you like & control that way.

 

2. If you don't use part numbers, why not assign the file name to be the part number so you can use the row merge settings?

 

3. If you are having so much issues with the BOM, why not do the renumbering within the PartsList, which is a system designed SPECIFICALLY for customers to override things to be just how they want with minimal programming interference? Do you actually use the BOM in any other instance - such as driving CADLink software?

 

4. Your item number custom iProperty deal sounds like it should work just fine for what you are trying to do...


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 9 of 11

MechMachineMan
Advisor
Advisor

 

There are a few reasons why this whole thing is causing problems.

 

  1. The biggest is that Inventor will not allow you to us an Item Number as a tag or a view label which is absolutely ridiculous considering this whole company started from AutoCAD.
  2. The second is there are no Occurrence level custom properties (other than the name) that I could use to store the Item Number for each occurrence.
  3. I am not able to override a BOM Row ItemNumber without it MAKING me use the top-level assembly's Item Number as a prefix.


For 1:

 - That's why inventor created balloons and customizable styles.

 - If the first doesn't work for you, use a custom iProp that you CAN push to the View.

 

For 2:

 - If it's the same physical part, you should never be describing it different physically. Use the same item number for both?

 

For 3:

 - Ok, so use the custom Item Number iProperty or do this in BOMS.

 - Inventor is set up so that it maintains the BOMS in a consistent & predictable format - which is why they have those small little quirks programmed in.

   If you want to do something different, custom iProps are great!

 - Item numbers are not just another random iProperty that is useless - they are tied in directly to the API to have specific functions, which is why the          BOMRow.ItemNumber call is a thing, instead of making you grab it by an index (ie; BOMRow.Item("Item Number").


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 10 of 11

MechMachineMan
Advisor
Advisor

I did some more testing, and if you are using an expanded BOM, the part number row merge won't work.

 

The real issue is that the style of BOM you are trying to use is you are trying to use item number as a specific identifier to the part instead of what inventor says it is - a simple index value which corresponds to it's position in the BOM and not the part.

 

Anyways, here is a programmed solution to "modify" the PartsList in a drawing to follow the format you are looking for, with some added indentation on the part numbers for the end user to increase readability.

 

Sub Main()	
	Dim oDwgDoc As DrawingDocument
	oDwgDoc = ThisDoc.Document

	Dim oSheet As Sheet
	oSheet = oDwgDoc.ActiveSheet

	Dim oItemNumberColumn As Integer
	oItemNumberColumn = 1 'This needs to be tweaked for each different PartsListStyleFormat

        Dim oCommonElementColumn As Integer
	oCommonElementColumn = 3 'This needs to be tweaked for each different PartsListStyleFormat

	Dim oPartsList As PartsList
	oPartsList = oSheet.PartsLists.Item(1)
	'For Each oPartsList In oSheet.PartsLists
		'oPartsList.Title = oPartsList.ReferencedDocumentDescriptor.DisplayName & Strings.Space(4) & " -- PARTSLIST"
	
	'Reset PartsList First.
		For Each oRRow In oPartsList.PartsListRows
			For Each oCell In oRRow
				oCell.Static = False
			Next
		Next
	'End reset
	
		For j = 1 To oPartsList.PartsListRows.Count
			oRow = oPartsList.PartsListRows(j)
				For m = j - 1 To 1 Step - 1
					oPreviousRow = oPartsList.PartsListRows(m)
					'MsgBox("j" & j & vbLf & "m" & m & vbLf & oPreviousRow.Item(oCommonElementColumn).Value & vbLf & oRow.Item(oCommonElementColumn).Value)
					If oPreviousRow.Item(oCommonElementColumn).Value = oRow.Item(oCommonElementColumn).Value
						oRow.Item(oItemNumberColumn).Value = oPreviousRow.Item(oItemNumberColumn).Value
						Exit For
					End If
				Next
			oItem = oRow.Item(oItemNumberColumn).Value
			oDotCount = Len(oItem) - Len(Replace(oItem, ".", ""))
			oRow.Item(oItemNumberColumn).Value = Strings.Space(oDotCount) & oItem
		Next
	'Next
End Sub

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 11 of 11

checkcheck_master
Advocate
Advocate

@CamperUnhappy 

What is the status of this?
I run into the same thing.
I go through the browser nodes, their order determines the order of the BoM and so does the Parts List on a drawing.

 

In principle it works except for that one small issue.

0 Likes