Ilogic Multivariable Parameter Creation Rule

Ilogic Multivariable Parameter Creation Rule

Anonymous
Not applicable
1,346 Views
4 Replies
Message 1 of 5

Ilogic Multivariable Parameter Creation Rule

Anonymous
Not applicable

Have this snippet of code where parameter "COLOR" is created as user parameter if it does not exist in a part.  How can I make multivariable parameter that would appear as drop down menu with multiple COLOR options:  RED, GREEN, BLUE, etc?

Easy to create multivariable parameter list in the part but this code will add them to old parts created before the COLOR parameter was important.

 

 

doc = ThisDoc.Document

Dim oPartCompDef As PartComponentDefinition = doc.ComponentDefinition
Dim oParams As Parameters = oPartCompDef.Parameters
Dim oUserParams As UserParameters = oParams.UserParameters
Dim ParameterChecker As Parameter
Try
ParameterChecker = oParams("COLOR")
Catch
ParameterChecker = oUserParams.AddByValue("COLOR","RED","text")  ' how to make drop down list:  RED, GREEN, BLUE, ....
End Try

0 Likes
Accepted solutions (1)
1,347 Views
4 Replies
Replies (4)
Message 2 of 5

mcgyvr
Consultant
Consultant

Some stuff here..

http://inventortrenches.blogspot.com/2011/01/ilogic-code-to-set-part-number-per.html

https://knowledge.autodesk.com/support/inventor-products/learn-explore/caas/CloudHelp/cloudhelp/2014...

 

 

inputlistbox

 

google "autodesk Inventor ilogic list"



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
0 Likes
Message 3 of 5

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi DavidBapst,

 

Here's a quick example rule to look for a paramater list for color, and create it if it is not found, and then set the part color.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

iLogicVb.UpdateWhenDone = True

'check For Parameter and create If Not found
Try
	'get parameter value (just to see if it exists)
	oTest = Parameter("Color") 
Catch
	' Get the active document.  Assumes a part document is active.
    Dim partDoc As PartDocument
    partDoc = ThisApplication.ActiveDocument
    
    ' Get the UserParameters collection
    Dim userParams As UserParameters
    userParams = partDoc.ComponentDefinition.Parameters.UserParameters
	
	'create the parameter
	oParam = userParams.AddByValue("Color", "Red", UnitsTypeEnum.kTextUnits)
End Try

'Set the list
MultiValue.SetList("Color", "Red", "Default", "Gray")

'Get user input and set color
iProperties.PartColor = InputListBox("Choose a color.", _
MultiValue.List("Color"), MultiValue.List("Color").Item(0), "iLogic", "List of Colors:")

EESignature

Message 4 of 5

Anonymous
Not applicable

Multivariable parameter list creator works great thanks!  How can I make the variable "Key".  Also, the parameter gets added to end of parameter list - any way to auto sort the list by "KEY" parameters after creation?

0 Likes
Message 5 of 5

Curtis_Waguespack
Consultant
Consultant

 

Hi DavidBapst,

 

To set the parameter as a key you can add this line:

 

 

Parameter.Param("Color").IsKey​ = True

 

As for the other question, I assume you're talking about in the Form Editor? If so, I don't know of a way to sort or re-order, but you can filter for keys:

 

Autodesk Inventor iLogic Form Key Parameters.png

 

Or if you mean in the Parameters Editor you can click the header to sort, and use the filter button to filter for only Keys:

Autodesk Inventor iLogic Form Key Parameters2.png

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature