For the geometry I am making, I want to extrude each face individually along its normal.
This is a standard procedure in 3D modeling software like Blender; see Example 3 here.
Is this possible in OpenSCAD?
For the geometry I am making, I want to extrude each face individually along its normal.
This is a standard procedure in 3D modeling software like Blender; see Example 3 here.
Is this possible in OpenSCAD?
For extruding a single face, as long as you can know the plane the face is in, you can projection
it to a 2D shape then linear_extrude
that. In general you need the cut=true
variant of projection
, and you need to translate/rotate the object to be projected such that the face is in the XY plane (this is the "as long as you can know") part. Unfortunately this is subject to numerical instability, so you probably have to translate it by an extra 0.001 or so to cross the XY plane, in which case you'll end up with an approximation of the face rather than an exact version of it.
(Strictly speaking OpenSCAD doesn't have exact things anyway, except in the case of faces sharing points in a polyhedron
, so this limitation probably doesn't make the situation any worse than it already is in OpenSCAD).
Once you have the projection, you can linear_extrude
it in any direction you want, manipulate the result (e.g. skew with a transformation matrix), and rotate and translate it back onto the face. It should be possible to wrap up this whole operation into a module
that operates on its child[ren].
Another approach would be capturing a thin slice around the face manually via intersection
, then performing a hull
with a translate of itself, but this will only work if it's convex (otherwise hull
will fill in the convex hull of the 2D face shape too).
Extruding faces is only possible on 2D polygons. From a 3D object you cannot capture the face and extrude it. To extrude "faces" you would need to define the shape of the face and extend it in the third dimension of your choice. This way a 3D shape is created that could be concatenated (joined using e.g. union
) to the original shape. For the extrusion, the function linear_extrude
is available:
linear_extrude(height = fanwidth, center = true, convexity = 10, twist = -fanrot, slices = 20, scale = 1.0, $fn = 16) {...}
projection
it to a 2D shape then extrude that. You can also capture a thin slice around a face manually via intersection
and then hull
it with a translate of itself. (Depending on the object the latter may or may not give exact results.)
$\endgroup$
Commented
Sep 6, 2019 at 11:50
Built-in to the language and its CSG model, no - processing the CSG tree is a completely separate phase following execution of the functional language, and there is no way to "read back" anything from the conversion of the model into faces in order to operate on the faces.
However, you can do this if you're willing to do some heavy lifting yourself, or look for library code from someone else who's already done it. What it would involve is working out a description form of your own in terms of nested lists representing the model, with a module for converting the list to an OpenSCAD CSG tree. You can then write functions to manipulate this description in arbitrary ways, essentially reinventing the CSG phase of OpenSCAD within its own language. Some lesser versions of this have definitely been done in the past for things like implementing "loft" type functionality in OpenSCAD.