Multi-value lists selection with form does not store as parameter

Multi-value lists selection with form does not store as parameter

ben.vandermeer
Explorer Explorer
1,915 Views
4 Replies
Message 1 of 5

Multi-value lists selection with form does not store as parameter

ben.vandermeer
Explorer
Explorer

I am having problems with ilogic and multivalue lists. I need to use inventor to create a couple of parameters for our BOM list and our PDM system. For that i wanted to use a multivalue list, in combination with a form, to select the values wanted, and use the selection as parameters for the rest of the script.

 

I am not a programmer, and usually figure stuff out using google search, and copy paste, combined with a dose of logic and some basic scripting experience. However i have hit an ilogic wall.

 

I have managed to create multivalue lists using a centrally stored Excell file as input, using Multivalue.list . These generate just fine, and i can select a value in the user parameter screen, as well as a simple form I created by dragging the parameter on it. However, if i select a value, the result remains an empty parameter. I have tried several methods, including a popup screen to force an input from the multivalue list, however nothing works.

 

For one multivalue lists i need the drop down menu selection to fill in 3 other parameters, also from the same Excel file, which will be used in my script (later on, that part works perfectly) and is used as input for the BOM list.

 

The code itself is rather long and does a lot of different things. I will copy the part of the most 'complex' multivalue list that gives me trouble. Can anyone who can actually code please help me, and tell me what i do wrong?

 

I have also attached the source excel file.

 

Excuse the Dutch 🙂

 

Kind regards

 

Ben

 

Try
test = oUserParams("MateriaalKeuze")
Catch
'Aanmaken in geval van error
oUserParams.AddByValue("MateriaalKeuze", "", kTextUnits )
End Try
Try
test = iProperties.Value("Custom", "EN-MaterialGroup")
Catch
'Aanmaken in geval van error
iProperties.Value("Custom", "EN-MaterialGroup")=""
End Try
Try
test = iProperties.Value("Custom", "PBasisMat")
Catch
'Aanmaken in geval van error
iProperties.Value("Custom", "PBasisMat")=""
End Try
Try
test = iProperties.Value("Custom", "EN-Code")
Catch
'Aanmaken in geval van error
iProperties.Value("Custom", "EN-Code")=""
End Try

MultiValue.List("MateriaalKeuze") = GoExcel.CellValues("P:\mechanical drawings\Inventor Standard\Profile Excel Data\Weldment materials.xlsx", _ 
	"Weldment", "A2", "")

Try
test = oUserParams("oMatKeuze")
Catch
oUserParams.AddByValue("oMatKeuze", "", kTextUnits )
End Try

'oMatKeuze = InputListBox ("Select one:", MultiValue.List("MateriaalKeuze"), Parameter("MateriaalKeuze"), "iLogic", "List of Component Occurrences:")
'Parameter("MateriaalKeuze") = oMatKeuze

'MatiaalKeuze mag niet leeg zijn, anders geeft hij een error.
If MateriaalKeuze = "" Then
oMatKeuze = "-"
Else 
oMatKeuze = MateriaalKeuze
End If

'Zoek de waarde van MateriaalKeuze op, en vind daar met de andere kolommen de andere waardes bij.
i=GoExcel.FindRow("P:\mechanical drawings\Inventor Standard\Profile Excel Data\Weldment materials.xlsx", "Weldment", "Name", "=", oMatKeuze)
iProperties.Value("Custom", "EN-MaterialGroup") = GoExcel.CurrentRowValue ( "EN-Materialgroup") 
iProperties.Value("Custom", "EN-Code") = GoExcel.CurrentRowValue ( "EN-Code") 
iProperties.Value("Custom", "PBasisMat") = GoExcel.CurrentRowValue ( "PBasisMat") 

 

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

ben.vandermeer
Explorer
Explorer

Can nobody help me with this problem? What am i doing wrong?

0 Likes
Message 3 of 5

MjDeck
Autodesk
Autodesk
Accepted solution

Hi Ben,

MultiValue.List will only set the list of values on the parameter. To also change the parameter value itself, add this line before the call to MultiValue.List:

MultiValue.SetValueOptions(True)

Another problem is the difference between:
A) using MateriaalKeuze as a variable directly in the rule
B) using Parameter("MateriaalKeuze")

If you use a parameter directly as a variable, it won't work unless the parameter already exists in the document at the time the rule is edited and run. But you're creating that parameter dynamically in this rule. iLogic needs to be able to find the parameter (in the document) *before* running the rule in order to use it as a variable.
The Parameter() function is more flexible. It can find a parameter that was created earlier in the rule.
Also, the value assignment made by MultiValue.List will *not* automatically change MateriaalKeuze used as a variable. That's a limitation.
So I was going to recommend changing all instances of MateriaalKeuze to Parameter("MateriaalKeuze"). However, that would mean that the rule won't run automatically when you select a different value from the list. To work around that, you can add a button to your form to run the rule.
If possible, I would recommend not creating MateriaalKeuze dynamically. If it always exists in the part, then you can use it directly as a variable in the rule, and the rule will run automatically when it changes.


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 4 of 5

ben.vandermeer
Explorer
Explorer

Thank you for the reply. Sorry for the late reply, i have been swamped with work until now.

It took me several tries to figure out what i did wrong, but i got it working now. 

 

