20 | 09 | 2017

Inventor Add/Update Custom Property

The routine below adds or updates a custom property from an Inventor Document. 

    Public Sub UpdateCustomiProperty(ByRef Doc As Inventor.Document, ByRef PropertyName As String, ByRef PropertyValue As Object)
        ' Get the custom property set.
        Dim customPropSet As Inventor.PropertySet
        customPropSet = Doc.PropertySets.Item("Inventor User Defined Properties")

        ' Get the existing property, if it exists.
        Dim prop As Inventor.Property
        On Error Resume Next
        prop = customPropSet.Item(PropertyName)

        ' Check to see if the above call failed.  If it failed
        ' then the property doesn't exist.
        If Err.Number <> 0 Then
            ' Failed to get the existing property so create a new one.
            prop = customPropSet.Add(PropertyValue, PropertyName)
            ' Change the value of the existing property.
            prop.Value = PropertyValue
        End If
    End Sub

Sign up now and upload your code to the website.

Help us to continue.....
Articles View Hits
Latest Articles