API Stability Tips?
API Stability Tips?
(OP)
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.
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.






RE: API Stability Tips?
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.
RE: API Stability Tips?
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...
"If you don't use your head,
your going to have to use your feet."
RE: API Stability Tips?
How big are your files?
http://www.EsoxRepublic.com-SolidWorks API VB programming help
RE: API Stability Tips?
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.