Inventor Customization

Inventor Customization

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

How can i make these custom property formats with VBA?

394 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 (378 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: 158
Registered: ‎12-01-2010
Message 3 of 7 (371 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 (360 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: 158
Registered: ‎12-01-2010
Message 5 of 7 (332 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 (312 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 (297 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
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!