Using Global Form Button to 'Save As Step File' and 'Close' the .ipt file

Using Global Form Button to 'Save As Step File' and 'Close' the .ipt file

Anonymous
Not applicable
1,837 Views
19 Replies
Message 1 of 20

Using Global Form Button to 'Save As Step File' and 'Close' the .ipt file

Anonymous
Not applicable

I have an external rule that saves my .ipt's as a .stp file and then closes the file. When I run the rule from the "External rules" tab of the iLogic browser, it works as intended.

 

I have a Global Form that I use that has buttons for various shortcuts like this and one of the buttons is tied to this rule. When I execute the rule from the form button, it saves the stp file, but does not close the ipt file. My suspicion is this is because the form remains open after the button click. But since it's an external rule, I don't have the settings available to "close after click" in the form settings.

 

Here's my code below, is there code I can add to force close the Global Form when the button is clicked? Which might then allow the close doc command to execute..

 

 

ThisDoc.Document.SaveAs(ThisDoc.ChangeExtension(".stp"), True)
ThisDoc.Document.Close(True)

 

 

0 Likes
1,838 Views
19 Replies
Replies (19)
Message 3 of 20

Anonymous
Not applicable

Hi Xun, I can't quite tell if you marked your own post as the solution or if someone else did but it appears to have been done in error. My post states that I'm having no trouble at all actually saving the stp file with my code. What I need help with is programming the ipt file to close after being saved as stp. Closing the ipt is the issue I'm having. Both links you posted are in regards to helping people save stp files in specific ways but nothing to do with closing the ipt file. Please let me know if I'm missing something in one of these posts that would assist me or have someone unmark my post as 'solved'. While it's still fresh on the forum I would hate for somebody with an answer to overlook it for being marked already

0 Likes
Message 4 of 20

Xun.Zhang
Alumni
Alumni

Just to clarify, never marked it as resolved by myself.

I hope to help you out.


Xun
0 Likes
Message 5 of 20

johnsonshiue
Community Manager
Community Manager

Hi! Sorry, it was me marking Xun's reply as the solution. I thought the answer was logical and applicable. I must have overlooked something.

Many thanks! Sorry for the confusion!

 



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 6 of 20

Xun.Zhang
Alumni
Alumni

Hello @YuhanZhang, would you mind help on this?


Xun
0 Likes
Message 7 of 20

Anonymous
Not applicable
0 Likes
Message 8 of 20

YuhanZhang
Autodesk
Autodesk

This seems something related with the iLogic Global Form, I emailed to Mike Deck to help to look into this.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 9 of 20

MjDeck
Autodesk
Autodesk

@Anonymous , which version of Inventor are you using?


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 10 of 20

Anonymous
Not applicable

Inventor Release: 2020.2 Build: 310

0 Likes
Message 11 of 20

MjDeck
Autodesk
Autodesk

It's working for me so far. I haven't seen any error.

Is your rule exactly as shown above? It doesn't have any more statements?
Can you post your global form? You can get to it by right-clicking on the background of the Global Forms page and choosing Open Containing Folder. Then upload the XML file that has the same name as your form.


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 12 of 20

MjDeck
Autodesk
Autodesk

Note: if you want the form to close, set it to Non-Modal. (Set its Modal property to False.)


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 13 of 20

Anonymous
Not applicable

Did you see my screencast? I showed the rule code that matches what I posted. I attached my form file here as well.

0 Likes
Message 14 of 20

MjDeck
Autodesk
Autodesk

I watched the screencast and tried your form, but I still haven't seen the problem. I'll ask other people to try it.

Does this happen with all parts?

Do you have any iLogic Event Triggers running rules on the Save or Close events?

Does it happen if you:

- start a new Inventor session

- open the part

- run the rule from the global form


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 15 of 20

Anonymous
Not applicable

Yes, this happens with all parts I've tried it with.

 

No iLogic event triggers are there.

 

I tried your sequence twice, once with a new part created and not checked into Vault. And again restarting inventor, opening a part that's checked into vault (did not check out). Neither instance closed the part from Global Form button, but did save the step file.

 

 

0 Likes
Message 16 of 20

MjDeck
Autodesk
Autodesk

I haven't tried it with Vault at all. That might be a clue.

Do you have any Inventor add-ins installed that are not from Autodesk?


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 17 of 20

Anonymous
Not applicable

Just the coolOrange thread modeler

0 Likes
Message 18 of 20

JaneFan
Autodesk
Autodesk

Hey @Anonymous , 

Would you mind do one more check with your external rule and the form: is the reference rule on the form pointing to the proper location of the correct rule? Please try to find the rule from the location and open it in notepad to check the content in the rule.

Thank you.

 



Jane Fan
Inventor/Fusion QA Engineer
0 Likes
Message 19 of 20

Anonymous
Not applicable

Well, that made me feel silly. That was definitely the root cause of the issue. My external rules were in my 2020 folder, but the form was still referencing the old rule in the 2019 folder. However I'm now experiencing a new issue. Like my previous error, the new error still follows the same behavior of working correctly when executed manually from external rules tab, but not when executed from form button click.

 

From the form button click the file is now saving the step file and closing the ipt file (this is progress) but I am now getting an Microsoft .NET Framework error. The .Net error only occurs from the form button click, and not from right clicking the rule in external rules and selecting 'run'. I've attached a screenshot and .txt file of the error I'm getting.

0 Likes
Message 20 of 20

JaneFan
Autodesk
Autodesk

Hey @Anonymous , 

 

Sorry to hear that. But I didn't see the error message with the same build as you, not sure whether it is because I am using a simple file and relatively clean form. 

Have you tried Mike's suggestion to make the Form as non-Model? 

If it doesn't work, would you please try to create another global form which only contains this rule button, and see whether it has the same error? 




Jane Fan
Inventor/Fusion QA Engineer
0 Likes