I would like to suggest an argument to minkowski() that keeps the
bounding box of the first shape.
For example,
minkowski(){
linear_extrude(10)
text("hello");
sphere(1); // comment out to get 1st bounding box
}
The bounding box could be saved then resize() used to keep the bound box.
resize([27.8,10.20,10])
minkowski(){
linear_extrude(10)
text("hello");
sphere(1);
}
Jesse,
Did you base your example on text just to make an example, or is that
the specific need? If it is the latter then I think there there is a
solution without changing minkowski(). See below for an approach based
on textmetrics.
If your actual need isn't only for text, then I also have the same
problem from time to time but rather than changing minkowski, I would
like to have a metrics facility that provides bounding box size and
corner position for any geometry. For some of my projects, I generate
fairly complex geometry. I don't know the exact final dimensions but I
need them in order to enclose my first shape within another shape (a
hollow cylinder) with only a small clearance.
Steve
s = textmetrics(text = "hello", $fs = 0.1).size; // I use small
facets to get fairly smooth text
echo(s.x, s.y);
translate([0.5, 0.5, 0.5]) // because sphere radius is 1 in
this example
resize([s.x, s.y, 10]) minkowski() {
linear_extrude(10) text("hello", $fs = 0.1);
sphere(r = 1, $fs = 0.1); // I use small facets to get a
fairly smooth sphere
}
*color("red", 0.3) linear_extrude(10) text(text = "hello", $fs = 0.1);
// enable and preview to check that the result matches the orignal
text dimensions
On 2024-11-02 4:44 p.m., Jesse Campbell via Discuss wrote:
I would like to suggest an argument to minkowski() that keeps the
bounding box of the first shape.
For example,
minkowski(){
linear_extrude(10)
text("hello");
sphere(1); // comment out to get 1st bounding box
}
The bounding box could be saved then resize() used to keep the bound box.
resize([27.8,10.20,10])
minkowski(){
linear_extrude(10)
text("hello");
sphere(1);
}
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
On 11/3/2024 11:17 AM, Steve Lelievre via Discuss wrote:
I would like to have a metrics facility that provides bounding box
size and corner position for any geometry.
PR#4478 has this. (No ETA for integration. though.)
The construct {{ any-geometry }} yields a geometry value that can be put
into a variable, passed to a function, et cetera. One key function that
it can be passed to is the render() function. The results are like so
(reformatted for readability):
echo(render( {{ cube(10); }} ));
ECHO: {
min : [0, 0, 0],
max : [10, 10, 10],
center : [5, 5, 5],
size : [10, 10, 10],
objects : [{
points : [
[0, 10, 10],
[10, 10, 10],
[10, 0, 10],
[0, 0, 10],
[0, 0, 0],
[10, 0, 0],
[10, 10, 0],
[0, 10, 0]
],
faces : [
[0, 1, 2, 3],
[4, 5, 6, 7],
[3, 2, 5, 4],
[2, 1, 6, 5],
[1, 0, 7, 6],
[0, 3, 4, 7]
]
}]
}
Note that, as its name implies, the render() function renders its
argument. As with any render, that can take non-trivial time and may
slow down preview.
Oh! PR#4478 will be a huge bonus for me, once it does happen. Knowing
the bounding box will be very good, but having access to the polyhedron
points is huge.
I'm working on a project right now where it would be really helpful: I'm
distorting text in ways that I can't do only in OpenSCAD (a skewed
keystone effect) so I have ended up exporting extruded text as STL,
putting it through a web tool that converts STL to OpenSCAD polyhedron
data, and then finishing off the model in a second OpenSCAD program that
walks the points vector to apply the distortion.
Steve
On 2024-11-03 4:17 p.m., Jordan Brown wrote:
On 11/3/2024 11:17 AM, Steve Lelievre via Discuss wrote:
I would like to have a metrics facility that provides bounding box
size and corner position for any geometry.
PR#4478 has this. (No ETA for integration. though.)
The construct {{ any-geometry }} yields a geometry value that can be
put into a variable, passed to a function, et cetera. One key function
that it can be passed to is the render() function. The results are
like so (reformatted for readability):
echo(render( {{ cube(10); }} ));
ECHO: {
min : [0, 0, 0],
max : [10, 10, 10],
center : [5, 5, 5],
size : [10, 10, 10],
objects : [{
points : [
[0, 10, 10],
[10, 10, 10],
[10, 0, 10],
[0, 0, 10],
[0, 0, 0],
[10, 0, 0],
[10, 10, 0],
[0, 10, 0]
],
faces : [
[0, 1, 2, 3],
[4, 5, 6, 7],
[3, 2, 5, 4],
[2, 1, 6, 5],
[1, 0, 7, 6],
[0, 3, 4, 7]
]
}]
}
Note that, as its name implies, the render() function renders its
argument. As with any render, that can take non-trivial time and may
slow down preview.
I, also, would greatly appreciate it when PR4478 is integrated. It could
potentially make my designs much easier. Len
On Sun, Nov 3, 2024 at 10:20 PM Steve Lelievre via Discuss <
discuss@lists.openscad.org> wrote:
Oh! PR#4478 will be a huge bonus for me, once it does happen. Knowing the
bounding box will be very good, but having access to the polyhedron points
is huge.
I'm working on a project right now where it would be really helpful: I'm
distorting text in ways that I can't do only in OpenSCAD (a skewed keystone
effect) so I have ended up exporting extruded text as STL, putting it
through a web tool that converts STL to OpenSCAD polyhedron data, and then
finishing off the model in a second OpenSCAD program that walks the points
vector to apply the distortion.
Steve
On 2024-11-03 4:17 p.m., Jordan Brown wrote:
On 11/3/2024 11:17 AM, Steve Lelievre via Discuss wrote:
I would like to have a metrics facility that provides bounding box size
and corner position for any geometry.
PR#4478 has this. (No ETA for integration. though.)
The construct {{ any-geometry }} yields a geometry value that can be put
into a variable, passed to a function, et cetera. One key function that it
can be passed to is the render() function. The results are like so
(reformatted for readability):
echo(render( {{ cube(10); }} ));
ECHO: {
min : [0, 0, 0],
max : [10, 10, 10],
center : [5, 5, 5],
size : [10, 10, 10],
objects : [{
points : [
[0, 10, 10],
[10, 10, 10],
[10, 0, 10],
[0, 0, 10],
[0, 0, 0],
[10, 0, 0],
[10, 10, 0],
[0, 10, 0]
],
faces : [
[0, 1, 2, 3],
[4, 5, 6, 7],
[3, 2, 5, 4],
[2, 1, 6, 5],
[1, 0, 7, 6],
[0, 3, 4, 7]
]
}]
}
Note that, as its name implies, the render() function renders its
argument. As with any render, that can take non-trivial time and may slow
down preview.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org