Skip to content Skip to sidebar Skip to footer

How To Set Special Variables $fa, $fs, $fn In Solidpython

in a previous thread is shown, how to create a 3D-body and save it to an stl-file by solidpython. As $fa, $fs, $fn are not set they have the default values and the 3D-body has a lo

Solution 1:

There are two ways to do it.

In solidpython some objects (eg. circle(), sphere(), cylinder()) have the optional parameter segments corresponding to $fn in openscad, see the source code in the file objects.py in the solidpython package (on archlinux /usr/lib/python/site-packages/solid/objects.py).

possible solidpython code:

sphere(15, segments = 180)

resulting openscad code:

sphere($fn = 180, r = 15);

Alternatively a file header can be set in scad_render_to_file(), see the source code in the file solidpython.py in the solidpython package.

solidpython code:

scad_render_to_file(d, 'd.scad', file_header = '$fa = 0.1;\n$fs = 0.1;', include_orig_code=True)

writes these lines to the top of the openscad file:

$fa = 0.1;
$fs = 0.1;

and here the resulting stl from the example enter image description here


Post a Comment for "How To Set Special Variables $fa, $fs, $fn In Solidpython"