in 上一个线程 https://stackoverflow.com/questions/54040390/how-to-save-data-in-stl-file-after-python-solid-processing显示了如何通过 SolidPython 创建 3D 实体并将其保存到 stl 文件。由于 $fa、$fs、$fn 未设置,因此它们具有默认值,并且 3D 体的面数较少。
上面线程中的示例代码:
from solid import *
from subprocess import run
d = difference()(
cube(10),
sphere(15)
)
scad_render_to_file(d, 'd.scad')
run(["openscad", "-o", "d.stl", "d.scad"])
Here the resulting stl-body
In the documentation https://solidpython.readthedocs.io/en/latest/ i didn‘t find anything about setting these variables. This readme https://github.com/bjbsquared/SolidPy/blob/master/readme.md seems to be obsolete.
如何在solidpython中设置$fa、$fs、$fn?
有两种方法可以做到这一点。
在solidpython中一些对象(例如circle()
, sphere()
, cylinder()
) 有可选参数segments
对应于$fn
在openscad中,请参阅solidpython包中objects.py文件中的源代码(在archlinux /usr/lib/python/site-packages/solid/objects.py上)。
可能的solidpython代码:
sphere(15, segments = 180)
生成的 openscad 代码:
sphere($fn = 180, r = 15);
或者可以在中设置文件头scad_render_to_file()
,参见solidpython包中的solidpython.py文件中的源代码。
固体Python代码:
scad_render_to_file(d, 'd.scad', file_header = '$fa = 0.1;\n$fs = 0.1;', include_orig_code=True)
将这些行写入 openscad 文件的顶部:
$fa = 0.1;
$fs = 0.1;
and here the resulting stl from the example
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)