I am running a VBA Macro in solidworks that stops working and requires me to restart Solidworks after exactly 478 loop-itterations every time I run it.
Inside my loop, I open an STEP file, verify it, and then save it as an STL file. It appears as if Solidworks is struggling to open more than a fixed number of files in the same session.
My plan was to write a VB.NET script outside of Solidworks that can automatically restart the application without my intervention every X number of ittwerations, so I can process the thousands of files I have without my intervention.
VB.NET console script that closes and reopens Solidworks for me, whenever 477 itterations are reached, and then continues the macro from where it has left off.
The folders with my files are numbered, e.g.
c:\data\0\file.STEP
c:\data\1\file.STEP
c:\data\2\file.STEP
...
c:\data\20000\file.STEP
Specifically, I am looking for the VB.NET code that does the following:
1) first you need to open solidworks and the file you want to process: Open Assembly Document Example (VB.NET) http://help.solidworks.com/2017/english/api/sldworksapi/open_assembly_document_example_vbnet.htm
2) you will need the openMacro2 function. Here is a link with an example https://forum.solidworks.com/thread/79502
3) then close all documents with the CloseAllDocuments Method http://help.solidworks.com/2017/English/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.ISldWorks~CloseAllDocuments.html
4) then exit solidworks with the ExitApp Method https://help.solidworks.com/2017/english/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.ISldWorks~ExitApp.html
note: if you installed the api module you will find all needed examples in the apihelp.chm file which is located by default in: C:\Program Files\SOLIDWORKS Corp\SOLIDWORKS\api
I took the liberty choosing version 2017 since you didn't mention the version you are using. But all examples should work on later versions too. If you are on an earlier version and you cannot find for instance openDoc7, then look at openDoc6 or openDoc5... until you find the number that is available on your system.