Close current document using local rule without producing error

Close current document using local rule without producing error

DRoam
Mentor Mentor
312 Views
1 Reply
Message 1 of 2

Close current document using local rule without producing error

DRoam
Mentor
Mentor

I have a Part file with a local iLogic rule which does "some stuff" to configure Inventor. After the rule is done, I want it to close the part document that it's in. I have the following code at the end of my rule to do just that:

 

 

ThisDoc.Document.Close

This works just fine; the iLogic does everything I want, then fires this line and the document closes. However, immediately afterwards, I get the following error:

 

 

Close Current Doc Error.png

 

I'm about 99% certain this is because the rule isn't able to properly finish executing and hand off control back over to Inventor.

 

I'm able to continue just fine after that, Inventor doesn't crash or anything, but I want to avoid this error popping up.

 

So, is there some way to get around this? Just for kicks I tried adding an "On Error Resume Next" before the Close line, but it didn't make any difference.

 

Any suggestions? Or is it impossible to avoid this error?

 

(PS, the local rule does need to remain a local rule).

0 Likes
313 Views
1 Reply
Reply (1)
Message 2 of 2

philip1009
Advisor
Advisor

Is this the only document open in Inventor when it closes?  If this rule is run from an Assembly then it would be better to close the document from the Assembly file, I'm not sure of your workflow it's just a suggestion.  Other than that I'd try transferring that Document close line to an External Rule then have iLogicVb.RunExternalRule("Close Document") at the end of the local rule.

0 Likes