discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

What's the best way to accomplish splitting these elements?

G
guaranteed_interwoven
Fri, Jul 5, 2019 10:55 PM

Assuming I have:

translate([4, 5, 0])
cylinder(d1=10, d2=0, h=10);

cylinder(d1=10, d2=0, h=10);

translate([-5, 3, 0])
cylinder(d1=15, d2=0, h=10);

The result is this:

http://forum.openscad.org/file/t2594/example_01.png

This is just a simple example. I need to be able to split this up into
chunks for 3d printing. (It's for an art project)

Right now, I'm doing 160x160 mm regions (via intersection with cube).

However, this leaves very very ugly inorganic seams.

I would like to be able to do basically "intersections between cones
extruded along z axis", for lack of a better term.

Where two of the cones intersect, I would like to be able to "cut straight
down" to the xy plane.

The result for this example would be three separate objects, that get
"cylinderified" at the points where they intersect.

Does this make sense? I can provide a pencil sketch if that would be helpful
also.

This must be possible, I just am not skilled enough with openscad to achieve
this.

My thought is perhaps create 2d profile shapes from the intersection of the
cones, projected to an xy plane at z = 0. Then extrude those above the cone
max heights. Finally, one by one, do intersections of those extruded
projections with each cone. I'm not exactly sure how to do this though.

(In addition, what is the name of the operation I am trying to accomplish
here?)

Thank you so much!!

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

Assuming I have: translate([4, 5, 0]) cylinder(d1=10, d2=0, h=10); cylinder(d1=10, d2=0, h=10); translate([-5, 3, 0]) cylinder(d1=15, d2=0, h=10); The result is this: <http://forum.openscad.org/file/t2594/example_01.png> This is just a simple example. I need to be able to split this up into chunks for 3d printing. (It's for an art project) Right now, I'm doing 160x160 mm regions (via intersection with cube). However, this leaves very very ugly inorganic seams. I would like to be able to do basically "intersections between cones extruded along z axis", for lack of a better term. Where two of the cones intersect, I would like to be able to "cut straight down" to the xy plane. The result for this example would be three separate objects, that get "cylinderified" at the points where they intersect. Does this make sense? I can provide a pencil sketch if that would be helpful also. This must be possible, I just am not skilled enough with openscad to achieve this. My thought is perhaps create 2d profile shapes from the intersection of the cones, projected to an xy plane at z = 0. Then extrude those above the cone max heights. Finally, one by one, do intersections of those extruded projections with each cone. I'm not exactly sure how to do this though. (In addition, what is the name of the operation I am trying to accomplish here?) Thank you so much!! -- Sent from: http://forum.openscad.org/
G
GZ
Fri, Jul 5, 2019 11:36 PM

r u trying to do something like Tower of Hanoi?

On 7/5/19, guaranteed_interwoven kerryhall@gmail.com wrote:

Assuming I have:

translate([4, 5, 0])
cylinder(d1=10, d2=0, h=10);

cylinder(d1=10, d2=0, h=10);

translate([-5, 3, 0])
cylinder(d1=15, d2=0, h=10);

The result is this:

http://forum.openscad.org/file/t2594/example_01.png

This is just a simple example. I need to be able to split this up into
chunks for 3d printing. (It's for an art project)

Right now, I'm doing 160x160 mm regions (via intersection with cube).

However, this leaves very very ugly inorganic seams.

I would like to be able to do basically "intersections between cones
extruded along z axis", for lack of a better term.

Where two of the cones intersect, I would like to be able to "cut straight
down" to the xy plane.

The result for this example would be three separate objects, that get
"cylinderified" at the points where they intersect.

Does this make sense? I can provide a pencil sketch if that would be
helpful
also.

This must be possible, I just am not skilled enough with openscad to
achieve
this.

My thought is perhaps create 2d profile shapes from the intersection of the
cones, projected to an xy plane at z = 0. Then extrude those above the cone
max heights. Finally, one by one, do intersections of those extruded
projections with each cone. I'm not exactly sure how to do this though.

(In addition, what is the name of the operation I am trying to accomplish
here?)

Thank you so much!!

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


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

r u trying to do something like Tower of Hanoi? On 7/5/19, guaranteed_interwoven <kerryhall@gmail.com> wrote: > Assuming I have: > > translate([4, 5, 0]) > cylinder(d1=10, d2=0, h=10); > > cylinder(d1=10, d2=0, h=10); > > translate([-5, 3, 0]) > cylinder(d1=15, d2=0, h=10); > > The result is this: > > <http://forum.openscad.org/file/t2594/example_01.png> > > This is just a simple example. I need to be able to split this up into > chunks for 3d printing. (It's for an art project) > > Right now, I'm doing 160x160 mm regions (via intersection with cube). > > However, this leaves very very ugly inorganic seams. > > I would like to be able to do basically "intersections between cones > extruded along z axis", for lack of a better term. > > Where two of the cones intersect, I would like to be able to "cut straight > down" to the xy plane. > > The result for this example would be three separate objects, that get > "cylinderified" at the points where they intersect. > > Does this make sense? I can provide a pencil sketch if that would be > helpful > also. > > This must be possible, I just am not skilled enough with openscad to > achieve > this. > > My thought is perhaps create 2d profile shapes from the intersection of the > cones, projected to an xy plane at z = 0. Then extrude those above the cone > max heights. Finally, one by one, do intersections of those extruded > projections with each cone. I'm not exactly sure how to do this though. > > (In addition, what is the name of the operation I am trying to accomplish > here?) > > Thank you so much!! > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
M
MichaelAtOz
Fri, Jul 5, 2019 11:48 PM

guaranteed_interwoven wrote

(In addition, what is the name of the operation I am trying to accomplish
here?)

I don't think it has a name. Disaggregate?

guaranteed_interwoven wrote

My thought is perhaps create 2d profile shapes from the intersection of
the
cones, projected to an xy plane at z = 0. Then extrude those above the
cone
max heights. Finally, one by one, do intersections of those extruded
projections with each cone. I'm not exactly sure how to do this though.

That sounds about right, except you want to mix
a. difference() the extruded-projection from the outside cone(s).
b. intersection() the inner cone(s).

a.
http://forum.openscad.org/file/t359/Capture_cone_diff_a.jpg

Simple code:

module c1()  translate([4, 5, 0])
cylinder(d1=10, d2=0, h=10);
module c2()  cylinder(d1=10, d2=0, h=10);
module c3()  translate([-5, 3, 0])
cylinder(d1=15, d2=0, h=10);

difference() {
c3();
linear_extrude(height=11)
projection() {
union() {
intersection() {
c3();
c1();
}
c1();
}
}
}

Make it more generic:

module c1()  translate([4, 5, 0])
cylinder(d1=10, d2=0, h=10);
module c2()  cylinder(d1=10, d2=0, h=10);
module c3()  translate([-5, 3, 0])
cylinder(d1=15, d2=0, h=10);

module diff_extr_proj() {
difference() {
children(0);
linear_extrude(height=11)
projection() {
union() {
intersection() {
children(0);
children(1);
}
children(1);
}
}
}
}

diff_extr_proj() {
c3();
c1();
}

For b. just rearrange the above.


Admin - email* me if you need anything, or if I've done something stupid...

  • 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.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

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

guaranteed_interwoven wrote > (In addition, what is the name of the operation I am trying to accomplish > here?) I don't think it has a name. Disaggregate? guaranteed_interwoven wrote > My thought is perhaps create 2d profile shapes from the intersection of > the > cones, projected to an xy plane at z = 0. Then extrude those above the > cone > max heights. Finally, one by one, do intersections of those extruded > projections with each cone. I'm not exactly sure how to do this though. That sounds about right, except you want to mix a. difference() the extruded-projection from the outside cone(s). b. intersection() the inner cone(s). a. <http://forum.openscad.org/file/t359/Capture_cone_diff_a.jpg> Simple code: module c1() translate([4, 5, 0]) cylinder(d1=10, d2=0, h=10); module c2() cylinder(d1=10, d2=0, h=10); module c3() translate([-5, 3, 0]) cylinder(d1=15, d2=0, h=10); difference() { c3(); linear_extrude(height=11) projection() { union() { intersection() { c3(); c1(); } c1(); } } } Make it more generic: module c1() translate([4, 5, 0]) cylinder(d1=10, d2=0, h=10); module c2() cylinder(d1=10, d2=0, h=10); module c3() translate([-5, 3, 0]) cylinder(d1=15, d2=0, h=10); module diff_extr_proj() { difference() { children(0); linear_extrude(height=11) projection() { union() { intersection() { children(0); children(1); } children(1); } } } } diff_extr_proj() { c3(); c1(); } For b. just rearrange the above. ----- Admin - email* me if you need anything, or if I've done something stupid... * 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. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- Sent from: http://forum.openscad.org/
M
MichaelAtOz
Fri, Jul 5, 2019 11:51 PM

It will get tedious for more numerous objects.
There is probably some algorithm from set theory out there to help...


Admin - email* me if you need anything, or if I've done something stupid...

  • 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.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

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

It will get tedious for more numerous objects. There is probably some algorithm from set theory out there to help... ----- Admin - email* me if you need anything, or if I've done something stupid... * 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. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- Sent from: http://forum.openscad.org/
RP
Ronaldo Persiano
Sat, Jul 6, 2019 12:26 AM

I think MIchael's code can be simplified by:

module cutCyl() {
difference()
{
children(0);
for(i=[1:1:$children-1])
linear_extrude(height=1000)
projection() children(i);
}
}

cutCyl() { c1(); c2(); c3();} };

However, the union of that last object with c2() and c3() does not seem to
be the intended split of the cone union.

[image: CutCones.PNG]

The problem as I see is that the line of intersection of two cones is in a
vertical plane just in the very specific case where both cone have same
height and base diameter. In those case, a vertical plane can "organically"
split the twp cones.

I think MIchael's code can be simplified by: module cutCyl() { difference() { children(0); for(i=[1:1:$children-1]) linear_extrude(height=1000) projection() children(i); } } cutCyl() { c1(); c2(); c3();} }; However, the union of that last object with c2() and c3() does not seem to be the intended split of the cone union. [image: CutCones.PNG] The problem as I see is that the line of intersection of two cones is in a vertical plane just in the very specific case where both cone have same height and base diameter. In those case, a vertical plane can "organically" split the twp cones.
RP
Ronaldo Persiano
Sat, Jul 6, 2019 2:20 AM

I think now I have understood guaranteed_interwoven's construction. Very
clever split.

$fn = 20;

t1 = [4, 5, 0];
t2 = [0, 0, 0];
t3 = [-5, 3, 0];
delta = 0.02;

module c1() translate(t1) cylinder(d1=10, d2=0, h=10);
module c2() translate(t2) cylinder(d1=10, d2=0, h=10);
module c3() translate(t3) cylinder(d1=15, d2=0, h=10);

module cutCyl()
intersection() {
children(0);
linear_extrude(height=1000)
projection()
difference() {
children(0);
for(i=[1:1:$children-1]) children(i);
}
}

translate(deltat1) cutCyl() { c1(); c2(); c3();}
translate(delta
t2) cutCyl() { c2(); c1(); c3();}
translate(delta*t3) cutCyl() { c3(); c1(); c2();}

[image: CutCones.PNG]

I think now I have understood guaranteed_interwoven's construction. Very clever split. $fn = 20; t1 = [4, 5, 0]; t2 = [0, 0, 0]; t3 = [-5, 3, 0]; delta = 0.02; module c1() translate(t1) cylinder(d1=10, d2=0, h=10); module c2() translate(t2) cylinder(d1=10, d2=0, h=10); module c3() translate(t3) cylinder(d1=15, d2=0, h=10); module cutCyl() intersection() { children(0); linear_extrude(height=1000) projection() difference() { children(0); for(i=[1:1:$children-1]) children(i); } } translate(delta*t1) cutCyl() { c1(); c2(); c3();} translate(delta*t2) cutCyl() { c2(); c1(); c3();} translate(delta*t3) cutCyl() { c3(); c1(); c2();} [image: CutCones.PNG]
G
guaranteed_interwoven
Mon, Jul 8, 2019 6:10 AM

You folks are my heroes :)

