I have a question, i opened the drawing file Clutch_Bell_Simplified.iam. And i can get the bom by the API like this below.
Public Sub BOMQuery() ' Set a reference to the assembly document. ' This assumes an assembly document is active. Dim oDoc As AssemblyDocument Set oDoc = ThisApplication.ActiveDocument Dim FirstLevelOnly As Boolean If MsgBox("First level only?", vbYesNo) = vbYes Then FirstLevelOnly = True Else FirstLevelOnly = False End If ' Set a reference to the BOM Dim oBOM As BOM Set oBOM = oDoc.ComponentDefinition.BOM ' Set whether first level only or all levels. If FirstLevelOnly Then oBOM.StructuredViewFirstLevelOnly = True Else oBOM.StructuredViewFirstLevelOnly = False End If ' Make sure that the structured view is enabled. oBOM.StructuredViewEnabled = True 'Set a reference to the "Structured" BOMView Dim oBOMView As BOMView Set oBOMView = oBOM.BOMViews.Item("Structured") Debug.Print "Item"; Tab(15); "Quantity"; Tab(30); "Part Number"; Tab(70); "Description" Debug.Print "----------------------------------------------------------------------------------" 'Initialize the tab for ItemNumber Dim ItemTab As Long ItemTab = -3 Call QueryBOMRowProperties(oBOMView.BOMRows, ItemTab) End Sub
BOM informations include "Part Number,Thumbnail,Bom Structure,Unit QYT,QYT,Stock Number,Description". Then how can get the same informations like BOM from the top parent node:"Clutch_Bell_Simplified.iam"?
Solved! Go to Solution.
Solved by WCrihfield. Go to Solution.
Solved by A.Acheson. Go to Solution.
You would access the iproperties through the document property sets. Api sample here
Some more info here on the property sets.
Public Sub GetPropertySample() ' Get the active document. Dim invDoc As Document Set invDoc = ThisApplication.ActiveDocument ' Get the design tracking property set. Dim invDesignInfo As PropertySet Set invDesignInfo = invDoc.PropertySets.Item("Design Tracking Properties") ' Get the part number property. Dim invPartNumberProperty As Property Set invPartNumberProperty = invDesignInfo.Item("Part Number") MsgBox "Part Number: " & invPartNumberProperty.value End Sub
Hi @2208571753. I'm not 100% sure what you are asking for here, but since your code and image are both focused on the assembly's BOM, I assume you are looking for where all those individual pieces of information you are seeing in the BOM are coming from within the document. So, I have written out a fairly simple bit of iLogic code to help you get a better understanding about where each of those pieces of information are being found within the document.
AddReference "stdole"
Imports stdole
Dim oADoc As AssemblyDocument = ThisDoc.Document
Dim oPartNumber = oADoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value
oThumbnail = oADoc.Thumbnail 'an image (can't view it directly in a simple message)
Dim oBOMStructure As BOMStructureEnum = oADoc.ComponentDefinition.BOMStructure
Dim oQuantityType As BOMQuantityTypeEnum
oBaseQuantity = oADoc.ComponentDefinition.BOMQuantity.GetEvaluatedBaseQuantity(oQuantityType)
Dim oBaseUnits As String = oADoc.ComponentDefinition.BOMQuantity.BaseUnits
Dim oUnitQuantity As String = oADoc.ComponentDefinition.BOMQuantity.UnitQuantity
Dim oStockNumber As String = oADoc.PropertySets.Item("Design Tracking Properties").Item("Stock Number").Value
Dim oDescription As String = oADoc.PropertySets.Item("Design Tracking Properties").Item("Description").Value
MsgBox("oPartNumber = " & oPartNumber & vbCrLf & _
"oBOMStructure = " & oBOMStructure.ToString & vbCrLf & _
"oBaseQuantity = " & oBaseQuantity & vbCrLf & _
"oQuantityType = " & oQuantityType.ToString & vbCrLf & _
"oBaseUnits = " & oBaseUnits & vbCrLf & _
"oUnitQuantity = " & oUnitQuantity & vbCrLf & _
"oStockNumber = " & oStockNumber & vbCrLf & _
"oDescription = " & oDescription, vbInformation, "BOM Related Data")
And I just thought I would include one more image to help clarify some of the details. This shows you where to access some of the BOM related information about a document manually, just in case you weren't already aware.
Tools tab > Options panel > Document Settings button > Bill of Materials tab (within that dialog).
Wesley Crihfield
(Not an Autodesk Employee)
Can't find what you're looking for? Ask the community or share your knowledge.