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: 

Dynamic Multi Value list not working?

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
e2000773
568 Views, 11 Replies

Dynamic Multi Value list not working?

Hello my code for changing Multi value list parameter with another Multi value parameter is not working for some reason. If I change it to another it may update it 1 time, but it's under wrong parameter value and doesn't change after that. I have a form where I change these.  This is an external rule.

If Parameter("Kategoria") = "Tyhjä" Then
	MultiValue.SetList("Tuote", "Tyhjä")
	InventorVb.DocumentUpdate()
	
ElseIf Parameter("Kategoria") = "Kisko" Then
	MultiValue.SetList("Tuote", "Suora", "Suorataivutettu", "Kulma")
	InventorVb.DocumentUpdate()

ElseIf Parameter("Kategoria") = "Läpivienti" Then
	InventorVb.DocumentUpdate()
	MultiValue.SetList("Tuote", "Lattia", "Katto")
	InventorVb.DocumentUpdate()
End If

 

11 REPLIES 11
Message 2 of 12
e2000773
in reply to: e2000773

Okay after I changed it, I got it to work every time I change parameter and run the rule manually, but is there a way to run the rule immediately automatically.

 

If Parameter("Kategoria") = "Tyhjä" Then
	MultiValue.SetList("Tuote", "Tyhjä")


	
ElseIf Parameter("Kategoria") = "Kisko" Then
	MultiValue.SetList("Tuote", "Suora", "Suorataivutettu", "Kulma")



ElseIf Parameter("Kategoria") = "Läpivienti" Then
	MultiValue.SetList("Tuote", "Lattia", "Katto")


End If

MultiValue.UpdateAfterChange = True

 

Message 3 of 12
Andrii_Humeniuk
in reply to: e2000773

Hi @e2000773 . You need to add your rule to Event Triggers. Yes, you can. Follow the steps as in the screenshot.

YourRule.png

Andrii Humeniuk - Leading design engineer

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

Message 4 of 12
e2000773
in reply to: Andrii_Humeniuk

I have my "Refresh" rule (this code) there on both Parts and Assemblies tabs. Still no Dice. My form currently has no buttons so it's not about the apply button either (Didn't work with that either when I tried). This is External rule and Global form.

e2000773_0-1684235189106.png

 

Message 5 of 12
dimamazutaMMJ32
in reply to: e2000773

Hi @e2000773.

Try to create "internal rule" in your document with this line

iLogicVb.RunExternalRule("Refresh")
InventorVb.DocumentUpdate()

Then add this rule to the Event Triggers.

 

Message 6 of 12
e2000773
in reply to: dimamazutaMMJ32

No dice and I can't have any internal rules.

Message 7 of 12
dimamazutaMMJ32
in reply to: e2000773

Ok @e2000773 let's try this:

1. - I don't understand why rule "Refresh" is in  "Any Model Parameter Change" in Event Triggers. Are these Text Parameters users?

2. - I've created these parameters in Users Parameters, added external rule to the "Any User Parameter Change" in Event Triggers, created Global form and it's work for me.

Please check new code and video how it works.

MultiValue.UpdateAfterChange = True
MultiValue.SetValueOptions(True, 0)
If Parameter("Kategoria") = "Tyhjä" Then
	MultiValue.SetList("Tuote", "Tyhjä")
ElseIf Parameter("Kategoria") = "Kisko" Then
	MultiValue.SetList("Tuote", "Suora", "Suorataivutettu", "Kulma")
ElseIf Parameter("Kategoria") = "Läpivienti" Then
	MultiValue.SetList("Tuote", "Lattia", "Katto")
End If

 

 

Message 8 of 12
A.Acheson
in reply to: e2000773

Hi @e2000773 

Can you place the rule as a button in your form? I am not certain if there is a simple solution for triggering parameters from an external rule otherwise.

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 9 of 12
WCrihfield
in reply to: e2000773

Also, if you are using a global iLogic form, you will need to make sure you edit that form to include the Apply button, because when you make parameter value changes in a global form, those changes will not effect the model until after you click the Apply button.  And if you click the apply button, that will send the changes to the document, without closing the form.  Dragging that external rule over into your global form as a rule button is also an option, because then clicking that button will run the rule, but you would still need to click apply before running the rule to make sure that any edits have been sent to the document first.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 10 of 12
e2000773
in reply to: WCrihfield

What I’m trying to do is a preselect of directory folders in a path for automatic save & replace code initial directory in the file dialog.

The initial directory in the code is: ”C:\Users\Name\Desktop\” + Parameter(”Kategoria”) + ”\” + Parameter(”Tuote”). Both Parameters multivalue list contains the names of the folders. And yes later there will be more folders.


Currently in the form between these two parameters sits my Refresh rule as a button. So the process now goes like choose the first parameter value -> refresh button -> choose now from parameter multivalue the refresh button just limited smaller. I want to get rid of that refresh button to just the second parameter changing dynamically based on the first ones value.

When I have chosen the correct values, in the form I press my Save & Replace button and the initial directory in the file dialog opens the correct locations, I open the file and press Esc to get a new dialog asking for a new name for the file to be replaced on the assembly tree. I know this form is a primitive way to do this, but it works.

The reason why I have to have External rules and Global form is that it needs to work in a new empty assembly. Now if the External rules are the problem… Is there a code to create a internal rule with the code of the refresh rule on the fly when a new document is created or old one opened?

 

Message 11 of 12
e2000773
in reply to: dimamazutaMMJ32

Hey that works! It was there, because I was testing my form in empty part file too, because in the zero document my button for the form doesn't work (missing files or something). Thank you!

Message 12 of 12
e2000773
in reply to: A.Acheson

Yes I can, but dimamazutaMMJ32 came up with a brilliant solution.

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

Post to forums  

Autodesk Design & Make Report