• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Inventor Customization

    Reply
    Valued Contributor
    Vitornis
    Posts: 93
    Registered: ‎12-01-2010
    Accepted Solution

    How can i make these custom property formats with VBA?

    163 Views, 6 Replies
    01-19-2013 10:57 AM
    Please use plain text.
    Mentor
    Posts: 174
    Registered: ‎11-22-2009

    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
    
    

     

    Please use plain text.
    Valued Contributor
    Vitornis
    Posts: 93
    Registered: ‎12-01-2010

    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?

    Please use plain text.
    Mentor
    Posts: 174
    Registered: ‎11-22-2009

    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

     

    Please use plain text.
    Valued Contributor
    Vitornis
    Posts: 93
    Registered: ‎12-01-2010

    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?

    Please use plain text.
    Mentor
    Posts: 174
    Registered: ‎11-22-2009

    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

    Please use plain text.
    Valued Contributor
    Posts: 84
    Registered: ‎07-01-2012

    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 -

    -------------------------------------------------------------------------------------
    Please use plain text.