Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

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 form multi-value parameter does not update

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Pav3L
609 Views, 6 Replies

iLogic form multi-value parameter does not update

Hi,

I have a multi-value parameter "MG_Steel_Grade" and based on what I select another multi-value parameter "MG_PT001" is populated with data from an Excel table and a particular value should be displayed.

The problem is that about half the time the particular value of "MG_PT001" is not updated/changed and remains unchanged.

 

Values in the "MG_Steel_Grade" parameter are:

1)S235  2)S355  3)WNr. 1.4301, AISI 304  4)WNr. 1.4571, AISI 316 Ti

 

The values for the "MG_PT001" parameter are taken from an Excel table embedded in the assembly, screenshot of the Excel table is attached.

For S235 and S355 the options are in column A, for WNr. 1.4301, AISI 304 and 4. WNr. 1.4571 AISI 316 Ti the options are in column D.

 

By default if I choose S235 the "MG_PT001" parameter should show EN10025 S235JR.

For S355 it should show EN10025 S355J2 and so on...

 

Now when I switch from S235 or S355 to any WNr. and vice versa the "MG_PT001" gets updated/changed correctly, but when I switch from S235 to S355 the "MG_PT001" is not updated and the value remains the same as it was for S235.

This also applies for switching from WNr. 1.4301, AISI 304 to WNr. 1.4571, AISI 316 Ti and vice versa, the value of "MG_PT001" remains unchanged.

 

Here is example on a 1 min youtube video https://www.youtube.com/watch?v=pLD1fXoNAwU 

 

I don't know what to do or if this is a strange behaviour of Inventor... is there a way to fix it?

In a forum post I found this line of code "MultiValue.UpdateAfterChange = True" but it does not help.

 

The rule looks like this and example files are attached.

Dim Indx_PT001 As Integer
Dim ExcMin As String
Dim ExcMax As String

Select Case MG_Steel_Grade
	Case "S235"
		Indx_PT001 = 0
		ExcMin = "A2"
		ExcMax = "A10"
	Case "S355"
		Indx_PT001 = 1
		ExcMin = "A2"
		ExcMax = "A10"
	Case "WNr. 1.4301, AISI 304"
		Indx_PT001 = 0
		ExcMin = "D2"
		ExcMax = "D10"
	Case "WNr. 1.4571, AISI 316 Ti"
		Indx_PT001 = 4
		ExcMin = "D2"
		ExcMax = "D10"
End Select

If Component.IsActive("PT001") = True Then
	Select Case Parameter("Type")
		Case "Boss"
			MultiValue.SetValueOptions(True, DefaultIndex := Indx_PT001)
			MultiValue.List("MG_PT001") = GoExcel.CellValues("3rd Party:Material_Table", "Material_Solid_Bars", ExcMin, ExcMax)
		Case "Tube"
			MultiValue.SetValueOptions(True, DefaultIndex := Indx_PT001)
			MultiValue.List("MG_PT001") = GoExcel.CellValues("3rd Party:Material_Table", "Material_Tubes", ExcMin, ExcMax)
		Case "Washer"
			MultiValue.SetValueOptions(True, DefaultIndex := 5)
			MultiValue.List("MG_PT001") = GoExcel.CellValues("3rd Party:Material_Table", "Material_Solid_Bars", ExcMin, ExcMax)
	End Select
	Parameter("PT001", "Mat_Grade") = MG_PT001
End If

 

Labels (5)
6 REPLIES 6
Message 2 of 7
WCrihfield
in reply to: Pav3L

Hi @Pav3L.  You have several different things going on in that rule, and are using several different 'iLogic tools' in the process that each 'update' a bit differently.  It sounds a bit like the model is simply not getting the updated values sent to it, then updated, when you expect it to.  There are a few 'preparatory' lines you may need to add to the beginning of your rule, and a couple we could add to the end of it too, depending on your preferences.

 

The following two lines are for placing near the start of your code (before using the 'Parameter' or 'MultiValue' iLogic objects), and are for causing changes made with those two objects later in the code to cause an update whichever document those objects are being used to edit.

Parameter.UpdateAfterChange = True
MultiValue.UpdateAfterChange = True

 

The following line of code should be used after any portion of your code that has changed the value of one of the 'blue', unquoted parameter names, to force that change to be immediately pushed to 'the model'.  It is often only needed once, at or near the end of the rule, but sometimes if later calculations depend on earlier ones, it may be used between things.

RuleParametersOutput

After that line of code, if there is no other 'mechanisms' in place for updating the document at the end, then it is almost always a good idea to use one of the many lines of code that will force the Document to update immediately.

 

The following line is a very common iLogic snippet for causing an immediate document update.  You will notice once again that it contains no 'specification' for which document to update, so it tries to figure it out, and can be different in different scenarios.

InventorVb.DocumentUpdate()

One of my favorites though is a true Inventor API method, where the 'oDoc' shown below is a variable that you may have created earlier in the code, and represents the Document object that this rule is focused on.

