有没有一种方法可以在Python中有效地将SCAD文件转换为STL格式?我大约有3000个文件要转换为STL。另外,有一些不同的格式。
我尝试在Internet上搜索一些库,但找不到任何合适的库(我正在使用Windows OS)任何人有任何想法吗?
最佳答案
您可以从命令行运行openscad,请参见documentation,
并通过python准备每个命令(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)
python3.5及更高版本中的
subprocess.call
应替换为subrocess.run()
关于python - 在Python中将SCAD文件格式转换为STL,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44678286/