Run iLogic Rule after Part Geometry Change

Run iLogic Rule after Part Geometry Change

calincanahai
Contributor Contributor
2,732 Views
10 Replies
Message 1 of 11

Run iLogic Rule after Part Geometry Change

calincanahai
Contributor
Contributor

So this should be very simple but I cannot get this to work as intended.

I have a very simple code that measures the dimensions of a part when you run it.

 

 

G_L = MaxOfMany(Measure.ExtentsLength,Measure.ExtentsWidth,Measure.ExtentsHeight)
G_T = MinOfMany(Measure.ExtentsLength,Measure.ExtentsWidth,Measure.ExtentsHeight)
G_W = Measure.ExtentsLength + Measure.ExtentsWidth + Measure.ExtentsHeight - G_L - G_T
iLogicVb.UpdateWhenDone = True

 

I'm using the Event Trigger to run the rule on "Part Geometry Change".

 

You would expect that if you modify the part via extrude/cut/whatever. Inventor would see the part geometry has changed, it would run the rule, and I would have the new dimensions of the part in my parameters. However, that's not quite what happens. My rule is always 1 step behind my latest operation.  I think Inventor is registering that a part geometry change is about to happen, and before it does, it runs my rule to measure the part. Then after it has finished measuring it, the part geometry changes.

 

Below is my order of operations and what I'm observing:

  • I start with a cube 1x1x1 and my rule has not run yet (my G_T, G_W, G_L are all zero). 
  • I change my extrude length to 10 so that my part is 1x1x10.
  • My parameters update to G_T=1, G_W=1, G_L=1.
  • I change my extrude length back to 1 (part dimensions 1x1x1).
  • My parameters update again to G_T=1, G_W=1, G_L=10.

 

It seems like the Event Trigger should be worded "Before Part Geometry Change" and I would really like an event trigger that is "After Part Geometry Change". This has been very frustrating and I haven't been able to find anyone with a similar problem. Any help would be very appreciated. 

Thanks!

Accepted solutions (1)
2,733 Views
10 Replies
Replies (10)
Message 2 of 11

mcgyvr
Consultant
Consultant

Works fine here..

Please post a part file with this rule that shows the issue..

Also state the version of Inventor you are using..

 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 3 of 11

calincanahai
Contributor
Contributor

Thanks for the response. I tried to edit my original post to attach the file but I don't think it worked. I'm using Inventor 2018 and 2019. I get the same result on both. It won't let me attach a file to this message either. Were you able to get it to work with the event trigger?

0 Likes
Message 4 of 11

calincanahai
Contributor
Contributor

I can share the part through a google drive link, I hope that is allowed
https://drive.google.com/file/d/1fMGeTgtrfjfYYfSQf_FbjSa7FDTKJ2tA/view?usp=sharing

0 Likes
Message 5 of 11

mcgyvr
Consultant
Consultant

Set it to run with the "Any model parameter change" event then it works just fine..

The part geometry change rule seems to have some stipulation (that I'm not aware of) in which the rule fires before the model is actually updated to reflect the changes..



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 6 of 11

calincanahai
Contributor
Contributor

Thanks, that works for most situations. It correctly displays the dimensions when editing features through the model tree. However, if I change a parameter through the sketch or through the parameters directly it runs the rule before the model can update. It really seems like there should be a way to delay the rule to run after the changes are done and the model has updated

0 Likes
Message 7 of 11

johnsonshiue
Community Manager
Community Manager

Hi Guys,

 

I am not iLogic expert. I only know very basics. Pardon me if I am off. I am wondering if inserting the two options would help. You first set Parameter.UpdateAfterChange = False or place iLogicVb.UpdateWhenDone = True at the top.

 

 

Parameter.UpdateAfterChange
iLogicVb.UpdateWhenDone

 

Would it work for you?

Many thanks!

 



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
Message 8 of 11

calincanahai
Contributor
Contributor

Parameter.UpdateAfterChange didn't work. But, I tried just telling the document to update before measuring the extents and that did it! Thanks for the suggestion! I added InventorVb.DocumentUpdate() at the start of the code.

 

So the final code looks like this:

InventorVb.DocumentUpdate()

G_L = MaxOfMany(Measure.ExtentsLength, Measure.ExtentsWidth, Measure.ExtentsHeight)
G_T = MinOfMany(Measure.ExtentsLength,Measure.ExtentsWidth,Measure.ExtentsHeight)
G_W = Measure.ExtentsLength + Measure.ExtentsWidth + Measure.ExtentsHeight - G_L - G_T

iLogicVb.UpdateWhenDone = True

This will get the correct dimensions most of the time using the parameter change trigger. However, if you suppress or unsuppress a cut it will still be one step behind. I guess I can live with that. I would still like it if autodesk had an event trigger for "After a part geometry change" and not just "before". Triggering of parameter changes can make mistakes ideally I'd want to use geometry changes.

 

 

0 Likes
Message 9 of 11

DRoam
Mentor
Mentor
Accepted solution

Hi @calincanahai, I was able to get the Extents measurements to get the correct (new) value after feature suppression/un-suppression by using the following (I also added a MessageBox at the end for testing purposes):

 

 

ThisDoc.Document.Rebuild()

G_L = MaxOfMany(Measure.ExtentsLength, Measure.ExtentsWidth, Measure.ExtentsHeight)
G_T = MinOfMany(Measure.ExtentsLength,Measure.ExtentsWidth,Measure.ExtentsHeight)
G_W = Measure.ExtentsLength + Measure.ExtentsWidth + Measure.ExtentsHeight - G_L - G_T

MessageBox.Show(G_T & vbNewLine & G_W & vbNewLine & G_L)

 

I just replaced the "InventorVb.DocumentUpdate()" line with "ThisDoc.Document.Rebuild()", which does about the same thing, but is a little more "thorough", and I guess forces Inventor to actually perform the full geometry update before proceeding to measure the extents. Since it's more thorough, it could also be slower, but the difference shouldn't be noticeable unless your part is very complex.

 

Also, the "iLogicVb.UpdateWhenDone = True" shouldn't be necessary, since you're already updating/rebuilding at the start of the rule, and your rule isn't doing anything to affect the part.

 

Hope this works for you!

Message 10 of 11

calincanahai
Contributor
Contributor

Thank you! As far as I can tell this fixes it for every case. And now I can just use the trigger on part geometry change.

0 Likes
Message 11 of 11

dusan.naus.trz
Advisor
Advisor

This was the solution for me = ThisDoc.Document.Rebuild (); Thank you DRoam.
I also tried InventorVb.DocumentUpdate (), but I failed

0 Likes