iLogic crashes inventor when running ThisDoc.Document.SaveAs()

iLogic crashes inventor when running ThisDoc.Document.SaveAs()

Daan_M
Collaborator Collaborator
494 Views
4 Replies
Message 1 of 5

iLogic crashes inventor when running ThisDoc.Document.SaveAs()

Daan_M
Collaborator
Collaborator

Hi,

 

I'm trying to export a assembly as STP file and Zip it in a windows folder, i have to the following code

 

 

 

Dim StepName As String = Bestandsnaam 'Filename originating from text paramater inside my assembly
Dim SavePath As String = "C:\Data\Configurator testomgeving\Motor generator output files\"
Dim TempFile As String = SavePath & "zipDir\" & StepName & ".stp" 'Temp directory file

If System.IO.File.Exists(TempFile) = True 'check if it already exists
System.IO.File.Delete(TempFile)
End If

ThisDoc.Document.SaveAs(TempFile, True) 'Create Stepfile in a temporary folder in the destination path, it crashes here

Dim ZipName As String = SavePath & StepName & ".zip" 'Zip directory name and location
System.IO.Compression.ZipFile.CreateFromDirectory(SavePath & "zipDir", ZipName) 'Create zip-archive from temporary folder
System.IO.Directory.Delete(SavePath & "zipDir", True) 'Delete temporary folder

 

 


Unfortunatly it crashes my Inventor application at ThisDoc.Document.SaveAs(), not sure why....

 

EDIT: Also my other rule in which i save documents using ThisDoc.Document.SaveAs() has stopped working.

I ran fine earlier this morning, now it closes the application with and gives the 'send crash report' pop-up.

 

0 Likes
Accepted solutions (2)
495 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor
Accepted solution

This may be a dumb question, but does the value of the 'Bestandsnaam' parameter contain any characters that your file system may not like?  Here is one way to tell:

oInvalidNChars = System.IO.Path.GetInvalidFileNameChars
If oInvalidNChars.Length > 0 Then
	a = InputListBox("", oInvalidNChars, "", "Invalid File Name Chars", "List of Invalid File Name Chars")
End If
oInvalidPChars = System.IO.Path.GetInvalidPathChars
If oInvalidPChars.Length > 0 Then
	a = InputListBox("", oInvalidPChars, "", "Invalid Path Chars", "List of Invalid Path Chars")
End If

Can you use the same full file name as the code would create, but use it to manually SaveAs, using the File menu > SaveAs tool(s)?  Does that also cause a crash, or only when it is done by code?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 5

Daan_M
Collaborator
Collaborator

Hi,

 

That's a legitimate question, but unfortunatly i used "Motor" as name, which should be fine.

Also it only crashed through code

 

I think i might have found something that could be the source of the problem, I have a few rules in my assembly document (which is a configurator), marked yellow:

 

Daan_M_0-1668175814790.png

 

 

I have a form i use to test the outputs with, this form is connected to 'Assemble motor (manual)' rule, this rules saves the output as STP file.

 

The other rule  'Assemble motor (Excel linked STP generator)' saves the output as STP and then Zips it.

 

I just clicked on the button 'assemble motor (manual)' and it gave me a zipfile output, which is impossible because this does not happen in the 'Assemble motor (manual)' rule. I think somehow the other rule got triggered as well....

I notice a rule start running when i change a parameter in my form, but i'm not sure how i can disable this.

 

Maybe this is the cause of Inventor crashing, a conflict between rules running at the same time?

 

 

 

 

0 Likes
Message 4 of 5

Daan_M
Collaborator
Collaborator
Accepted solution

@WCrihfield 

 

I looked around a bit and coincidentally ran into another post where you gave a solution;

 

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/prevent-parameter-change-from-automa...

 

The parameters inside both rules are directly linked in my code, it could be that when i change these paramaters both rules start running, causing some sort of conflict. I will adress the paramaters indirectly and tell the result, thanks.

 

@WCrihfield This indeed seemed to be the problem, two rules doing a similar thing, both getting triggered by a paramater change inside my document. Thanks for your other post that provided the solution haha!

0 Likes
Message 5 of 5

WCrihfield
Mentor
Mentor

Just so you know, that may not be the only way to stop the rules from automatically running when parameter values change.  There are certain settings you can set to stop that behavior too.  When you are editing the rule within the iLogic Rule Editor dialog, go to the Options tab above the code window.  There are a couple options there you might be able to use, which would allow your code to remain the same, and things still work as planned.  The option named "Don't Run Automatically" can be checked, which is supposed to stop that rule from automatically running due to parameter changes.  The other option named "Fire Dependent Rules Automatically" could also be checked, to make sure.  These may be easier to do than changing your codes.

PS.  I believe those options can also be toggled by code remotely, just in case you may need to do this to a lot of rules, or something like that.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes