iLogic: Get & Set User Parameters

I saw a forum post in the Inventor Customisation forum and I thought I should share some iLogic code that I use for the getting and setting user parameters.

It’s pretty simple, but really effective. The code adds all user parameters to an Array, which it then presents to the user in the form of an “InputListBox”. When the user selects a parameter, the code presents an “InputBox” with the current value, this can be changed as desired, the interface looks like the images above.

Here is the code:

'iLogic code by Clint Brown @ClintBrown3D
'Code originally posted at https://clintbrown.co.uk/ilogic-get--set-user-parameters

Dim oCSB As New ArrayList 'Create an Array
Dim UserParam As UserParameters 'Get the Parameters
UserParam = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters
For Each Item In UserParam 'Write Paramters to Array
oCSB.Add(Item.Name) '2nd Option - Just the Parameter names, no values
Next

XX = InputListBox("User Paramters", oCSB, oCSB, Title := "Unofficial Inventor", ListName := "Select a User Parameter From the List")
If XX = "" Then : Return : End If ' Error handling for null selection 
Parameter(XX) = InputBox("Set Value for " & XX, "Unofficial Inventor - " & XX, Parameter(XX))

Notes:

This version of the code was briefly tested in Inventor 2021.

As always, please test all iLogic code extensively on non-production files. Do not use any code in a production environment until YOU have thoroughly tested it and have verified that it works as expected. Always back up any data before running any experimental code. You are ultimately responsible for any iLogic code that you run, so make sure you test it thoroughly!