iLogic - derived parameter out of sync

iLogic - derived parameter out of sync

Anonymous
Not applicable
493 Views
6 Replies
Message 1 of 7

iLogic - derived parameter out of sync

Anonymous
Not applicable

I'm driving changes in a sub-assembly from a top-level assembly by changing parameter values in a base component .I use an iLogic rule in my top-level assembly to write to the parameter values in the base component, which then sets of a ripple effect of rules firing in sub-levels.

 

One of the parameters in my base component is called "ratio". 

 

I have a sub-assembly that derives this parameter and uses it in an iLogic rule to determine what component to replace. But the parameter value is not updating before replacing the component. I've used this technique countless times without a problem in different rules and I'm stumped as to why its not working for this one.

 

As a test, I used a message box to show the value of "ratio" at the end of my top level rule (which is always correct) and another message box to show the value of "ratio" in my sub-assembly rule before the replacing occurs (which is always different to the value I'm shown in the top level).

 

I need to then manually run the rule in the sub-assembly after all the other rules have executed, which by that point is then using the updated value.

 

I don't understand how this can be possible? My 1st messagebox confirms the value has changed, and as the parameter is derived in the sub-assembly it should be the same?

 

 

0 Likes
494 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable

To add a little more to this, I ran a messagebox check in a sub-part which also derives the "ratio" parameter and its showing the correct value. So its only the assembly that's not working.

0 Likes
Message 3 of 7

Owner2229
Advisor
Advisor

Hmm, the only thing that comes on my mind is: Do you update the document before reading the value?

oDoc.Update()

(IMO)

If You're changing Sub-Sub parts from the top assy (without the sub-assy open), this might happen:

- the top assy is avare of the change, as it was changed directly from it => correct value

- the sub-assy might be unavare of the change, as it is not open => wrong value

- the part is avare of the change as, you're reading the value from the top-assy => correct value

 

The point is, the changed value you're trying to access is stored in the top-assy, so when you command the sub-assy to read the values, it reads the "original" ones from the stored part. So you have to either save the part (and the sub-assy) or update the sub-assy.

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 4 of 7

Anonymous
Not applicable

Is InventorVb.DocumentUpdate() the same thing? I've got that as the first line of code.

 

FYI - The sub-assembly is open when the change occurs

0 Likes
Message 5 of 7

Owner2229
Advisor
Advisor

The "InventorVb.DocumentUpdate()" will update the document from which it is run (the top-assy in your case).

 

How are you accessing the sub-assy / part? Using the occurrences? Or even better, can you post your code?

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 6 of 7

Anonymous
Not applicable

I'm using this bit of code at the very end of my top-level rule to run all the rules inside my "Door" assembly.

 

Dim ruleRunner = New RunAllRulesUnderDocument(iLogicVb, Component, "")
Dim doc = ThisDoc.Document
ruleRunner.RunAllRules("Door") 

 

When I comment out this section, it solves the problem (but gives me a long list of other problems!! so I need to keep it)

0 Likes
Message 7 of 7

Anonymous
Not applicable

This is the code inside my sub-assembly


InventorVb
.DocumentUpdate()
MessageBox.Show(dooropeningratio, "Title") If dooropeningratio >= 1555 And dooropeningratio < 1605 Then Component.Replace("Slide", "P01742.iam", False) ElseIf dooropeningratio >= 1505 And dooropeningratio < 1555 Then Component.Replace("Slide", "P01741.iam", False)

ElseIf and so on.........

End If

 

0 Likes