Recently I have been working on an assignment to convert five file formats (.dae, .stl, .step, igs, obj) to .stl. using FreeCAD Python console and help from people on StackOverflow and FreeCAD forum, I was able to do that.
The last part of this assignment is to convert .sldprt (Solidworks Parts File) to .stl. Unfortunately, FreeCAD does not support importing this file format and I can not use its Python console to convert this file format to .stl.
I have been searching Python APIs that can read/export .sldprt files but I haven't been able to find any. I did find some online sources (GradCAD, Datakit Cross manager etc.) but I need to accomplish this by a Python script (preferably Python 2).
Is there another way I can convert .sldprt file to .stl using Python? Can someone point me in the right direction where to start?
Since sldprt is a proprietary format, you are only able to do that if SOLIDWORKS is installed on the executing machine. This is done with the SOLIDWORKS API. With that condition out of the way, you will need to write some sort of bridge between Python and the SOLIDWORKS COM API objects which is a big hassle. If this is a school assignment, I would suggest you write a console application in C# or VB.NET that opens the file and converts it to whatever target format. You can command that application from your Python program.
There are a bunch of cloud services that can do CAD files conversion. Those can be a good alternative if you can't afford a SOLIDWORKS license or don't have access to one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With