Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
harvey_craig2RCUH
191 Views, 1 Reply

Calling an user parameter from strings

I have simplified this majorly for what I'm trying to do:

 

Inside Inventor I have a user parameter called myUserParameter

 

How can I set it by piecing together the parameter name on the left hand side of the equals sign if I'm bringing it together with strings?

 

Dim string1 As String = "my"
Dim string2 As String = "UserParameter"

string1 & string2 = 42

 

Hi @harvey_craig2RCUH.  If you are referring to how we can use the blue, unquoted names of parameters within 'internal' iLogic rules (rules that are saved within Inventor documents), then nothing like that will work, because they will be seen as a String type object by the code processor, not as a Parameter.  However, you may be able to do something like:

 

Dim string1 As String = "my"
Dim string2 As String = "UserParameter"
Parameter(string1 & string2) = 42

 

But doing it this way will not cause the automatic triggering of the rule whenever its value changes.

Edit:  There is also the Inventor API way of getting that UserParameter, then setting its value, based on those two Strings, but its ModelValue & Value Properties Get/Set the value in 'database units' instead of 'document units' or 'parameter units'.

Dim string1 As String = "my"
Dim string2 As String = "UserParameter"
ThisDoc.Document.ComponentDefinition.Parameters.UserParameters.Item(string1 & string2).Value = 42

Wesley Crihfield

EESignature

(Not an Autodesk Employee)