Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Ilogic Bom Unit QTY

marco_bonacina5834P
Contributor

Ilogic Bom Unit QTY

marco_bonacina5834P
Contributor
Contributor

Hi everyone,
Is it possible to extract the QTY unit value  from the BOM?

0 Likes
Reply
Accepted solutions (1)
529 Views
10 Replies
Replies (10)

Michael.Navara
Advisor
Advisor

Yes, see BOMQuantity object in ComponentDefinition.

When it returns empty string, it means "Each" in english or something else in localized versions.

0 Likes

marco_bonacina5834P
Contributor
Contributor

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

0 Likes

AndrewHumiston
Advocate
Advocate

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

 

0 Likes

marco_bonacina5834P
Contributor
Contributor

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.

0 Likes

AndrewHumiston
Advocate
Advocate

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.

0 Likes

AndrewHumiston
Advocate
Advocate
Accepted solution

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

 

AndrewHumiston_0-1722599358838.png

 

0 Likes

marco_bonacina5834P
Contributor
Contributor

This is what I was looking for. I made a mistake compiling this ".BOMQuantity.BaseUnits" part and it was throwing an error.
Thanks.

0 Likes

m_baczewski
Advocate
Advocate

Nevermind

 

0 Likes

AndrewHumiston
Advocate
Advocate
Glad to help! let me know how your project turns out. i do a lot of interfacing with Excel and ilogic/vba. We use a custom user form to drive configurations in ilogic.

have a great week.
0 Likes

marco_bonacina5834P
Contributor
Contributor

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.

0 Likes