09-17-2019
08:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-17-2019
08:18 AM
Do all custom iProperties require a string output?
I'm trying to set up a code where I can update an iProperty based on inputs. I modified the example code to update iProperties. The sub would be used with texts, bools, and numbers. I set the input as a variant but get errors if I pass anything other than a variant or string. What's the rules on iProps?
Public Sub CalliProp()
Dim docCurr As Document
Set docCurr = ThisApplication.ActiveDocument
Dim dblTest As Double
dblTest = 3.22222
Call UpdateCustomiProp(docCurr, "Woohah", dblTest)
End Sub
Public Sub UpdateCustomiProp(docDoc As Document, strPropTitle As String, varValue As Variant)
' Get the custom property set.
Dim psCustom As PropertySet
Set psCustom = docDoc.PropertySets.Item("Inventor User Defined Properties")
Dim propCurrent As Property
Set propCurrent = psCustom.Item(strPropTitle)
If Err.Number <> 0 Then
' Failed to get the property, which means it doesn't exist
' so we'll create it.
Call psCustom.Add(varValue, strPropTitle)
Else
' Got the property so update the value.
propCurrent.Value = varValue
End If
End Sub
09-17-2019
11:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-17-2019
11:19 AM
Custom iProps can be what ever type that is available when you go and add one manually.
You can use the object type instead of variant to make it generic.
Keep in mind the iproperty type will change depending on what type of value you assign ex: assigning "123" and 123 will change the iproperty type automatically between string and number.
Was my reply Helpful ? send a Kudos or accept as solution