The idea is to create n CAD models as per the sampling algorithm, each of those n CAD models are saved in separate directories along with a equations.txt file and a Macro.swp file.
So, I am writing a loop in python that a) goes to each directory b) updates the equations.txt file taking values from the sampling algorithm output. c) run a batch file that (opens solidworks, builds the model after the equations.txt update, saves sldprt)
Now, in c), the steps of opening building and saving a sldprt are in macro.swp file, which has a path mentioned in it to open the CAd file. As I have n directories, I need to be able to update this path for each macro.swp file as well.
Unfortunately macro.swp does not open as a text file to be updated by python. I tried changing the extension from swp to bas, which is text format, but then the extension cannot be changed back to swp, making it impossible to update the path in the macro as a text update.
Can anyone suggest, how can I change the path in the macro file?
SolidWorks macros can be save as text files with SWB extension.
But I think a better solution would be to get the folder of the current macro with GetCurrentMacroPathName. And eventually get the cad files path from either the current directory with GetFolder or from the equations.txt