@arkelec wrote:
Those are Custom Properties, are they not? I am adding Custom Parameters:

You are adding a user parameter, then you are exporting it as a custom property (.ExposedAsProperty = True)
Parameter.CustomPropertyFormat is called CustomPropertyFormat because its the format of the property that is exportet from the parameter. Thats why I asked to make sure you knew. The formatting this code is doing has no effect on what you see in the parameters window.
Try this code and have a look at your custom Properties. You'll se it formats the property that is created when the parameter is exported.
Dim oDoc As PartDocument = ThisDoc.Document
Dim oParam As Inventor.Parameter
Try
oParam = oDoc.ComponentDefinition.Parameters.UserParameters.Item("xLength")
oParam.Expression = "1.12345678 mm" '8 decimals
Catch
oParam = oDoc.ComponentDefinition.Parameters.UserParameters.AddByExpression("xLength", "1.12345678 mm", "mm")
End Try
oParam.ExposedAsProperty = True
Dim oFormat As CustomPropertyFormat = oParam.CustomPropertyFormat 'This is the format of the property, not the parameter
oFormat.PropertyType = CustomPropertyTypeEnum.kNumberPropertyType
'-----------------Try switching between these and see the difference--------------------------
oFormat.Precision = CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision
'oFormat.Precision = CustomPropertyPrecisionEnum.kEightDecimalPlacesPrecision
'---------------------------------------------------------------------------------------------
iLogicVB.UpdateWhenDone = True
If you just want to change what's in the parameters window though, you can set the expression of the parameter with a string.
See the difference between these two:
Dim oDoc As PartDocument = ThisDoc.Document
Dim oParam As Inventor.Parameter
Try
oParam = oDoc.ComponentDefinition.Parameters.UserParameters.Item("xLength")
oParam.Expression = "0 mm" '0 decimals
Catch
oParam = oDoc.ComponentDefinition.Parameters.UserParameters.AddByExpression("xLength", "0 mm", "mm")
End Try
And
Dim oDoc As PartDocument = ThisDoc.Document
Dim oParam As Inventor.Parameter
Try
oParam = oDoc.ComponentDefinition.Parameters.UserParameters.Item("xLength")
oParam.Expression = "0.000000 mm" '8 decimals
Catch
oParam = oDoc.ComponentDefinition.Parameters.UserParameters.AddByExpression("xLength", "0.000000 mm", "mm")
End Try
If Ive misinterpreted what you want to accomplish, could you do manually what you want the code to do and take a screenshot of the result so I'll understand once and for all? 😆