×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

API Stability Tips?

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.

RE: API Stability Tips?

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.

RE: API Stability Tips?

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...
       "If you don't use your head,            
                   your going to have to use your feet."

RE: API Stability Tips?

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?

I could be the world's greatest underachiever, if I could just learn to apply myself.
http://www.EsoxRepublic.com-SolidWorks API VB programming help

RE: API Stability Tips?

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources