Part QTY from BOM

Part QTY from BOM

william
Advocate Advocate
615 Views
2 Replies
Message 1 of 3

Part QTY from BOM

william
Advocate
Advocate

Hello 

I am looking to get the Qty from the bom for a component or a virtual component. Capture.JPG

Just about all posts I have read on this loop through all bom rows to get the quantity, but I only want to get the qty for a specific part. 

The API diagram shows BOMQuantity as accessible from the VirtualComponentDefinition without having to go through the BOM object. API Diagram.JPG

Is there a simple oneline I can use for this? 

 

Starting code,

Dim oAsmCompDef As AssemblyComponentDefinition = ThisApplication.ActiveDocument.ComponentDefinition
Dim oOcc As ComponentOccurrence
Dim oOccs = oAsmCompDef.Occurrences

For Each oOcc In oAsmCompDef.Occurrences
	If TypeOf oOcc.Definition Is VirtualComponentDefinition Then
		If oOcc.Name.Contains("REF_RAIL") Then
			strQTY = oOcc.BOMQuantity() 
			MessageBox.Show("QTY = " & strQTY, "Title")
		End If
	End If
Next

 

0 Likes
Accepted solutions (1)
616 Views
2 Replies
Replies (2)
Message 2 of 3

theo.bot
Collaborator
Collaborator
Accepted solution

With the BOMQuantity object you can set the QTY option for that component like you can do using the document settings.

theobot_0-1635747873472.png

if you want a one line code you need to now the rownumber of your component. 

 

oDoc.ComponentDefinition.BOM.BOMViews.Item("Structured").BOMRows.Item(1).TotalQuantity

like the other post are telling you, a small loop will work to find the row and get your totalquantity.
0 Likes
Message 3 of 3

william
Advocate
Advocate

Ok, thanks. 

0 Likes