Is there a way of adding a unit called "AR" as a unitless type?
I want this for B.O.M. QTY overrides to be able to carry an adjustable QTY defined and stored in the Part file.
I know I can accomplish this by overriding the B.O.M. on the drawings but I want to automate the drawings as much as possible. In order to Automate the process as much as possible I require that ALL B.O.M. data is to be stored in the Parts.
Help?
TomPy
Possible workflow:
1. You can create in your parts unitless user parameter with fixed name (e.g., name = “Qty”) to save desired adjustable quantity.
2. Then in the assembly document context you may access BOMView, find BOMRow for any component with known PartNumber and override its quantity using the current value of user parameter “Qty”.
This will produce correct assembly document BOM quantities calculated with data stored in your parts.
Sample VBA code (works for assembly document in Master Level of Detail):
Private Sub SetBOMQty() Dim oDoc As AssemblyDocument Set oDoc = ThisApplication.ActiveDocument Dim oDef As AssemblyComponentDefinition Set oDef = oDoc.ComponentDefinition 'target PartNumber Dim PartNumber As String PartNumber = "BOX" 'Set a reference to the "Model" BOMView Dim oBOMView As BOMView Set oBOMView = oDef.BOM.BOMViews.Item(1) Dim oBomRow As BOMRow 'find BOM row for the component with the desired PartNumber For Each oBomRow In oBOMView.BOMRows Dim oTempDef As ComponentDefinition Set oTempDef = oBomRow.ComponentDefinitions.Item(1) Dim oPartNumProperty As Property If Not TypeOf oTempDef Is VirtualComponentDefinition Then 'Get the file property that contains the "Part Number" 'The file property is obtained from the parent 'document of the associated ComponentDefinition. Set oPartNumProperty = oTempDef.Document.PropertySets _ .Item("Design Tracking Properties").Item("Part Number") If oPartNumProperty.Value = PartNumber Then 'read quantity from user parameter "Qty" Dim Qty As Integer Qty = oTempDef.Parameters.UserParameters.Item("Qty").Value 'override BomRow quantity oBomRow.TotalQuantity = Qty ' 'depending on your workflow you may want ' 'recursively iterate child rows if present. ' If Not oRow.ChildRows Is Nothing Then ' ... ' End If End If End If Next 'row End Sub 'SetBOMQty
Error checking is omitted.
The same can be done via iLogic rule in the assembly document:
ThisBOM.OverrideQuantity("Model Data", PartNumber, NewValue)
Note please that the sample above should be corrected if you have several component occurrences (copies) for some part files.
I appreciate the effort in your code but I think you missed my request.
'Dim Qty As Integer' is precisely what I am trying to get around. I want the BOM qty to read 'AR' to represent 'As Required'. I want to store this data in the part files so I can control it via the B.O.M. in the top level assembly.
If there MUST be an integer used then I would like to create a unittype of unitless but to show 'AR' instead of 'ul'.
ie. '1ar' as opposed to '1' or '1ul'. I can get a 'ul' unit to show in the BOM as it is now but requires a bit of a workflow to accomplish it without code. First the QTY parameter must be set to be "in" or any unitl aside of unitless. Once it is pushed into the BOM on the drawing I can modify the part parameter to be 'ul' and it will go through to the Drawing as '#ul' I want that 'ul' to be 'ar' instead.
Thanks for the help,
TomPy
You cannot extend UnitsTypeEnum. Sorry.