by Luke Davenport
Hello again,
A nice simple one here:
Question: How can I dynamically change my drop down list options in an iLogic form?
Solution: Use the standard iLogic code snippet 'MultiValue.SetList' to set the list in any multi-value parameter.
Explanation:
In my window frame assembly above, I have a simple iLogic form which allows me to pick the type of profile machining on the inside of the frame. These values are stored in a multivalue parameter called 'InsideProfile', and this profile can only ever be one of four types, which are cunningly codenamed 0.0001, 0.0002, 0.0003, 0.0004. The problem, however, is that when the length of my window frame is more than 2 metres, only profiles 0.0002 and 0.0004 are suitable (not 0.0001 or 0.0003)
So I need some simple iLogic code to limit the profile options based on the window length. Well happily - this code happens to be part of the standard supplied snippets under 'Parameters' – called 'SetList'. Double click on this and you'll get the following:
MultiValue.SetList("d0", 0.5, 0.75, 1.0, 1.25)
So using this, I can control my InsideProfile parameter list as follows:
If Length <= 2000 Then ' Make all profiles available
MultiValue.SetList("Inside_Profile", 0.0001, 0.0002, 0.0003, 0.0004)
Else ' Make two profiles available
MultiValue.SetList("Inside_Profile", 0.0002, 0.0004)
End If
Note this rule will run automatically by default every time the 'Length' parameter is changed, thanks to iLogic's built in 'Autorun' feature.
Pretty simple eh?
But what if I have profile 0.0003 active and I switch my length from 1500 mm to 2500 mm – won't the currently selected profile then be incorrect? To prevent this 'leftover' item in the list, add this additional line of standard code to the start of your iLogic rule:
' This option forces currently selected value to an available value in multivalue list
MultiValue.SetValueOptions(True, DefaultIndex := 0)
Enjoy!
Comments
0 comments
Please sign in to leave a comment.