discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] reusing unions objects?

A
ajs
Sun, Mar 13, 2016 4:16 PM

Hello there, I have a similar OpenSCAD design, the way I handled it (just
yesterday!) was to export the "unit piece" to STL then I made a new model
that imported and translated the STL unit from within a loop.  It worked for
me but I really do not know if it shortened overall rendering time.  My unit
piece took about an hour to render, I put 20 of them together, I hit render
and went to bed.  They were done about 7 hours later....

--
View this message in context: http://forum.openscad.org/reusing-unions-objects-tp16464p16465.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Hello there, I have a similar OpenSCAD design, the way I handled it (just yesterday!) was to export the "unit piece" to STL then I made a new model that imported and translated the STL unit from within a loop. It worked for me but I really do not know if it shortened overall rendering time. My unit piece took about an hour to render, I put 20 of them together, I hit render and went to bed. They were done about 7 hours later.... -- View this message in context: http://forum.openscad.org/reusing-unions-objects-tp16464p16465.html Sent from the OpenSCAD mailing list archive at Nabble.com.
TP
Torsten Paul
Sun, Mar 13, 2016 7:15 PM

On 03/13/2016 05:04 PM, Antonin wrote:

Is there a way in Openscad to reuse an object that is made from the
union of many smaller objects without recalculating it every time?

While the application is running, the cache should take care of
this. Having a persistent cache that would be able to work across
application starts is on the to-do list.

As additional helper, it's possible to add render() calls in the
model. This might slow down the first preview but allow OpenSCAD
to cache that part of the model as render() basically forces the
actual mesh to be calculated at this point.

That said, OpenSCAD currently struggles with a huge amount of
small objects as the underlying calculation engine is very slow
for unions. In some cases it might help to find a different way
to generate the model geometry (e.g. using 2D + extrusion, or
directly generating more complex polyhedrons). But that's very
model specific, so it's not possible to give anything like:
"Do this change and that will fix all performance issues".

On 03/13/2016 05:16 PM, ajs wrote:

was to export the "unit piece" to STL then I made a new model
that imported and translated the STL unit from within a loop.

In some cases that can speed up the whole model generation,
depending on where the performance hit comes from. In most
cases it will not help much as it's often the top level
unions that have the most vertices and therefor also need
the most time.

Using STL as external cache also create a huge risk of issues
as the export sometimes creates STL files that cause problems
when importing those again.

ciao,
Torsten.

On 03/13/2016 05:04 PM, Antonin wrote: > Is there a way in Openscad to reuse an object that is made from the > union of many smaller objects without recalculating it every time? > While the application is running, the cache should take care of this. Having a persistent cache that would be able to work across application starts is on the to-do list. As additional helper, it's possible to add render() calls in the model. This might slow down the first preview but allow OpenSCAD to cache that part of the model as render() basically forces the actual mesh to be calculated at this point. That said, OpenSCAD currently struggles with a huge amount of small objects as the underlying calculation engine is very slow for unions. In some cases it might help to find a different way to generate the model geometry (e.g. using 2D + extrusion, or directly generating more complex polyhedrons). But that's very model specific, so it's not possible to give anything like: "Do this change and that will fix all performance issues". On 03/13/2016 05:16 PM, ajs wrote: > was to export the "unit piece" to STL then I made a new model > that imported and translated the STL unit from within a loop. > In some cases that can speed up the whole model generation, depending on where the performance hit comes from. In most cases it will not help much as it's often the top level unions that have the most vertices and therefor also need the most time. Using STL as external cache also create a huge risk of issues as the export sometimes creates STL files that cause problems when importing those again. ciao, Torsten.
CA
Carsten Arnholm
Sun, Mar 13, 2016 8:48 PM

On 13. mars 2016 20:15, Torsten Paul wrote:

That said, OpenSCAD currently struggles with a huge amount of
small objects as the underlying calculation engine is very slow
for unions. In some cases it might help to find a different way
to generate the model geometry (e.g. using 2D + extrusion, or
directly generating more complex polyhedrons).

I have experimented generating polyhedrons using carve and saving them
in OpenSCAD format (using .csg files). Theoretically, one could then do
in OpenSCAD:

module my_thing()
{
include <my_thing.csg>
}

my_thing();

This works just fine for display F5/F6/F12, but I am having no luck
doing any further boolean operations in OpenSCAD with my_thing(), even
though I know for sure the polyhedron contained is water tight.

i.e. the following typically fails:

difference()
{
my_thing();
cylinder(h=150,r=15,center=true);
}

This is different from doing the same difference in carve, which works.
I guess this problem reflects differences in requirements to polyhedrons
in OpenSCAD and carve.

If the above had worked in OpenSCAD, you would already have a
"persistent cache". I guess if you could export an OpenSCAD generated
polyhedrons (result of booleans) to a .csg or .scad file it might still
work.

Carsten Arnholm

On 13. mars 2016 20:15, Torsten Paul wrote: > That said, OpenSCAD currently struggles with a huge amount of > small objects as the underlying calculation engine is very slow > for unions. In some cases it might help to find a different way > to generate the model geometry (e.g. using 2D + extrusion, or > directly generating more complex polyhedrons). I have experimented generating polyhedrons using carve and saving them in OpenSCAD format (using .csg files). Theoretically, one could then do in OpenSCAD: module my_thing() { include <my_thing.csg> } my_thing(); This works just fine for display F5/F6/F12, but I am having no luck doing any further boolean operations in OpenSCAD with my_thing(), even though I know for sure the polyhedron contained is water tight. i.e. the following typically fails: difference() { my_thing(); cylinder(h=150,r=15,center=true); } This is different from doing the same difference in carve, which works. I guess this problem reflects differences in requirements to polyhedrons in OpenSCAD and carve. If the above had worked in OpenSCAD, you would already have a "persistent cache". I guess if you could export an OpenSCAD generated polyhedrons (result of booleans) to a .csg or .scad file it might still work. Carsten Arnholm