Custom Poperty Format Precision

Custom Poperty Format Precision

Anonymous
Not applicable
497 Views
2 Replies
Message 1 of 3

Custom Poperty Format Precision

Anonymous
Not applicable

How do I setup the precision of a Custom Property ?

 

I tried several codes from the forum, but non of them works and on Inventor Helps I didn't find anything.

 

Thank you in advance !

 

image.png

 

 

 

 

 

0 Likes
498 Views
2 Replies
Replies (2)
Message 2 of 3

pball
Mentor
Mentor

Here is some VBA code that can change the precision of parameters

    Dim oPartDoc As PartDocument
    Set oPartDoc = ThisApplication.ActiveEditDocument
    
    Dim oParameter As Parameter
    For Each oParameter In oPartDoc.ComponentDefinition.Parameters
'Set as exported oParameter.ExposedAsProperty = True
'Set type oParameter.CustomPropertyFormat.PropertyType = kTextPropertyType
'Set units oParameter.CustomPropertyFormat.Units = UnitsTypeEnum.kInchLengthUnits
'Set precision and decimal/fraction oParameter.CustomPropertyFormat.Precision = kThreeDecimalPlacesPrecision
'Show units string oParameter.CustomPropertyFormat.ShowUnitsString = True Next oParameter
Values for precision

kZeroFractionalLengthPrecision
kHalfFractionalLengthPrecision
kQuarterFractionalLengthPrecision
kEighthsFractionalLengthPrecision
kSixteenthsFractionalLengthPrecision
kThirtySecondsFractionalLengthPrecision
kSixtyFourthsFractionalLengthPrecision
kOneTwentyEighthsFractionalLengthPrecision

kZeroDecimalPlacePrecision
kOneDecimalPlacePrecision
kTwoDecimalPlacesPrecision
kThreeDecimalPlacesPrecision
kFourDecimalPlacesPrecision
kFiveDecimalPlacesPrecision
kSixDecimalPlacesPrecision
kSevenDecimalPlacesPrecision
kEightDecimalPlacesPrecision
Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
0 Likes
Message 3 of 3

GeorgK
Advisor
Advisor
Private Sub Test()

Dim oInvApp As Application
Set oInvApp = ThisApplication

Dim oUserParameter As UserParameter
Set oUserParameter = oInvApp.ActiveDocument.ComponentDefinition.Parameters.UserParameters.Item(1)

oUserParameter.ExposedAsProperty = True
oUserParameter.CustomPropertyFormat.PropertyType = CustomPropertyTypeEnum.kTextPropertyType
oUserParameter.CustomPropertyFormat.Precision = CustomPropertyPrecisionEnum.kTwoDecimalPlacesPrecision
oUserParameter.CustomPropertyFormat.Units = UnitsTypeEnum.kMillimeterLengthUnits
oUserParameter.CustomPropertyFormat.ShowUnitsString = False

End Sub
0 Likes