Immediately update Reference Parameter to use in iLogic code

Immediately update Reference Parameter to use in iLogic code

Anonymous
Not applicable
1,978 Views
4 Replies
Message 1 of 5

Immediately update Reference Parameter to use in iLogic code

Anonymous
Not applicable

I have iLogic code that alters my sketch, which changes the value of a Reference Parameter. I want to use that Reference Parameter to alter another sketch through iLogic.

The problem is, the Reference Parameter is not updated immediately, so the iLogic code needs to be run twice to get the right value of the Reference Parameter.

 

To illustrate the issue, I created a sketch as shown:

CaptureReferenceParameter.PNG

I run the following code:

 

Length1 = DesiredLength
Length2 = RemainingLength
iLogicVb.UpdateWhenDone = True

 

So Length1 is immediately set to the value of DesiredLength when the code is run, but RemainingLength is not updated, so Length 2 is not updated. If I run the code again, first then Length2 is updated correctly.

 

I know that in this specific case I could constrain the two squares to each other, or use following code instead:

 

Length2 = MaxLength - Length1

 

But my real user case is much more complex, involving multiple parameters and trigonometry, so I would prefer to use Reference Parameter as input.

 

Can this even be done, or is it a limitation in the way iLogic code is executed?

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

WCrihfield
Mentor
Mentor

Have you tried placing the update code between the two lines?

You can also try this option at the top of the rule:

Parameter.UpdateAfterChange = True

Its description is as follows:

If this is true, a document update will be performed automatically after a parameter value is changed with a Parameter function (Parameter.Value) in the current rule.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 5

WCrihfield
Mentor
Mentor

Here is another update line you might try:

RuleParametersOutput()

Its description is as follows:

Apply the modified values of any Inventor parameters used as local variables in this rule to the Inventor model.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 5

JhoelForshav
Mentor
Mentor
Accepted solution

@Anonymous 

I downloaded your part and did some testing.

This ilogic rule works 🙂

Length1 = DesiredLength
RuleParametersOutput()
InventorVb.DocumentUpdate()
Parameter("Length2") = Parameter("RemainingLength") 'Access parameters like this to not trigger the rule again.

 

Message 5 of 5

Anonymous
Not applicable

Thanks all!
This has been giving me a headache for some time, and I tried living with it. Glad to have it solved! 😃