Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
3575 Views, 8 Replies

Change User Parameter Custom Property with VBA

Inventor 2017

All updates and hot fixes installed

 

When I create an assembly that has a frame (constructed with Frame Gen) in it i have to go in to each individual part file and change the G_L user parameter "Custom property format" from "Decimal" to "Fractional" and change the "Precision" to "1/16th". I would like to do this through VBA (or iLogic if possible).  The code i wrote shows the error in the attached pic when i try to run it.  Can anyone help??  I have attached a pic of my code as well because when i paste it on here its hard to read.

 

 

Public Sub ChangeParameterFormat()
' Get the active assembly document.
Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument

' Iterate through all of the documents referenced by the assembly.
Dim oDoc As Document

For Each oDoc In oAsmDoc.AllReferencedDocuments

' Check to see if this is a part.
If oDoc.DocumentType = kPartDocumentObject Then

Dim oPartDoc As PartDocument
Set oPartDoc = oDoc

Dim oUserParams As UserParameters
Set oUserParams = oPartDoc.ComponentDefinition.Parameters.UserParameters

Dim i As Integer

For i = 0 To oUserParams.Count

oUserParams.Item(i).CustomPropertyFormat.Precision = Inventor.CustomPropertyPrecisionEnum.kSixteenthsFractionalLengthPrecision

Next i

End If

Next

End Sub