Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

API Stability Tips?

Status
Not open for further replies.

engAlright

Mechanical
Jun 12, 2003
240
I've got an API program that runs through a directory of about 10,000 parts, assemblies and drawings and does various things to them (open in Solidworks, lock references, re-orient to ISO, edit custom props, save).

Some of these documents have errors, and the odd one seems to lock up Solidworks or crash it.

Does anyone have any tips for ensuring Solidworks stability in the API? Is there a way to "monitor" the status of an active application to determine if it is hung?

Barring that, is there a way to record a Solidworks crash? If I could at least figure out how to record which document caused the crash, I could set the program to restart itself from that document, or do it manually.
 
Replies continue below

Recommended for you

I have some routines that perform similar tasks on batches of files (open file, change options, resave) and have seen similar behaviour - random crashes and occasional lockups.

I sometimes see a message "This program is busy - Abort Retry" but after pressing Retry the program continues without errors. I think this is due to network issues - the code trying to communicate faster than the network will allow.

If you want to see whether the same file(s) are causing the problem, open a text file during execution and write the file name and time as you process each file. Then you will have a record. I think it would be better to close the text file after each entry and reopen on the next file rather than keep it open during the entire process.
 
To capture where and what errors occur, you could try ..

Sub main()
On Error GoTo errorHandler
Dim swDoc....
.
.
.
.
.
.
.
.


Exit Sub
errorHandler:
"INSERT ERROR HANDLING CODE - for example to display message box with the doc that erred and possibly an explanation as to why"
Resume Next
End Sub


The statement "On Error Resume Next" will disable VB's implicit error handling control and allow you to control how the errors are handled and at the least minimize the chances of your API program being the cause of the lockup.


Remember...
[navy]"If you don't use your head,[/navy] [idea]
[navy]your going to have to use your feet."[/navy]
 
Maybe it's a memory thing. Are you releasing all of your objects and variables? Are your files completely unloaded?

How big are your files?

[bat]I could be the world's greatest underachiever, if I could just learn to apply myself.[bat]
-SolidWorks API VB programming help
 
Ended up that the problem was with the quality of the model data (errors, missing external references). I was able to buzz through parts and drawings without too many problems, but when it got to assemblies it would crash solidworks about every hour.

Still haven't been able to figure out a way through api to detect a solidworks crash, so every time it crashed I had to restart the program manually. Since the program was re-saving the documents I just set up the program to skip any files that had a save date within the recent time frame of when the program was running, which seemed to work reasonably well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor