Hi qroos,
Code work fine and set the precision work fine.
It's CustomPropertyFormat look at the CustomProperty
For the Thickness you don't need to create a UserParameter once you ExposedAsProperty
is create automatic a CustomProperty Thickness
For the doc you can use the Unit of Measure
something like
Dim oUOM As UnitsOfMeasure = InvDocument.UnitsOfMeasure
' Set the units and precision.
oUOM.LengthDisplayPrecision = 4
Imports Inventor.UnitsTypeEnum
Dim oParams As Parameters
oParams=ThisDoc.Document.ComponentDefinition.Parameters
Dim oUserParams As UserParameters
oUserParams=oParams.UserParameters
'look for user parameter and try to set it
Try
oUserParams("lengthExtents").Value = Round(SheetMetal.FlatExtentsLength /10)
oUserParams("widthExtents").Value = Round(SheetMetal.FlatExtentsWidth /10)
Catch
' assume error means not found and create it
oUserParams.AddByValue("lengthExtents", Round(SheetMetal.FlatExtentsLength /10), kmillimeterLengthUnits)
oUserParams.AddByValue("widthExtents", Round(SheetMetal.FlatExtentsWidth /10), kmillimeterLengthUnits)
'oUserParams.AddByValue("Thickness", Round(Thickness/10), kmillimeterLengthUnits)
End Try
'ensure the parameters are exported/exposed as custom iProperties
Parameter.Param("lengthExtents").ExposedAsProperty = True
Parameter.Param("widthExtents").ExposedAsProperty = True
Parameter.Param("Thickness").ExposedAsProperty = True
'set the description to read in the iProperties
iProperties.Value("Project", "Stock Number") = "=<Thickness>PL x <widthExtents> x <lengthExtents>"
Parameter.Param("lengthExtents").CustomPropertyFormat.ShowLeadingZeros = False
Parameter.Param("lengthExtents").CustomPropertyFormat.ShowTrailingZeros = False
Parameter.Param("lengthExtents").CustomPropertyFormat.ShowUnitsString = False
Parameter.Param("widthExtents").CustomPropertyFormat.ShowLeadingZeros = False
Parameter.Param("widthExtents").CustomPropertyFormat.ShowTrailingZeros = False
Parameter.Param("widthExtents").CustomPropertyFormat.ShowUnitsString = False
With Parameter.Param("Thickness")
.CustomPropertyFormat.ShowLeadingZeros = False
.CustomPropertyFormat.ShowTrailingZeros = False
.CustomPropertyFormat.ShowUnitsString = False
.CustomPropertyFormat.Precision = CustomPropertyPrecisionEnum.kFourDecimalPlacesPrecision
End With
'update the file
iLogicVb.UpdateWhenDone = True