Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Ilogic set parameters based on initial multivalue parameter instance

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
JCollins
2084 Views, 5 Replies

Ilogic set parameters based on initial multivalue parameter instance

Hi All,

 

I have a lifting lug which is sized according to the weight it is able to lift. The lugs size parameters are controlled by one multivalue parameter "Tank_Lifting_Lug_WWL_Tonnes". I am currently selecting these size parameters by using Case Select, but wanted to know if there is a more efficient way it could be done? Possible by getChoice = Choose(index, "first", "second", "third")? Below  is a list of the values for each instance of the lug. If for example you were to choose:  "Tank_Lifting_Lug_WWL_Tonnes" 3 then

"Tank_Lifting_Lug_Hole_DIA" would  =  36

"Tank_Lifting_Lug_Hole_to_Base"  would = 44 etc

List of Values:

MultiValue.List("Tank_Lifting_Lug_WWL_Tonnes", 2, 3, 4, 5, 6, 8, 10)

 ("Tank_Lifting_Lug_Hole_DIA", 28, 36, 39, 42, 46, 57, 60)

 ("Tank_Lifting_Lug_Hole_to_Base", 36, 44, 50, 54, 62, 67, 76)

 ("Tank_Lifting_Lug_Edge_Flat_Length", 14, 17, 22, 22, 24, 28, 31)

 ("Tank_Lifting_Lug_Base_Width", 100, 127, 141, 151, 184, 203, 215)

 ("Tank_Lifting_Lug_Plate_THK", 16, 20, 25, 25, 28, 32, 36)

 ("Tank_Lifting_Lug_Outside_RAD", 42, 54, 59, 63, 69, 86, 90)

 

Thanks

5 REPLIES 5
Message 2 of 6
Vladimir.Ananyev
in reply to: JCollins

I personally prefer Array.IndexOf method:

 

'our data lists
Dim Tank_Lifting_Lug_WWL_Tonnes() As Integer = { 2, 3, 4, 5, 6, 8, 10}
Dim Tank_Lifting_Lug_Hole_DIA() As Integer = { 28, 36, 39, 42, 46, 57, 60}
Dim Tank_Lifting_Lug_Hole_to_Base() As Integer = { 36, 44, 50, 54, 62, 67, 76}
Dim Tank_Lifting_Lug_Edge_Flat_Length() As Integer = { 14, 17, 22, 22, 24, 28, 31}
Dim Tank_Lifting_Lug_Base_Width() As Integer = { 100, 127, 141, 151, 184, 203, 215}
Dim Tank_Lifting_Lug_Plate_THK() As Integer = { 16, 20, 25, 25, 28, 32, 36}
Dim Tank_Lifting_Lug_Outside_RAD() As Integer = { 42, 54, 59, 63, 69, 86, 90}
 
'find values for the given input weight
Dim weight As Integer = 5
'index in array.  Start from 0.  Returns -1 if value is not found.
Dim n As Integer = Array.IndexOf(Tank_Lifting_Lug_WWL_Tonnes, weight)
 
MsgBox( "WWL_Tonnes       = " & weight & vbNewLine & _
         "Hole_DIA         = " & Tank_Lifting_Lug_Hole_DIA(n) & vbNewLine & _
         "Hole_to_Base     = " & Tank_Lifting_Lug_Hole_to_Base(n) & vbNewLine & _
         "Edge_Flat_Length = " & Tank_Lifting_Lug_Edge_Flat_Length(n) & vbNewLine & _
         "Base_Width       = " & Tank_Lifting_Lug_Base_Width(n) & vbNewLine & _
         "Plate_THK        = " & Tank_Lifting_Lug_Plate_THK(n) & vbNewLine & _
         "Outside_RAD      = " & Tank_Lifting_Lug_Outside_RAD(n) )

 See MSDN for additional information on Array class methods.

Hope this helps.

Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 3 of 6
JCollins
in reply to: Vladimir.Ananyev

Hi Vladimir,

Thanks for your reply. The rule returns the correct value for all the parameters listed, via the value specified in the following line: Dim weight As Integer = 5, as a MsgBox on the screen. Is there a way of:

1. Setting the value of the Integer via the multi value parameter Tank_Lifting_Lug_WLL_Tonnes directly, instead of manually typing it in?

2. Forcing all the parameters to change to that integer? As they seem to stay at their current value, even though the MsgBox appears with the correct values.

 

Thanks or your help,

 

James

Message 4 of 6
Vladimir.Ananyev
in reply to: JCollins

>>> Setting the value of the Integer via the multi value parameter <<<

Answer: Yes, of course, this is much more friendly way.

 

>>> Forcing all the parameters to change to that integer?<<<

Answer: If input mass is not changed then nothing should be recalculated.  Scenario is entirely defined by you.

 cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 5 of 6
adam.nagy
in reply to: JCollins

Hi James,

 

So if I understand correctly, you have a main parameter (Tank_Lifting_Lug_WWL_Tonnes) and you just want to make sure that whenever that is changed, the other values update automatically, right?

 

So I created a part with all those multivalue parameters. Then created a rule that fills those with values:

MultiValue.SetList("Tank_Lifting_Lug_WWL_Tonnes", 2, 3, 4, 5, 6, 8, 10)
MultiValue.SetList("Tank_Lifting_Lug_Hole_DIA", 28, 36, 39, 42, 46, 57, 60)
MultiValue.SetList ("Tank_Lifting_Lug_Hole_to_Base", 36, 44, 50, 54, 62, 67, 76)
MultiValue.SetList("Tank_Lifting_Lug_Edge_Flat_Length", 14, 17, 22, 22, 24, 28, 31)
MultiValue.SetList ("Tank_Lifting_Lug_Base_Width", 100, 127, 141, 151, 184, 203, 215)
MultiValue.SetList ("Tank_Lifting_Lug_Plate_THK", 16, 20, 25, 25, 28, 32, 36)
MultiValue.SetList("Tank_Lifting_Lug_Outside_RAD", 42, 54, 59, 63, 69, 86, 90)

Then I have another rule named "Tank_Lifting_Lug_WWL_Tonnes" that will update the other parameters whenever any parameter changes:

' This returns an array of strings
Dim weights As ArrayList = MultiValue.List("Tank_Lifting_Lug_WWL_Tonnes")

' Get back current value as a string
Dim weight As String = Tank_Lifting_Lug_WWL_Tonnes

' Find its index in the list
Dim n As Integer = weights.IndexOf(weight)

' Set the given index for all parameters
Tank_Lifting_Lug_Hole_DIA = MultiValue.List("Tank_Lifting_Lug_Hole_DIA")(n)
Tank_Lifting_Lug_Hole_to_Base = MultiValue.List("Tank_Lifting_Lug_Hole_to_Base")(n)
Tank_Lifting_Lug_Edge_Flat_Length = MultiValue.List("Tank_Lifting_Lug_Edge_Flat_Length")(n)
Tank_Lifting_Lug_Base_Width = MultiValue.List("Tank_Lifting_Lug_Base_Width")(n)
Tank_Lifting_Lug_Plate_THK = MultiValue.List("Tank_Lifting_Lug_Plate_THK")(n)
Tank_Lifting_Lug_Outside_RAD = MultiValue.List("Tank_Lifting_Lug_Outside_RAD")(n)

This seems to do what I think you want.

 

Cheers, 



Adam Nagy
Autodesk Platform Services
Message 6 of 6
MaheshwarMD
in reply to: adam.nagy

Hello,

 

I would like to know how to use and its application of  getChoice = Choose(index, "first", "second", "third") in inventor ilogic.

please share any example file if you have any.

Mahesh

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report