

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
[hidden email]
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 < [hidden email]> 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
> [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

Administrator

In reply to this post by guaranteed_interwoven
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 extrudedprojection 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/_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
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!

Administrator

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/_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
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!


I think MIchael's code can be simplified by:
module cutCyl() { difference() { children(0); for(i=[1:1:$children1]) 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.
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.
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


I think now I have understood guaranteed_interwoven's construction. Very clever split.
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); linear_extrude(height=1000) for(i=[1:1:$children1]) children(i); translate(delta*t1) cutCyl() { c1(); c2(); c3();} translate(delta*t2) cutCyl() { c2(); c1(); c3();} translate(delta*t3) cutCyl() { c3(); c1(); c2();}
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


This post was updated on .
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:$children1]) 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]);
}
}
*/
// Does work
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]);
}
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/_______________________________________________
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Administrator

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/_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
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!

Administrator

In reply to this post by guaranteed_interwoven
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/_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
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!


This post was updated on .
Never mind, I think I have it solved:
$fn = 20;
delta = 0.5;
module gen_node(coords, d, h)
{
translate(coords)
cylinder(d1=d, d2=0, h=h);
}
data = [
[[4, 5, 0], 10, 10],
[[0, 0, 0], 10, 20],
[[5, 3, 0], 15, 10],
[[2, 6, 0], 15, 7],
[[2, 16, 0], 20, 20],
];
module embedded(target)
{
intersection()
{
gen_node(data[target][0], data[target][1], data[target][2]);
linear_extrude(height=1000)
projection()
{
difference()
{
gen_node(data[target][0], data[target][1], data[target][2]);
for(i=[0:len(data)])
{
if(i != target)
{
gen_node(data[i][0], data[i][1] + delta, data[i][2]);
}
}
}
}
}
}
for(i = [0:len(data)1])
{
embedded(i);
}
Having to embed the module call in the actual operation feels wrong to me,
but I don't think it's possible any other way.

Sent from: http://forum.openscad.org/_______________________________________________
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


I think I'm closer with:
$fn = 20;
delta = 0.5;
module gen_node(coords, d, h)
{
translate(coords)
cylinder(d1=d, d2=0, h=h);
}
data = [
[[4, 5, 0], 10, 10],
[[0, 0, 0], 10, 20],
[[5, 3, 0], 15, 10],
[[2, 6, 0], 15, 7],
[[2, 16, 0], 20, 20],
];
module embedded(target)
{
translate(data[target][0])
scale([(data[target][1]  delta)/data[target][1], (data[target][1] 
delta)/data[target][1], 1])
translate(data[target][0])
intersection()
{
gen_node(data[target][0], data[target][1], data[target][2]);
linear_extrude(height=1000)
projection()
{
difference()
{
gen_node(data[target][0], data[target][1], data[target][2]);
for(i=[0:len(data)])
{
if(i != target)
{
gen_node(data[i][0], data[i][1], data[i][2]);
}
}
}
}
}
}
for(i = [0:len(data)  1])
{
embedded(i);
}
</file/t2594/example_06.png>
This is at least consistent per edge, but not consistent per node or
globally.

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


I don't think that changing the cone shapes is a good idea to get the intended gap. And in some cases, there is no displacement of the embeded(target) which produces a good gap, for instance when one cone base is entirely inside another cone base. So, the general problem of finding appropriate small cone displacement to get gaps has no solution. To find a solution when one exists seems to be a hard problem.
I tried a heuristic strategy that does not work in many cases; change the main code to:
delta = 0.02;
for(i = [0:len(data)1]) { translate(displ(i)) embedded(i); }
where displ() is defined by:
[for(i=[0:len(l)1]) 1]*l; let( ctp = sum([for(di=data) di[0]])/len(data) )
BTW, two 'for' in your code have an improper last index and I got a warnings of undef values delivered to translate. Correction:
for(i=[0:len(data)1])
Em seg, 8 de jul de 2019 às 10:31, guaranteed_interwoven < [hidden email]> escreveu: I think I'm closer with:
$fn = 20;
delta = 0.5;
module gen_node(coords, d, h)
{
translate(coords)
cylinder(d1=d, d2=0, h=h);
}
data = [
[[4, 5, 0], 10, 10],
[[0, 0, 0], 10, 20],
[[5, 3, 0], 15, 10],
[[2, 6, 0], 15, 7],
[[2, 16, 0], 20, 20],
];
module embedded(target)
{
translate(data[target][0])
scale([(data[target][1]  delta)/data[target][1], (data[target][1] 
delta)/data[target][1], 1])
translate(data[target][0])
intersection()
{
gen_node(data[target][0], data[target][1], data[target][2]);
linear_extrude(height=1000)
projection()
{
difference()
{
gen_node(data[target][0], data[target][1], data[target][2]);
for(i=[0:len(data)])
{
if(i != target)
{
gen_node(data[i][0], data[i][1], data[i][2]);
}
}
}
}
}
}
for(i = [0:len(data)  1])
{
embedded(i);
}
</file/t2594/example_06.png>
This is at least consistent per edge, but not consistent per node or
globally.

Sent from: http://forum.openscad.org/
_______________________________________________
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


why not using offset() after the projection?
module embedded(target, delta)
{
intersection()
{
gen_node(data[target][0], data[target][1], data[target][2]);
linear_extrude(height=1000, convexity = 5)
offset(delta)
projection()
{
difference()
{
gen_node(data[target][0], data[target][1], data[target][2]);
for(i=[0:len(data)1])
{
if(i != target)
{
gen_node(data[i][0], data[i][1], data[i][2]);
}
}
}
}
}
}

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


A very effective method to create a kerf between the split parts. It works even when the center of a cone base is inside another cone base.
The linear_extrude height in embedded() could be the height of the target cone preferably with some extra and translated down to avoid zfighting in preview. Would not be better the convexity of linear_extrude be something like 2*len(data) ? why not using offset() after the projection?
module embedded(target, delta)
{
intersection()
{
gen_node(data[target][0], data[target][1], data[target][2]);
linear_extrude(height=1000, convexity = 5)
offset(delta)
projection()
{
difference()
{
gen_node(data[target][0], data[target][1], data[target][2]);
for(i=[0:len(data)1])
{
if(i != target)
{
gen_node(data[i][0], data[i][1], data[i][2]);
}
}
}
}
}
}

Sent from: http://forum.openscad.org/
_______________________________________________
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

