How can i make these custom property formats with VBA?

How can i make these custom property formats with VBA?

Vitornis
Advocate Advocate
1,015 Views
6 Replies
Message 1 of 7

How can i make these custom property formats with VBA?

Vitornis
Advocate
Advocate

ScreenClip.png

0 Likes
Accepted solutions (1)
1,016 Views
6 Replies
Replies (6)
Message 2 of 7

Ralf_Krieg
Advisor
Advisor

Hello

 

You can set these formats like this:

 

Dim oUserParameter As UserParameter
oUserParameter = oInvApp.ActiceDocument.Parameters.UserParameters.Item(1)
           
oUserParameter.ExposedAsProperty = True
oUserParameter.CustomPropertyFormat.Precision =  CustomPropertyPrecisionEnum.kDegreesAnglePrecision 
oUserParameter.CustomPropertyFormat.PropertyType = CustomPropertyTypeEnum.kTextPropertyType
oUserParameter.CustomPropertyFormat.ShowTrailingZeros = True
oUserParameter.CustomPropertyFormat.ShowUnitsString = False

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 3 of 7

Vitornis
Advocate
Advocate

How do you change the format to fractional?

0 Likes
Message 4 of 7

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

Define the correct type of precision-property

 

Private Sub fxex()

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.kSixteenthsFractionalLengthPrecision
oUserParameter.CustomPropertyFormat.Units = UnitsTypeEnum.kInchLengthUnits
oUserParameter.CustomPropertyFormat.ShowUnitsString = False

End Sub

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
Message 5 of 7

Vitornis
Advocate
Advocate

oooo Thanks!

 

Now i see what i was missing!

 

What is a good resource for writing these VBA macros?

0 Likes
Message 6 of 7

Ralf_Krieg
Advisor
Advisor

Hello

 

Happy it works. Smiley Happy

 

The best three sources are:

- Autodesk Inventor programmers help (included in pulldown menu in every inventor installation)

- Internet

- watch window in VBA-Editor to step through the object model tree


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 7 of 7

Anonymous
Not applicable

 

Exactly kreig,

 

I prefer first and third options.... VBA Help is fantastic and watch window will tell all of the info in referenced Doc.

 

Cheers

0 Likes