Breaking down a 3D model

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

Breaking down a 3D model

emanuel
Hi community!

I'm pretty new with OpenSCAD and I was wondering if you could help me with my project. I need to find out the edges position or length from some bodies. I'm currently using an stl file and then making the difference form a raw material to find the missing spots. So far the code below worked quite well.

difference(){
  cube([3000,3000,315]);
    import("file.stl");
    }

My challenge comes after this as I have no clue on how to access to the volumes as a result of the simple render, and I have been checking the documentation and nothing refers to this. I'm leaving an image for a better understanding of what I want to do.

Thanks!



Sent from the OpenSCAD mailing list archive at Nabble.com.

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

Re: Breaking down a 3D model

kdtop
I don't think this can be done.  Perhaps someone else will know better.  But I have found that working with an imported STL often gives funny results when doing differences.

Come to think of it, I'm not even sure if this could be done if using 2 native OpenSCAD objects.

Let's see if other people smarter than me can figure it out.

KT

On Wed, Feb 17, 2021 at 5:35 PM emanuel <[hidden email]> wrote:
Hi community!

I'm pretty new with OpenSCAD and I was wondering if you could help me with my project. I need to find out the edges position or length from some bodies. I'm currently using an stl file and then making the difference form a raw material to find the missing spots. So far the code below worked quite well.

difference(){
  cube([3000,3000,315]);
    import("file.stl");
    }

My challenge comes after this as I have no clue on how to access to the volumes as a result of the simple render, and I have been checking the documentation and nothing refers to this. I'm leaving an image for a better understanding of what I want to do.

Thanks!



Sent from the OpenSCAD mailing list archive at Nabble.com.
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.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: Breaking down a 3D model

MichaelAtOz
Administrator
In reply to this post by emanuel
You can't do D. or E. with built-in OpenSCAD, there is no access to the vertices/faces/edges etc of the resultant geometry. You could export it, but that doesn't help directly.

There are libraries which provide operations that work with vectors representing the points of objects.
I don't use those, so someone who does may join in the discussion.

But for those libraries to be used with a .STL would require a different method to get the STL geometry into OpenSCAD, as a polyhedron. I seem to recall some external conversion of STL to points, which could be include<>'ed as a variable.
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain;
to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.


Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain;
to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.
Reply | Threaded
Open this post in threaded view
|

Re: Breaking down a 3D model

cacb
On 18.02.2021 07:22, MichaelAtOz wrote:
> You can't do D. or E. with built-in OpenSCAD, there is no access to the
> vertices/faces/edges etc of the resultant geometry. You could export it,
> but that doesn't help directly.
>
> There are libraries which provide operations that work with vectors
> representing the points of objects.
> I don't use those, so someone who does may join in the discussion.

You can't do it in OpenSCAD, true.

In general, you can extract such information from Polyhedra, but going
via an STL file format is a particularly useless route because it
explicitly discards the topoligical information that is requested. But
that's only part of it.

I am however puzzled by the question since it is not explained why those
faces and edges are required. It seems to me to be an attempt to
re-create a traditional B-REP cad model from a discrete mesh based
modeller such as OpenSCAD. Maybe that is a totally wrong impression, but
if it isn't then it is asking for a "Von Munchhausen algorithm" (after
Baron Von Munchhausen who rescued himself and his horse from being stuck
in a swamp, by lifting his own hair). Most of the time, such attempts
are less than successful, I have tried it several times.

Still, if one insists, it is possible to some degree to extract such
information from polyhedra, containing only vertices and triangles. If
faces are assumed to be flat, you can collect all neighbour triangles
that share a common normal vector (within a specified tolerance) and
make a face from that. The boundaries of such faces become the edges.
However, if faces are not limited to being flat, e.g. as in the cylinder
body, you are out of luck. There is no easy way to recreate a non-flat
face from a discrete mesh consisting of (flat) triangles.

It is important to recognize that different CAD systems use very
different internal representations, so exchanging data between them
becomes a challenge. For example, the discrete mesh based OpenSCAD is
not likely to soon offer STEP file output.

Carsten Arnholm

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

Re: Breaking down a 3D model

gilboonet
In reply to this post by emanuel
Hello, D and E cannot be done using OpenSCAD, but if your output is saved to a .STL then you can import it. I have a node js script that maybe could help you, it reads a STL file then creates a .jscad file from it using polyhedron() and this function is not far from OpenSCAD polyhedron so it won't be hard to translate to OpenSCAD syntax.
https://github.com/gilboonet/auto_flattener/blob/master/stl2jscad.js 

Sent from the OpenSCAD mailing list archive at Nabble.com.

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

Re: Breaking down a 3D model

emanuel
In reply to this post by emanuel
Hi everybody,

Thanks for your feedback and ideas. The purpose of this process is to use the edges for machining with non conventional robots some wood panels. So, all the "exterior"faces will always be flat and I only need to recognize the lines and edges to machine. I guess that i will have to make an exception for the circles.

Anyway, for what I see I might need to export the difference result into stl and keep processing with other editor for my E and D steps.

Thanks everybody for your time.

Sent from the OpenSCAD mailing list archive at Nabble.com.

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