Hi
I am trying to run some code prior to checking a file back into vault. The code works when run on a normal File -> Close. But when I check the same file into Vault I experience a crash.
Following is the code at its bare minimum and yet it crashes. Can anyone guide me on this one....
'On Error Resume Next Dim oDoc As DrawingDocument oDoc = ThisApplication.ActiveDocument Dim Sheet As Inventor.Sheet Dim Cursheet As String Cursheet = oDoc.ActiveSheet.Name For Each oSheet In oDoc.Sheets oSheet.Activate For Each pL In oDoc.ActiveSheet.PartsLists If (pL.Title = "Data Dump List") Then oPartsList = pL
'''Process info'''
Next Next oDoc.Sheets(Cursheet).Activate
Open to all the ideas.
Thank you in advance
Solved! Go to Solution.
Solved by adam.nagy. Go to Solution.
Could you verify that active document is the document you expect to be active when you experience crash?
use MsgBox:
oDoc = ThisApplication.ActiveDocument
MsgBox(oDoc.FullFilename)
What is the detailed error message you get from iLogic?
Thanks,
Hi Vladimir
Tried your code but it didn't play nice with iLogic so I changed it to
MessageBox.Show(oDoc.FullFilename, "Title")
I am sure it will give you the same result. But do let me know if you need me to try something else.
Now the detailed error is as follows
Error Message tab:
Error in rule: Rule1, in document: 15-0002
Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
More Info tab:
System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)
at LmiRuleScript.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
Hope you can help me resolve this one.
Thanks
Vishal
Have you set event triggers for your rule?
Could you describe the workflow in more detail?
Thanks,
Yes, I have this code as an external rule in our custom template iDW file and it is set to the 'Close' event trigger.
So everytime I close a file I have two scenario's. One when I simply close the file without checking it in and this works just fine. But the second one is where I want to allow checkin which then causes this error.
Could you please itry to ntiate this rule by Before Save event trigger (not Close) and let me know the result.
Thanks.
Hi
I did move the rule to the save event trigger and added a messagebox to ensure the rule cycles through the sheets. Then I did save the file and checked it into Vault. I did not get any errors, the trigger worked fine.
Then I tried reverting back to the original scenario and got the error again. So my rule in combination with a close/check-in event trigger does not work. So the Vault connection seems to play up because if I closed a file which is only in my workspace and not heading to Vault the close trigger works.
Do let me know if you need anymore info.
Thanks
Another idea
I looks like after iLogic rule the file could be always dirty. That’s why you get an error - check-in won't happen with unsaved document.
Hi
Sorry for the late reply. But I don't understand what you mean by 'dirty' so I tried adding a ThisDoc.Save at the end. That did not help either. I still got a crash on the Close event.
Well the code I provdied you does crash and this is with me not processing any of the information I want. The comment '''Process info''' was just to indicate that I will eventually add stuff in there.
Could you please try this out on your machine and let me know if it does crash for you too.
Do you have any other suggestions to fix this problem?
Thanks
Hi,
You said "I am trying to run some code prior to checking a file back into vault."
If you have a look at the discussoin in this thread then it seems like listening to the close event is too late, the file is already checked into Vault by then:
So you as well should probably try to do things in the onsave event.
"Dirty" means that the document has unsaved changes. Any change (even oSheet.Activate) will make the document dirty.
Cheers,
Adam
Thank you for your reply and the link too. This was highly informative. I will have to work around this issue but now that I know the steps as highlighted in the link I can be smart about it.
Thanks once again
Vishal