Hello Sanaa,

I used makepy.py to generate swcommands.py, swbindings.py, swconst.py
and cosworks.py and placed them in the same directory as the python file
I ran (at least I think it worked that way).

Then,

import swbindings, swcommands, swconst, cosworks
import win32com.client
import pythoncom
sw=swbindings.SldWorks()
arg1 = win32com.client.VARIANT(pythoncom.VT_DISPATCH, None)
mdsl=sw.NewDocument(r'C:\ProgramData\SolidWorks\SOLIDWORKS
2018\templates\MBD\part 0251mm to 1000mm.prtdot',6,1,1)
model = sw.ActiveDoc
modelExt = model.Extension
selMgr = model.SelectionManager
featureMgr = model.FeatureManager
sketchMgr = model.SketchManager
sketchMgr.InsertSketch(True)

etc. worked fine. It should work similarly with your code.

Inspecting swbindings.py, I found a RunMacro function, which might be
what you need.

Are there any error messages?

An other way would be to run the macro from excel using xlwings, if it
is a excel macro.

Best regards

Moritz
_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to