Getting dimensions of imported shape?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting dimensions of imported shape?

marhar
Sometimes I import an external STL file to make some modifications...
resize a hole, etc.  To do so, I need to get the dimensions of the
imported object.

Scale markers are useful for this, but usually takes a couple of tries
to get the correct values.

Is there any way in OpenSCAD to retrieve dimensions of objects?  Even
dumping out bounding boxes to the console would be great.

Alternatively, any other programs that can print useful information
about an STL file, such as bounding boxes?  I realize that STL files
don't have dimension information; just the values are fine.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Getting dimensions of imported shape?

JordanBrown
On 7/22/2018 11:39 AM, Mark Harrison wrote:
Alternatively, any other programs that can print useful information
about an STL file, such as bounding boxes?  I realize that STL files
don't have dimension information; just the values are fine.

Text STL files are in a pretty simple format and can be relatively easily examined in any language.

Here's an awk program that dumps the bounding box for a text STL file:

BEGIN {
    m = 1000000;	// Make larger if your model is really large
    maxx = -m;
    minx = m;
    maxy = -m;
    miny = m;
    maxz = -m;
    minz = m;
}

$1 == "vertex" {
    maxx = ($2>maxx ? $2 : maxx);
    minx = ($2<minx ? $2 : minx);
    maxy = ($3>maxy ? $3 : maxy);
    miny = ($3<miny ? $3 : miny);
    maxz = ($4>maxz ? $4 : maxz);
    minz = ($4<minz ? $4 : minz);
}

END {
    print minx,miny,minz;
    print maxx,maxy,maxz;
}


If what you have is a binary STL file then it's a little harder.  How hard depends on your computer; if you're on a little-endian system (like Intel-derived systems) then it's not bad, probably a couple of dozen lines of C.

There's a simple description of the file format at https://en.wikipedia.org/wiki/STL_(file_format)#Binary_STL



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Getting dimensions of imported shape?

fred_dot_u
In reply to this post by marhar
I've found it useful to use Meshmixer, a free program, to import STL files.
The Analysis feature has a dimension option which will display a bounding
box for the entire model based on the current orientation. If a model is
irregular, you can use Edit/Transform to rotate it and check the bounding
box again.

Also useful is the Edit/Plane Cut, which allows you to slice the model in
any location, multiple times, to get a different set of bounding boxes,
enabling you to measure accurately, say, a cylinder in the center of the
model, or to better determine a specific dimension.

Obviously, one would not save the sliced model as it would overwrite your
original.

Another great feature is Undo (Control-Z) which lets you perform and measure
a slice, then return to the original model (Control-Z multiple times) and
make other actions.



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Getting dimensions of imported shape?

atnbueno
In reply to this post by marhar
Hi.

Alternatively, any other programs that can print useful information
about an STL file, such as bounding boxes?  I realize that STL files
don't have dimension information; just the values are fine.

There is a really old (‘96!) command line tool that you may find useful:


Regards,
Antonio B.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Getting dimensions of imported shape?

Jamie Bainbridge
In reply to this post by marhar
On 23 July 2018 at 04:39, Mark Harrison <[hidden email]> wrote:
> Alternatively, any other programs that can print useful information
> about an STL file, such as bounding boxes?  I realize that STL files
> don't have dimension information; just the values are fine.

I wrote a Python script which can do this:
https://www.reddit.com/r/3Dprinting/comments/7ehlfc/python_script_to_find_stl_dimensions/

Jamie

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Getting dimensions of imported shape?

ClintGoss
>  … external STL file …
>  … get the dimensions of the imported object.

I use 3D-Tool. They provide a free STL viewer that is very handy for measuring between points, vertices, lines, planes, etc.


-- Clint Goss

Goss.com  ... index of all our web sites



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
-- Clint Goss <clint@goss.com>
Reply | Threaded
Open this post in threaded view
|

Re: Getting dimensions of imported shape?

Alexander Pruss
In reply to this post by marhar
Rather than using OpenSCAD's import function, I convert stl files directly to
OpenSCAD polyhedra using my stl2scad.py script:
https://github.com/arpruss/miscellaneous-scad/tree/master/scripts

The latest version of the script puts all the points in an stlObject1_points
list, so you can calculate bounding boxes yourself with:
 minima = [for(i=[0:2]) min([for(p=stlObject1_points) p[i]])];
 maxima = [for(i=[0:2]) max([for(p=stlObject1_points) p[i]])];

If you just want to see the bounds without converting to a polyhedron, the
bounds.py script will do that.



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org