edyvedy13
edyvedy13

Reputation: 2296

Converting scad file format to stl in Python

Is there a way of converting SCAD files to STL format efficiently in Python? I have around 3000 files to be converted to STL. Plus, there are some different formats.

I tried searching on the internet for some libraries but was not able to find any suitable one (I am using Windows OS) Anyone has any idea?

Upvotes: 1

Views: 2279

Answers (2)

Marco Merlin
Marco Merlin

Reputation: 31

nowadays openscad integrates manifold library which is much faster. However the updated release (2023) is not yet availble as packages for main distrubution so the easiest way to get it is to install one of the nightly builds.

Upvotes: 0

a_manthey_67
a_manthey_67

Reputation: 4306

you can run openscad from command line, see documentation, and prepare every command by python (example in python3)

from os import listdir
from subprocess import call

files = listdir('.')
for f in files:
    if f.find(".scad") >= 0:            # get all .scad files in directory
        of = f.replace('.scad', '.stl') # name of the outfile .stl
        cmd = 'call (["openscad",  "-o", "{}",  "{}"])'.format(of, f)   #create openscad command
        exec(cmd)

in python3.5 and higher subprocess.call should be replaced by subrocess.run()

Upvotes: 2

Related Questions