iLogic Multi-Value

iLogic Multi-Value

Cosmin_V
Advocate Advocate
2,119 Views
8 Replies
Message 1 of 9

iLogic Multi-Value

Cosmin_V
Advocate
Advocate

Hi

Can somebody help me whit this rule?

I have a multi value User Parameter, named "Number_Of_Holes" which is a Circular Pattern.

And one User Parameter, named "Hole_Angle". 

I need the User Parameter "Hole_Angle" to be = whit a multi value of all numbers from 0 to "Number_Of_Holes"/360.

 

Many Thanks!

0 Likes
Accepted solutions (1)
2,120 Views
8 Replies
Replies (8)
Message 2 of 9

johnsonshiue
Community Manager
Community Manager

Hi! Let me confirm with you what you are looking for. "Number_Of_Holes" is a unitless parameter has a list of predefined integer values from 0 to 5 for example. You want an angular user parameter, "Hole_Angle" equals to 360 divided by "Number_Of_Holes."

Shouldn't "Hole_Angle" = 360/Number_Of_Holes?

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 3 of 9

Cosmin_V
Advocate
Advocate

Hi,

                          

Yes, but, if for example "Number Of Holes" = 20

then if  "Hole_Angle" = 360/Number_Of_Holes(20)

"Hole_Angle" = 18

But I will like the multi-value "Hole_Angle" = All numbers from (0 to 18)

"Hole_Angle",  "1",  "2", "3", "4"...…."16", "17", "18")

 

Or if for example "Number Of Holes" = 25

then if "Hole_Angle" = 360/Number_Of_Holes(25)

"Hole_Angle"= 14,4

But I will like the multi-value "Hole_Angle" = All numbers from (0 to 14 or 15)

Like This....MultiValue.SetList ("Hole_Angle", "1", "2", "3"....."13", "14")

I hope is understandable

 

Many Thanks!

 

 

0 Likes
Message 4 of 9

philip1009
Advisor
Advisor

Could you provide a sample of what you're trying to achieve?  It seems to me that what you want is when the user puts in a number of holes, you want a list of all possible angles divided by the numbers between 1 and the number of holes the user entered.

 

If user puts in 18 then you want a multi-value list with these angle values, 360 divided by 1 thru 18:

360

180

120

90

72

60

51.42857142857143

45

40

36

32.72727272727273

30

27.69230769230769

25.71428571428571

24

22.5

21.17647058823529

20

Message 5 of 9

johnsonshiue
Community Manager
Community Manager

Hi! I think it is doable. Essentially, you want a dynamic list depending on another parameter or an equation. In iLogic, you can use SetList command to set the list of numbers. I guess you want to build the list by using a Loop, starting from 0 and ending with the last angular value.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 6 of 9

Cosmin_V
Advocate
Advocate

Exactly, but how can that be done?

 

I started to set manual the multi-value of "Hole_Angle"  every time the "Number_Of_Holes" is different but that will be a very long code.

0 Likes
Message 7 of 9

philip1009
Advisor
Advisor
Accepted solution

It's a lot easier than you think.  I named the Unitless Parameter HoleQty, and my angle list HoleAngle, it's recommended to use camel case to name your parameters and variables instead of using _ all the time.

 

Here's the rule:

'Reset user input if less than 1 to eliminate errors
If HoleQty < 1 Then HoleQty = 1

'Recreate a new ArrayList
Dim lisAngle As New ArrayList

'Start a loop going from 1 to user input
For i = 1 To HoleQty

	'Add the current value dividing 360 to the list
	lisAngle.Add(360 / i)

	'Loop to next possible entry
Next

'Set the multi-value list from the ArrayList
MultiValue.List("HoleAngle") = lisAngle

 

Here's the rule if you don't want notes:

 

If HoleQty < 1 Then HoleQty = 1
Dim lisAngle As New ArrayList
For i = 1 To HoleQty
	lisAngle.Add(360 / i)
Next
MultiValue.List("HoleAngle") = lisAngle

 

After creating the rule, go to  Manage>iLogic>Event Triggers on your ribbon and drag your rule under Any Model Parameter Change:

 

Event Trigger_edited.jpg

Message 8 of 9

Cosmin_V
Advocate
Advocate

hi

Thank You, philip1009     

But is not Working….

 have a problem whit this Line

For i = 1 To HoleQty

Did I mention the "HoleQty" is also a Multi-value...I think that is the problem..

 

error.jpg

0 Likes
Message 9 of 9

philip1009
Advisor
Advisor

Mutli-Value list isn't the problem.  It looks like your code is longer than what I wrote.  Are you using "i" for something else before it's used in the HoleQty loop?

 

Maybe try this code re-defining "i" before using it:

 

If HoleQty < 1 Then HoleQty = 1
Dim lisAngle As New ArrayList
Dim i As Integer = Nothing
For i = 1 To HoleQty
	lisAngle.Add(360 / i)
Next
MultiValue.List("HoleAngle") = lisAngle