discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Minkowski() argument to preserve size

JC
Jesse Campbell
Sat, Nov 2, 2024 11:44 PM

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);
}

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); }
SL
Steve Lelievre
Sun, Nov 3, 2024 7:17 PM

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

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 -- https://www.gnomoni.ca https://www.youtube.com/@gnomonica
JB
Jordan Brown
Mon, Nov 4, 2024 12:17 AM

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.

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.
SL
Steve Lelievre
Mon, Nov 4, 2024 4:20 AM

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.

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. >
LM
Leonard Martin Struttmann
Mon, Nov 4, 2024 2:07 PM

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

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 >