Inventor Customization

Inventor Customization

Reply
Distinguished Contributor
Vitornis
Posts: 152
Registered: ‎12-01-2010
Message 1 of 7 (386 Views)
Accepted Solution

How can i make these custom property formats with VBA?

386 Views, 6 Replies
01-19-2013 10:57 AM

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

 

Mentor
krieg
Posts: 176
Registered: ‎11-22-2009
Message 2 of 7 (370 Views)

Re: How can i make these custom property formats with VBA?

01-20-2013 03:52 AM in reply to: Vitornis

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

 

Distinguished Contributor
Vitornis
Posts: 152
Registered: ‎12-01-2010
Message 3 of 7 (363 Views)

Re: How can i make these custom property formats with VBA?

01-20-2013 05:36 PM in reply to: krieg

How do you change the format to fractional?

Mentor
krieg
Posts: 176
Registered: ‎11-22-2009
Message 4 of 7 (352 Views)

Re: How can i make these custom property formats with VBA?

01-20-2013 10:32 PM in reply to: Vitornis

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

 

Distinguished Contributor
Vitornis
Posts: 152
Registered: ‎12-01-2010
Message 5 of 7 (324 Views)

Re: How can i make these custom property formats with VBA?

01-23-2013 06:16 PM in reply to: krieg

oooo Thanks!

 

Now i see what i was missing!

 

What is a good resource for writing these VBA macros?

Mentor
krieg
Posts: 176
Registered: ‎11-22-2009
Message 6 of 7 (304 Views)

Re: How can i make these custom property formats with VBA?

01-24-2013 10:28 PM in reply to: Vitornis

Hello

 

Happy it works. :smileyhappy:

 

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

Distinguished Contributor
ADNpati
Posts: 126
Registered: ‎07-01-2012
Message 7 of 7 (289 Views)

Re: How can i make these custom property formats with VBA?

01-29-2013 03:43 PM in reply to: krieg

 

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

Mechanical Engineer
Inventor Applications Engineer

--------------------------------------------------------------------------------------

If my solution seems to remedy your problem, please press the Accept Solution button, Some KUDOS -

-------------------------------------------------------------------------------------
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.