- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Folks,
Trying to create an external rule that adds a 'Mass' parameter that will be used in drawing parts list instead of unit QTY. The code seems to work so far achieving the following:
- Change document precision to 0 places
- Create the parameter (Mass) = to iprop mass
- Change the BoM base QTY to use new parameter (Mass)
Works so far, but I cant get the mass in the BoM to change precision to 0. It remains at 3 places as per original ipt template.
Something strange tho, after running the rule, if I click the precision drop down and re-select 0 (even when already set), and then do the same for the parameter in base quantity drop down to mass, it updates the precision correctly to 0 places. Not sure if I'm missing something in the ilogic to make this happen?
Dim oDoc = ThisDoc.Document
'-----Change document unit type, comment out as required.-----
oMassType = 11284 'Grams
'oMassType = 11283 'Kilograms
oDoc.UnitsOfMeasure.MassUnits = oMassType
oDoc.UnitsOfMeasure.LengthDisplayPrecision = 0
'-----Create the Mass Parameter if it does not exist.-----
Try
Parameter("Mass")=Ceil(iProperties.Mass)
Catch
oMyParameter=ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters
oParameter=oMyParameter.AddByExpression("Mass", "5", "g")
'oParameter=oMyParameter.AddByValue("Mass", "", UnitsTypeEnum.kGramMassUnits)
Parameter("Mass")=Ceil(iProperties.Mass)
End Try
'-----Change the BoM Quantity to use the Mass parameter.-----
oDoc.ComponentDefinition.BOMQuantity.SetBaseQuantity(BOMQuantityTypeEnum.kParameterBOMQuantity, Parameter.Param("Mass"))
oDoc.ComponentDefinition.BOMQuantity.BaseUnits = "g"
'-----Update the document.-----
iLogicVb.UpdateWhenDone = True
Appreciate any help!
Thanks,
Solved! Go to Solution.