oDoc.Update2(True)

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 7
Pav3L
in reply to: WCrihfield

Hi @WCrihfield 

the thing is, I am only working with two multi-value parameters in the main assembly, they are not used anywhere in the model yet, that will come later, I wanted to test if this part will work first.
I can and will remove some code from the rule to make it easier to test, but it still does not behave as I would like.

I tried adding the lines below literally everywhere in the rule, since I knew about these lines of code before your reply, but still to no effect.

 

RuleParametersOutput()
MultiValue.UpdateAfterChange = True
InventorVb.DocumentUpdate()

 

Only the one below is new to me, but adding it did not help.

 

Parameter.UpdateAfterChange = True

 

 


@WCrihfield wrote:

One of my favorites though is a true Inventor API method, where the 'oDoc' shown below is a variable that you may have created earlier in the code, and represents the Document object that this rule is focused on.

 

oDoc.Update2(True)

 

 

The rule I posted before is all there is to it, there is no hidden part or anything after it. I am not using the line below or anything like it in the rule.

 

oDoc = ThisApplication.ActiveDocument

 

 

To repeat, the MG_Steel_Grade parameter has the following values  1) S235  2) S355  3) WNr. 1.4301, AISI 304  4) WNr. 1.4571, AISI 316 Ti. These are the case lines of the code.

One thing I do not understand is that the rule partially works fine, even with absolutely zero of the above update lines.

 

It works fine if I change the MG_Steel_Grade from 1) to 3) or 1) to 4) or 2) to 3) or 2) to 4) and vice versa.

It does not work, when I change the MG_Steel_Grade from 1) to 2) or 3) to 4) and vice versa.

 

Another way to explain it. It works ok when the MG_Steel_Grade parameter is changed so that the data from the Excel table is taken from a different column, because when you look at it case 1) and 2) are from column A and case 3) and 4) are column D.

 

Here is a new video that also shows the working/not working part I mentioned above https://youtu.be/gvkxFh_exPw 

The assembly shown in the video is attached.

 

Shortened version of the original code, which still only partially works, I did not leave any of the update lines in because they had no effect.

 

Dim Indx_PT001 As Integer
Dim ExcMin As String
Dim ExcMax As String
Select Case MG_Steel_Grade
	Case "S235" ' 1)
		Indx_PT001 = 0
		ExcMin = "A2"
		ExcMax = "A10"
	Case "S355" ' 2)
		Indx_PT001 = 1
		ExcMin = "A2"
		ExcMax = "A10"
	Case "WNr. 1.4301, AISI 304" ' 3)
		Indx_PT001 = 0
		ExcMin = "D2"
		ExcMax = "D10"
	Case "WNr. 1.4571, AISI 316 Ti" ' 4)
		Indx_PT001 = 4
		ExcMin = "D2"
		ExcMax = "D10"
End Select
MultiValue.SetValueOptions(True, DefaultIndex := Indx_PT001)
MultiValue.List("MG_PT001") = GoExcel.CellValues("3rd Party:Material_Table", "Material_Solid_Bars", ExcMin, ExcMax)

 

 

I feel like the problem is somehow related to the DefaultIndex value or when the data from Excel is inserted into the MG_PT001 parameter.

When the MG_PT001 is populated with new data, the data is really new only if there is a change in the column from which they are taken, then it works, but if the data remains the same (changing from case 1) to 2) or 4) to 3) then the displayed value is changed only by the DefaultIndex and this part does not work.

 

Message 4 of 7
A.Acheson
in reply to: Pav3L

Hi @Pav3L 

As far as I can remember the default index only works when there is new data or if the existing value is no longer in the list. Of there is no change it doesnt effect the list. In this case I prefer to set the value manually using the parameter value. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 5 of 7
Pav3L
in reply to: A.Acheson

Hi @A.Acheson 


@A.Acheson wrote:

Hi @Pav3L 

In this case I prefer to set the value manually using the parameter value. 


I am not sure what you mean exactly, could you give me an example?

 


As far as I can remember the default index only works when there is new data or if the existing value is no longer in the list. Of there is no change it doesnt effect the list. 


This is what I was afraid of, looks like I will have to write the rule that everytime there is new data.

Message 6 of 7
A.Acheson
in reply to: Pav3L

Set the parameter just like going into the parameter window and adjusting. 

 

Parameter("MG_PT001") = "......"


Or alternatively you get set it as an index of multivalue list of you want the value to be automated to a certain value by index.  

Parameter("MG_PT001") = MultiValue.List("MG_PT001").Item(1)

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 7 of 7
Pav3L
in reply to: A.Acheson


@A.Acheson wrote:

Or alternatively you get set it as an index of multivalue list of you want the value to be automated to a certain value by index.  

 

Parameter("MG_PT001") = MultiValue.List("MG_PT001").Item(1)

 

 

 

That works, thank you.

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

Post to forums  

Autodesk Design & Make Report