Issue with multiple modifications of a Parameter value within iLogic

Issue with multiple modifications of a Parameter value within iLogic

llorden4
Collaborator Collaborator
690 Views
9 Replies
Message 1 of 10

Issue with multiple modifications of a Parameter value within iLogic

llorden4
Collaborator
Collaborator

I've been handling this issue for some time now, thought I'd bring this up to see if this is a bug or working as intended...

 

Basically I'm finding that as long as my iLogic is only modifying a Parameter value once, then the parameter updates correctly.  However if a value is modified more than once then the parameter fails to update at all per the iLogic rule.

 

A typical workflow I use it first to ensure the input value is within an acceptable range, in this example I'll be accepting a value of 1 thru 10 in any decimal value.  I'll then make sure the user input is rounded to a specific fractional value to ensure consistency in output.  For example, some people may enter 0.6, 0.63, or 0.625, etc for a value of 1/16th.  I use an algorithm to ensure it's always "exactly" a decimal equivalent to the nearest 16th value.

'ensure user input is between 1 and 10, decimal values allowed
If Dia < 1 Or Dia > 10 Then Parameter("Dia") = 5

'round user input to nearest 16th
'(this works ONLY if line 2 doesn't change the "Dia" parameter value
Parameter("Dia") = Round(Dia * 16) / 16			'rem this line to get parameter updates to work

 A work around I've found  is the following double method...

'this method appears to be a valid work around
If Dia < 1 Or Dia > 10 Then
	Parameter("Dia") = 5
	Dia = 5
End If

Parameter("Dia") = Round(Dia * 16) / 16
Dia = Round(Dia * 16) / 16

 I've played around a bit trying updates with "RuleParemetersUpdate()" and "InventorVb.DocumentUpdate()" but they don't appear to help.

 

It appears to me that parameters just won't correctly update if modified more than once during the iLogic rule.  Is this intended, is there a best practice, or is this news to everyone else?

 

File attached in Inv Ver 2023 for your sample review, just open the Parameters menu.  Choose to use the Alternate method (with the work around) or not (doesn't update) and just edit the "Dia" model parameter with values to see how it responds.

 

Autodesk Inventor Certified Professional
0 Likes
Accepted solutions (1)
691 Views
9 Replies
Replies (9)
Message 2 of 10

Frederick_Law
Mentor
Mentor
Accepted solution

Don't keep changing the parameter.  Use a variable and change parameter at the end.

NewDia = Parameter("Dia")

NewDia = 5

NewDia = Round(NewDia * 16) / 16

Parameter("Dia") = NewDia

 

Unless you want to see the model update with each parameter change.

Message 3 of 10

llorden4
Collaborator
Collaborator

Thanks.

 

The down side to this solution is that after entering all those Parameters, within ilogic I have to re-enter "all" of them again and update output again at the end.  Three times the work, not exactly a time saving option and could easily miss handling a variable/parameter with a long list.

Autodesk Inventor Certified Professional
0 Likes
Message 4 of 10

Frederick_Law
Mentor
Mentor

What do you mean by "enter all" again?

If you need to check all parameters for same thing, make that a function/sub.

0 Likes
Message 5 of 10

llorden4
Collaborator
Collaborator

I mean for every user Parameter I want to validate the rounding...

  • Create the Parameter for the user entry
  • Create a duplicate Variable in iLogic to manipulate and use within iLogic
  • Copy the value of the duplicate variable back to the Parameter

 

 

Autodesk Inventor Certified Professional
0 Likes
Message 6 of 10

Frederick_Law
Mentor
Mentor

@llorden4 wrote:

I mean for every user Parameter I want to validate the rounding...

  • Create the Parameter for the user entry
  • Create a duplicate Variable in iLogic to manipulate and use within iLogic
  • Copy the value of the duplicate variable back to the Parameter

Exactly.  One iLogic funtion/sub to work on all parameters.

0 Likes
Message 7 of 10

Frederick_Law
Mentor
Mentor

Do you have a set of User Parameters?

Or user will create and delete User Parameters.

Does user edit the parameters?

Or use iLogic form to edit?

0 Likes
Message 8 of 10

llorden4
Collaborator
Collaborator

Typically I have predefined attributes, entered using a form.  I believe I get where you're coming from, create a sub-routine that runs through every Parameter, evaluate the type, then round, back to iLogic.

Rounding inputs will vary (16th, 8th, quarter, etc), so, a bit of a twist there...  but maybe two or three sub-routines to separate the rounding type...

 

Still doesn't invalidate the point of having to do manage one intended placeholder at least three times.

Autodesk Inventor Certified Professional
0 Likes
Message 9 of 10

Frederick_Law
Mentor
Mentor

Ok, the problem is parameter changed.  Model/sketch didn't update.

iLogic-09.jpg

0 Likes
Message 10 of 10

Frederick_Law
Mentor
Mentor

Try this file.

Don't know if rule can be function.

0 Likes