有没有办法在 Python 中有效地将 SCAD 文件转换为 STL 格式?我有大约 3000 个文件要转换为 STL。另外,还有一些不同的格式。
我尝试在互联网上搜索一些图书馆,但找不到任何合适的图书馆(我使用的是 Windows 操作系统)有人知道吗?
有没有办法在 Python 中有效地将 SCAD 文件转换为 STL 格式?我有大约 3000 个文件要转换为 STL。另外,还有一些不同的格式。
我尝试在互联网上搜索一些图书馆,但找不到任何合适的图书馆(我使用的是 Windows 操作系统)有人知道吗?
您可以从命令行运行 openscad,查看文档,并通过 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()