I rewrote all parameters that mattered to 'Parameter("...")', which is indeed more flexible. I did not manage to get it to auto-update after a selection. But that may be due to that i work with Inventor 2016. Perhaps that will go more smoothly in Inventor 2019/2020. To make sure the parameters where present before the selection was made, i settled on 2 scripts, both run from my form. The first one makes all the parameters (including filling the multi value lists from the excel file), which then opens up the options for selection. After selection, i run the second script manually, which then updates the parameters i use in my model and PDM system.

 

I know that with the selection, i can forgo the 'double' parameter (writing the multivalue list selection into another parameter, instead of using it directly), however it is the only sure way i know that all the parameters have been filled, since the process does not auto update. Making sure the correct parameters are there is important.

 

Again: thank you very much for your answer.

 

I settled on the following 2 scripts: 

The parameter creation script (pardon the Dutch)

Try
test = oUserParams("Basismateriaal")
'test = Parameter("Basismateriaal")
Catch
'Aanmaken in geval van error
oUserParams.AddByValue("Basismateriaal", "", kTextUnits )
'Parameter("Basismateriaal") = ""
End Try
Try
test = iProperties.Value("Custom", "EN-MaterialGroup")
Catch
'Aanmaken in geval van error
iProperties.Value("Custom", "EN-MaterialGroup")=""
End Try
Try
test = iProperties.Value("Custom", "PBasisMat")
Catch
'Aanmaken in geval van error
iProperties.Value("Custom", "PBasisMat")=""
End Try
Try
test = iProperties.Value("Custom", "EN-Code")
Catch
'Aanmaken in geval van error
iProperties.Value("Custom", "EN-Code")=""
End Try
Try
test = oUserParams("oMatKeuze")
'test = iProperties.Value("Custom", "oMatKeuze")
Catch
oUserParams.AddByValue("oMatKeuze", "", kTextUnits )
'iProperties.Value("Custom", "oMatKeuze")=""
End Try
Try
test = iProperties.Value("Custom", "Finish")
'test = oUserParams("Finish")
Catch
'oUserParams.AddByValue("Finish", "", kTextUnits )
iProperties.Value("Custom", "Finish") = ""
End Try
Try
'test = oUserParams("Color")
test = iProperties.Value("Custom", "Color")
Catch
'oUserParams.AddByValue("PColor", "", kTextUnits )
iProperties.Value("Custom", "Color") = ""
End Try

MultiValue.SetValueOptions(True)
MultiValue.List("Basismateriaal") = GoExcel.CellValues("P:\mechanical drawings\Inventor Standard\Profile Excel Data\Weldment materials.xlsx", _ 
	"Weldment", "A2", "")

'Finish multivalue lijst aanmaken, en vullen met waardes vanuit de excel
Try
test = oUserParams("Nabewerking")
Catch
'Error = bestaat niet, dus: Aanmaken
oUserParams.AddByValue("Nabewerking", "", kTextUnits )
End Try
MultiValue.List("Nabewerking") = GoExcel.CellValues("P:\mechanical drawings\Inventor Standard\Profile Excel Data\Weldment materials.xlsx", _ 
	"Finish", "A2", "")


'Color multivalue lijst aanmaken, en vullen met waardes vanuit de excel
Try
test = oUserParams("Kleur")
Catch
'Error = bestaat niet, dus: Aanmaken
oUserParams.AddByValue("Kleur", "", kTextUnits )
End Try
MultiValue.List("Kleur") = GoExcel.CellValues("P:\mechanical drawings\Inventor Standard\Profile Excel Data\Weldment materials.xlsx", _ 
	"Colors", "A2", "")

And the selection script:

Parameter ("oMatKeuze") = Parameter("Basismateriaal")

MultiValue.UpdateAfterChange = True
Parameter.UpdateAfterChange= True

'MatiaalKeuze mag niet leeg zijn, anders geeft hij een error.
If Parameter("oMatKeuze") = "" Then
Parameter("oMatKeuze") = "-"
Else 
End If

'Zoek de waarde van MateriaalKeuze op, en vind daar met de andere kolommen de andere waardes bij.
i=GoExcel.FindRow("P:\mechanical drawings\Inventor Standard\Profile Excel Data\Weldment materials.xlsx", "Weldment", "Name", "=", Parameter("oMatKeuze"))
iProperties.Value("Custom", "EN-MaterialGroup") = GoExcel.CurrentRowValue ( "EN-Materialgroup") 
iProperties.Value("Custom", "EN-Code") = GoExcel.CurrentRowValue ( "EN-Code") 
iProperties.Value("Custom", "PBasisMat") = GoExcel.CurrentRowValue ( "PBasisMat") 

' Nu voor Finish
iProperties.Value("Custom", "Finish") = Parameter("Nabewerking")

'MatiaalKeuze mag niet leeg zijn, anders geeft hij een error.
If iProperties.Value("Custom", "Finish") = "" Then
iProperties.Value("Custom", "Finish") = "No Finish"
Else 
End If
	
'En voor Color
iProperties.Value("Custom", "Color") = Parameter("Kleur")

'MatiaalKeuze mag niet leeg zijn, anders geeft hij een error.
If iProperties.Value("Custom", "Color") = "" Then
iProperties.Value("Custom", "Color") = "-"
Else 
End If

All run from my form:

Form.JPG

0 Likes
Message 5 of 5

MjDeck
Autodesk
Autodesk

Glad to hear that you got it to work.

I had an idea that would allow you to use parameter names directly in the second rule. The first rule could create not only the parameters (if they didn't already exist) but it could also create the second rule. That would allow the second rule to use parameter names directly, and thus it would run whenever the parameter values changed.

The iLogicVb.Automation.AddRule statement can be used to add a rule. The rule text could be read from a file.


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes