Does anybody know how to close an application (*.ipt & *.iam) by ilogic code?
I tried to use
ThisDoc.Document.close (True)
to close it.
Indeed, it can close the application, but there is an error occurred as following:
Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
Does anybody know how to avoid this error or any other way to close (or exit) the application?
OK need some more info or understanding.
You have a part that has ilogic to make the part then after you make the part you want it to close?
see we have to understand your steps in what you are doing with it.
You are right.
The reason is I do not want other people see my codes.
So, I have a *.ipt (or *.iam) file with codes (we coudl call it parent-model?). When it is opened, it will start to ask user to input part number to generate the model (child-model?).
So, when child-model is generated, I will use codes to delete all rules in child-model which you and Mike help me to get this already.
Now, because I do not want the user to see my rules. So, I need close the parent-model immidiately after user get the child model.
I just get a code which could close Inventor
ThisApplication.Quit
But it is better just close the parent-model instead of Inventor.
Do you know any code can do this way?
I think your issue may be with the ilogic code you have to delet all ilogic.
you may have to leave the ilogic that closes the main file if you are deleted them all the error is you are deleting the closed part too.
This is a guess without seeing the code you have to delete all ilogic.
No. The iLogic code in child-model could be delete by rules already.
Now, I just want to close the parent model (*.ipt or *.iam) in order user cannot see my rules.
Hello James,
Thanks lot for your reply. But could you please let me know what the type of oPartDoc is? We need declare it before use it, right?
Sorry, I may not make my idea very clear.
Just after genarating the child model, the child model will be saved to a separate files and all rules will be deleted by an external rule in child-model.
The parent-model will keep as it is.
If I could colse the parent-model imminately after generating the child-model, the user should be unable to see my rules.
That is the reason I need some code to close the parent-model.
Sorry, James,
PartDocument is not a good type, I think.
Because it will occure Errors:
Type 'PartDocument' is not defined.
And I need code to close *.iam too.
For child-model, I am using
ThisDoc.Document.SaveAs(outputfile, True)
It works fine. And I can make my child-model very nice and clear (without any rules).
I just want to close parent-model by code after generating child model in order the user cannot read my rules in parent-model.
I think you may get an error no matter what you do unless you use a starting dummy part to open your parent part. As when you are in the parent any code you execute to close it will cause an error as the code itself has not finished. Could you open a dummy part, which opens your parent part, execute that code then pass control back to the dummy part which closes your parent?
Is this also the way you save the assembly?
I don't have a delete rules in my parts or assembly but the parent part should close after you generate files if you are using the code we helped you with.
So this is why I am lost mine closes and I don't get that error so there is something we are missing and this is where seeing the code would help.
Now if I just put a close ilogic in I get the error but not if I add the generate files with saveas in ilogic and the oPartDoc.close I do not get the error.
But after reading the error it will not hurt anything they will have to close the error message but if that is all it is I would not worry about it. It still closes the main file.
But still customer can open the parent part seperately.
If this is the case, I may use
ThisApplication.Quit
to close the Inventpr.
Even this way, I can control the user to read the code in *.iam, still I cannot control them to read the code in *.ipt. I need find a way in order the user cannot open the *.ipt seperately as
If *.iam is not open, then *.ipt need to be clsoed.
Any suggestion?
OK. May be the error is OK.
Do we have code to check whether an assembly is opened?
I want ot write some code in *.ipt. When it is opened, if its relative *.iam is not opened, it need to be closed immediately.
If we could do this, the user should be unable to read my ilogic code.
May I ask why you don't want the user to see the code? And are thee local users or you making ilogic parts for another company and don't want to give out codes so they can do it themselves ?
Oh reason I am asking I have an idea but need to know who what where there before I go into testing..
Mark would be able to answer it right away he is the ilogic guru.... Me I still have to test...
Can't find what you're looking for? Ask the community or share your knowledge.