pythonsolidworksapi

How to run a SolidWorks macro directly using Python


Is there a way where I can run a SolidWorks macro using python? Either by running the full script (macro) directly from a Python IDE, or by even writing a python script that could somehow open SolidWorks and run my pre-saved .swp macro, preferably in batch mode.


Solution

  • You can run a SolidWorks macro by executing a terminal command

    import os
    os.popen('"Path to SLDWORKS.exe" /m "Path to a macro"')