How to update a form with iLogic

How to update a form with iLogic

yvette.van.den.bosch
Contributor Contributor
1,160 Views
6 Replies
Message 1 of 7

How to update a form with iLogic

yvette.van.den.bosch
Contributor
Contributor

hi,

I am trying to make something, but I am not succeeding.

 

In a rule I create temporary paramter. In this case it contains 2 options. Then I open a form. The idea is that if you switch options, you get to see different info. In a message box I get the desired result, only the form does not update.

 

Is there any way to update the form so that it shows the updated parameter?

 

Sub main
	TempDiscription = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters.AddByValue("TempDiscriptionValue", "", UnitsTypeEnum.kTextUnits)
	
	Dim oModelEvent As ModelingEvents
	oModelEvent = ThisApplication.ModelingEvents

	AddHandler oModelEvent.OnParameterChange, AddressOf oModelEvent_ParameterChange

	' Make temp list
	MakeTempList()

	' Open the form
	Dim Form As FormReturnValue = iLogicForm.Show("Form 1", FormMode.Modal)

	' Delete temp ipropertie/parameter
	ThisDoc.Document.ComponentDefinition.Parameters.Item("TempList").delete
	ThisDoc.Document.ComponentDefinition.Parameters.Item("TempDiscriptionValue").delete

	RemoveHandler oModelEvent.OnParameterChange, AddressOf oModelEvent_ParameterChange
End Sub

Sub oModelEvent_ParameterChange(DocumentObject As _Document, Parameter As Parameter, BeforeOrAfter As EventTimingEnum, Context As NameValueMap, ByRef HandlingCode As HandlingCodeEnum)
	If BeforeOrAfter <> kAfter Then Exit Sub

	Dim DiscriptionList As New ArrayList
	DiscriptionList.Add("Option1;Discripton1")
	DiscriptionList.Add("Option2;Discription2")

	For Each aItem In DiscriptionList
		If aItem.Contains(Parameter.Value) Then
			arr = Split(aItem, ";")
			TempDiscriptionValue = arr(1)
			
			MessageBox.Show(TempDiscriptionValue, "What i want to see in the form")

		End If
	Next
End Sub

Sub MakeTempList()
	Dim OptionTempList As New ArrayList
	OptionTempList.Add("Option1")
	OptionTempList.Add("Option2")

	' make custom parameter
	TempListOptions = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters.AddByValue("TempList", "Option1", UnitsTypeEnum.kTextUnits)

	' fill custom parameter
	MultiValue.List("TempList") = OptionTempList
End Sub

yvettevandenbosch_0-1713809664718.png

I want to use this to display a list of materials to choose from. Depending on the material chosen, I then want to display the properties. Therefore, I use temporary parameters

 

0 Likes
Accepted solutions (1)
1,161 Views
6 Replies
Replies (6)
Message 2 of 7

WCrihfield
Mentor
Mentor
Accepted solution

Hi @yvette.van.den.bosch.  You may have to use separate iLogic rules for something like this.  When you launch an iLogic Form from an iLogic rule, the iLogic rule will remain 'paused' while that iLogic Form remains open, then will continue once that iLogic Form closes.  So, you will not be able to do anything to that iLogic Form from that same iLogic rule while that form remains open.  That rule that launches the Form will be notified though when that iLogic Form closes, as you may have already discovered.  Plus, if using an event handler code by iLogic rules, it is best to use an 'external' rule just for that event handler part, and have the other stuff in a different iLogic rule.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 7

yvette.van.den.bosch
Contributor
Contributor

Hi,

Thank you for your responds.

 

With the help of the event handler the code goes into the Sub "oModelEvent_ParameterChange". If you then switch between the options, a massage box with the desired result will appear. In the form I display the parameter to which the answer is written. Only the form does not update the parameter. So it looks like some kind of 'update form' is missing.

0 Likes
Message 4 of 7

WCrihfield
Mentor
Mentor

Lots of stuff going on there, but definitely need a document update after setting any parameter values.  Plus, within the event handler, it seems like you want that secondary value to be assigned as the value of your 'TempDiscriptionValue' parameter.  Well, when using a blue, unquoted parameter name in your rule, the parameter value changes set to those also need a special document update to see the results.  Use "RuleParametersOutput" (without the quotes) after any parameter value changes using those blue, unquoted parameter names.  When using Parameter() to change values, use Parameter.UpdateAfterChange = True at beginning of rule.  When using MultiValue to change param values, use MultiValue.UpdateAfterChange  = True at the beginning of the rule.  When changing param values using Inventor API, just do a regular Document.Update2(True) or 'InventorVb.DocumentUpdate'.  Heading out now for the day.  I'll check back tomorrow, if I remember.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 7

yvette.van.den.bosch
Contributor
Contributor

I tried both options. But the solution was indeed to take the code apart. I did this and now it works perfectly!

0 Likes
Message 6 of 7

wfajber
Contributor
Contributor

Already solved, but I wanted to chime in with a trick.

 

An iLogic rule appears as a button on the form. So if you break your rules apart, you can assign the rule that does the calculation to a button and change the label to Update or Apply.  Makes the form look more traditional and hides the thinking from the user.

0 Likes
Message 7 of 7

yvette.van.den.bosch
Contributor
Contributor

hi,

Thank you for the additional idea.

 

The idea was that the user chooses a material and then the description automatically comes with it. But I didn't want the user to have to press an update button or something.

 

yvettevandenbosch_4-1713940714370.png
yvettevandenbosch_3-1713940692105.png

 

 

0 Likes