Use iLogic to create local iLogic rule (but not run it), or edit an existing one

Use iLogic to create local iLogic rule (but not run it), or edit an existing one

DRoam
Mentor Mentor
775 Views
3 Replies
Message 1 of 4

Use iLogic to create local iLogic rule (but not run it), or edit an existing one

DRoam
Mentor
Mentor

I'm using the code in the following blog post to have an external iLogic rule create a local iLogic rule in my document: AUTODESK INVENTOR – ILOGIC – CREATE A NEW ILOGIC RULE AUTOMATICALLY.

 

Problem is, the "AddRule"command used to do this also runs the local rule after creating it. But I don't want to run the rule yet, I just want it to be created. If it runs when the external rule creates it, a whole bunch of things will go wrong.

 

Indeed, if I open C:\Program Files\Autodesk\Inventor 2017\Bin\Autodesk.iLogic.Interfaces.xml, under the remarks for the "AddRule" command command it states that "The rule will be compiled and run." So this is how the command is supposed to behave.

 

But is there any way to disable or circumvent that behavior? Maybe a way  to suppress any iLogic rules from running until after AddRule has finished, and then un-suppress? (I tried using the "EnterDelayedRuleRunningMode" command to do just that but it doesn't make any difference.

 

Any suggestions on how to create a local iLogic rule without immediately running it?

 

Another possibility would be to have my external rule create the local rule empty, and then have my external rule edit it to have the correct contents. But I don't know of a command to edit an existing local rule. I'd like to be able to do that anyway, so if anyone knows of a way to do that, that would be great.

776 Views
3 Replies
Replies (3)
Message 2 of 4

clutsa
Collaborator
Collaborator

Could you wrap your new local rule in an if statement that checks if it's after some date/time that's set to 5 min. after the external rule starts running? It's kind of a dumb work around and it's not very elegant but it might buy you the delay you need?

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 3 of 4

LSKELLY
Enthusiast
Enthusiast

Have you found a solution to this problem yet?

0 Likes
Message 4 of 4

LSKELLY
Enthusiast
Enthusiast

At long last, I found a solution to this!

Instead of:

iLogic.AddRule(oDoc, RuleName, RuleText)

Add this code:

iLogic.AddRule(oDoc, RuleName, "")
iLogicVb.Automation.GetRule(ThisDoc.Document, RuleName).Text = RuleText

 

Can't believe it was that simple.