Edit Part BOM Base Quantity
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
There is an interesting thread on the general Inventor forum about setting a part to a partial quantity. So instead of having a part be qty 1 it could be qty .1, which would allow items that come in packs to display pack quantities on drawings. There is actually a work around to enable this, but it's pretty clunky and I'd like to automate it. I tried copying the work around in VBA but I'm stuck at the last step which seems to require manually opening the parameters dialog from the BOM tab in the Document Settings.
Here is part 1 and part 2 of Johnson's work around, unfortunately the last step in his second post is the point I'm stuck at.
The code can properly set the Base quantity but the unit quantity won't update. I tried toggling the export option on the user parameter but that didn't seem effect it. Opening the parameter dialog from this Documents dialog and simply closing it forces the Unit Quantity to update. Do note opening the parameter dialog normally does not cause the Unit Quantity to update, some how opening it from the Document Settings dialog is what appears to trigger the update. So unless that can be emulated via the API somehow this might not be possible.
Public Sub bomqty()
Dim oPart As PartDocument
Set oPart = ThisApplication.ActiveEditDocument
Dim oCompDef As PartComponentDefinition
Set oCompDef = oPart.ComponentDefinition
Dim Qty As Double
temp = InputBox("Enter the Qty", "Quantity", "1")
If Not IsNumeric(temp) Then
MsgBox ("Please enter a number")
Exit Sub
Else
Qty = temp
End If
On Error Resume Next
If Qty = 1 Then
Call oCompDef.BOMQuantity.SetBaseQuantity(kEachBOMQuantity)
oCompDef.Parameters.UserParameters.Item("qty").Delete
Else
Dim oUserParam As UserParameter
Set oUserParam = oCompDef.Parameters.UserParameters.Item("qty")
'update qty param if exist
oUserParam.Value = Qty * 2.54
oUserParam.Units = "in"
'create qty param if not exists
If (Err.Number <> 0) Then Set oUserParam = oCompDef.Parameters.UserParameters.AddByValue("qty", Qty * 2.54, "in")
'set qty param as base quantity
Call oCompDef.BOMQuantity.SetBaseQuantity(kParameterBOMQuantity, oUserParam)
'change qty param units and update value
oUserParam.Units = "ul"
oUserParam.Value = Qty
oUserParam.ExposedAsProperty = True
oPart.Update
End If
End SubAlso there is at least one Idea post to officially add partial qty for parts. Please vote if you like the idea. Part unit quantity ability to enter fractional or decimal for the quantity