- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone,
Is it possible to extract the QTY unit value from the BOM?
Solved! Go to Solution.
The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.
Hi everyone,
Is it possible to extract the QTY unit value from the BOM?
Solved! Go to Solution.
Yes, see BOMQuantity object in ComponentDefinition.
When it returns empty string, it means "Each" in english or something else in localized versions.
Is it possible to have a practical example?
I tried with "oRow.BOMQuantity" but I get an error
I then have to export this value to an Excel cell
are you using ilogic or VBA?
here is a quick VBA with dialog box so you can see the qty.
Sub GetBOMQty()
Dim oActiveDoc As AssemblyDocument
Set oActiveDoc = ThisApplication.ActiveDocument
Dim oBOM As BOM
Set oBOM = oActiveDoc.ComponentDefinition.BOM
Dim oStructView As BOMView
Set oStructView = oBOM.BOMViews.Item("Structured")
For Each oBomRow In oStructView.BOMRows
oItemQty = oBomRow.ItemQuantity
oItemTotalQty = oBomRow.TotalQuantity
Call MsgBox("Item Name: " & oBomRow.ComponentDefinitions.Item(1).Document.DisplayName & vbNewLine & "Item Qty: " & oItemQty & vbNewLine & "Item Total Qty: " & oItemTotalQty, vbOKOnly, "BOM Qty Information...")
Next
End Sub
Hi, thanks for the reply but it's not what I need. I would like to export the unit quantity (each, mm, m, etc.) from the BOM.
At the moment I am creating a customized iproperties from each single part or subassembly, I wanted to understand if it is possible to obtain it directly from the BOM in which it should already be contained.
it is contained, thats why i triggered the msgbox so you can see the data. you have to access the BOM first, then select wich BOM structure to look at, then loop through each row and find the properties you are looking for in that row for each item.
the other method is to look at the BOM columns object, find the Column you want based on a value, store that index number, then use that index number to search through the rows to find the data you are looking for.
here is a VBA code to go into the BOM Row and to the component in that row and retrieve the base unit.
Sub GetBOMQty()
Dim oActiveDoc As AssemblyDocument
Set oActiveDoc = ThisApplication.ActiveDocument
Dim oBOM As BOM
Set oBOM = oActiveDoc.ComponentDefinition.BOM
Dim oStructView As BOMView
Set oStructView = oBOM.BOMViews.Item("Structured")
For Each oBomRow In oStructView.BOMRows
oItemQty = oBomRow.ItemQuantity
oItemTotalQty = oBomRow.TotalQuantity
oBaseUnit = oBomRow.ComponentDefinitions.Item(1).BOMQuantity.BaseUnits
Call MsgBox("Item Name: " & oBomRow.ComponentDefinitions.Item(1).Document.DisplayName & vbNewLine & "Item Qty: " & oItemQty & vbNewLine & "Item Total Qty: " & oItemTotalQty & vbNewLine & "Base units: " & oBaseUnit, vbOKOnly, "BOM Qty Information...")
Next
End Sub
This is what I was looking for. I made a mistake compiling this ".BOMQuantity.BaseUnits" part and it was throwing an error.
Thanks.
I just need to export the unit of measurement of the reference row to be indicated in an Excel sheet for data exchange with production. The solution proposed by @AndrewHumiston is right for me.