This last one is exactly what I needed! Especially with the delta in there,
that is very slick.

In terms of iterating over each object and exporting, I have been using bash
for that, so no worries there. (Unless there is a better way I'm not aware
of.)

This is perfect! Thank you so much!!

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

You folks are my heroes :) This last one is exactly what I needed! Especially with the delta in there, that is very slick. In terms of iterating over each object and exporting, I have been using bash for that, so no worries there. (Unless there is a better way I'm not aware of.) This is perfect! Thank you so much!! -- Sent from: http://forum.openscad.org/
G
guaranteed_interwoven
Mon, Jul 8, 2019 7:00 AM

My apologies, one last question here.

I'm trying to do one last generifying step, to extend to an arbitrary number
of objects.

$fn = 20;

module gen_node(coords, d, h)
{
translate(coords)
cylinder(d1=d, d2=0, h=h);
}

module cutCyl()
{
intersection()
{
children(0);
linear_extrude(height=1000)
projection()
{
difference()
{
children(0);
for(i=[1:1:$children-1]) children(i);
}
}
}
}

data = [
[[4, 5, 0], 10, 10],
[[0, 0, 0], 10, 20],
[[-5, 3, 0], 15, 10],
[[-2, 6, 0], 15, 7],
];

/* Does not work:
cutCyl()
{
for (i = [0: len(data)])
{
gen_node(data[i][0], data[i][1], data[i][2], data[i][3]);
}
}
*/

// Does work
cutCyl()
{
gen_node(data[0][0], data[0][1], data[0][2], data[0][3]);
gen_node(data[1][0], data[1][1], data[1][2], data[1][3]);
gen_node(data[2][0], data[2][1], data[2][2], data[2][3]);
gen_node(data[3][0], data[3][1], data[3][2], data[3][3]);
}

I did notice that the delta doesn't work for certain shapes. The delta is a
good idea I think to guarantee that the pieces fit together once printed.
What I can do is that the "subtracting" objects can just have their
diameters increased by that delta, which I think will work nicely.

So I basically want to do a for loop from within cutCyl, but the actual for
loop version doesn't work. I had a suspicion that the for loop was affecting
the object tree, but I'm not exactly sure how. So I tried to unroll the for
loop manually, and this does work.

So my question is now "How do I modify cutCyl so that it can accept the for
looped version here?"

(As an aside, I have been writing openscad code the same way I am used to
writing C, with the opening braces on the next line. However, I defer to the
style guide of the language of course, is this generally frowned upon?
Should I adopt the style I have seen in examples in this thread?)

Thank you!!

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

My apologies, one last question here. I'm trying to do one last generifying step, to extend to an arbitrary number of objects. $fn = 20; module gen_node(coords, d, h) { translate(coords) cylinder(d1=d, d2=0, h=h); } module cutCyl() { intersection() { children(0); linear_extrude(height=1000) projection() { difference() { children(0); for(i=[1:1:$children-1]) children(i); } } } } data = [ [[4, 5, 0], 10, 10], [[0, 0, 0], 10, 20], [[-5, 3, 0], 15, 10], [[-2, 6, 0], 15, 7], ]; /* Does not work: cutCyl() { for (i = [0: len(data)]) { gen_node(data[i][0], data[i][1], data[i][2], data[i][3]); } } */ // Does work cutCyl() { gen_node(data[0][0], data[0][1], data[0][2], data[0][3]); gen_node(data[1][0], data[1][1], data[1][2], data[1][3]); gen_node(data[2][0], data[2][1], data[2][2], data[2][3]); gen_node(data[3][0], data[3][1], data[3][2], data[3][3]); } I did notice that the delta doesn't work for certain shapes. The delta is a good idea I think to guarantee that the pieces fit together once printed. What I can do is that the "subtracting" objects can just have their diameters increased by that delta, which I think will work nicely. So I basically want to do a for loop from within cutCyl, but the actual for loop version doesn't work. I had a suspicion that the for loop was affecting the object tree, but I'm not exactly sure how. So I tried to unroll the for loop manually, and this does work. So my question is now "How do I modify cutCyl so that it can accept the for looped version here?" (As an aside, I have been writing openscad code the same way I am used to writing C, with the opening braces on the next line. However, I defer to the style guide of the language of course, is this generally frowned upon? Should I adopt the style I have seen in examples in this thread?) Thank you!! -- Sent from: http://forum.openscad.org/
M
MichaelAtOz
Mon, Jul 8, 2019 8:25 AM

for() has an implicit union() so only returns one object.
So children() doesn't see each iteration if the for().


Admin - email* me if you need anything, or if I've done something stupid...

  • 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.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

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

for() has an implicit union() so only returns one object. So children() doesn't see each iteration if the for(). ----- Admin - email* me if you need anything, or if I've done something stupid... * 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. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- Sent from: http://forum.openscad.org/
M
MichaelAtOz
Mon, Jul 8, 2019 8:30 AM

guaranteed_interwoven wrote

(As an aside, I have been writing openscad code the same way I am used to
writing C, with the opening braces on the next line. However, I defer to
the
style guide of the language of course, is this generally frowned upon?
Should I adopt the style I have seen in examples in this thread?)

Personal taste. I like saving vertical space in the editor.
Your way allows the command to be commented out for debugging. e.g.

//cutCyl()
{
gen_node(data[0][0], data[0][1], data[0][2]);
gen_node(data[1][0], data[1][1], data[1][2]);
gen_node(data[2][0], data[2][1], data[2][2]);
gen_node(data[3][0], data[3][1], data[3][2]);
}


Admin - email* me if you need anything, or if I've done something stupid...

  • 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.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

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

guaranteed_interwoven wrote > (As an aside, I have been writing openscad code the same way I am used to > writing C, with the opening braces on the next line. However, I defer to > the > style guide of the language of course, is this generally frowned upon? > Should I adopt the style I have seen in examples in this thread?) Personal taste. I like saving vertical space in the editor. Your way allows the command to be commented out for debugging. e.g. //cutCyl() { gen_node(data[0][0], data[0][1], data[0][2]); gen_node(data[1][0], data[1][1], data[1][2]); gen_node(data[2][0], data[2][1], data[2][2]); gen_node(data[3][0], data[3][1], data[3][2]); } ----- Admin - email* me if you need anything, or if I've done something stupid... * 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. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- Sent from: http://forum.openscad.org/