我需要在 python 上处理 openscad 程序。我使用实体库(https://solidpython.readthedocs.io/en/latest/index.html https://solidpython.readthedocs.io/en/latest/index.html)但我还没有找到任何处理后保存数据的方法。例子
from solid import *
d = difference()(
cube(10),
sphere(15)
)
我需要保存d变量到 stl 文件。这个怎么做?如果有更好的库,我需要建议哪个库更好使用。
您需要 openscad 将数据导出为 stl 文件。您可以通过 python 代码执行此操作:
from solid import *
# to run openscad
from subprocess import run
d = difference()(
cube(10),
sphere(15)
)
# generate valid openscad code and store it in file
scad_render_to_file(d, 'd.scad')
# run openscad and export to stl
run(["openscad", "-o", "d.stl", "d.scad"])
您可以在 openscad 中打开 d.scad,渲染它(按 F6)并将其导出为 STL 或在控制台中运行,而不是最后一步:
openscad -o d.stl d.scad
从命令行查看openscad的使用文档 https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_OpenSCAD_in_a_command_line_environment
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)