DM
Daniel Miner
Tue, Nov 22, 2022 10:55 PM
Ha! I got it. Pretty ugly, but it works.
Thanks for your help.
module screw_mount(pr=[[0,0,0,0,0,0]])
{
difference()
{ union ()
{ children();
for (x = pr)
{ translate ([x[0],x[1],x[2]]) rotate ([x[3],x[4],x[5]])
cylinder (d=10, h=2);
}
}
for (x = pr)
{ translate ([x[0],x[1],x[2]]) rotate ([x[3],x[4],x[5]])
translate ([0, 0, -4]) cylinder (d=6, h=8);
}
}
}
// mounting plate
union ()
{
screw_mount ([ [ 5, 5, 3, 0, 0, 0],
[25, 5, 3, 0, 0, 0],
[ 5, 25, 3, 0, 0, 0],
[25, 25, 3, 0, 0, 0] ]) cube ([30, 30, 3]);
}
On Tue, Nov 22, 2022 at 4:43 PM Daniel Miner dgminer@gmail.com wrote:
I'm getting closer. This works for ONE screw_mount but not two because
the plate (cube) gets added again and that fills any previous hole.
module screw_mount(pos=[0,0,0], rot=[0,0,0])
{
difference()
{ union ()
{ children();
translate (pos) rotate (rot) cylinder (d=10, h=2);
}
translate (pos) rotate (rot) translate ([0, 0, -4]) cylinder (d=6,
h=8);
}
}
// mounting plate
union ()
{
screw_mount ([ 5, 5, 3]) cube ([30, 30, 3]); // Only ONE is OK,
screw_mount ([25, 5, 3]) cube ([30, 30, 3]); // but not when adding
a second or more...
// screw_mount ([ 5, 25, 3]) cube ([30, 30, 3]);
// screw_mount ([25, 25, 3]) cube ([30, 30, 3]);
}
On Tue, Nov 22, 2022 at 4:36 PM Daniel Miner dgminer@gmail.com wrote:
I upgraded to version 2022.11.18 but I still don't get the subtract
(difference) when I execute.
At least I now believe I understand how children() works - at least
partially.
However it seems like your example does not do what I need to do.
I need to remove a cylinder from the cube but it ALSO needs to subtract
the cylinder from a previously existing object.
My initial code like this:
module washer (pos=[0,0,0], rot=[0,0,0], dia=9, hgt=2)
{ translate (pos)
rotate (rot)
translate ([-dia/2, -dia/2, 0])
cube ([dia, dia, hgt]); // was: cylinder(d=dia, h=hgt);
}
module screw_hole (pos=[0,0,0], rot=[0,0,0], dia=5, hgt=2)
{ translate (pos)
rotate (rot)
translate ([0, 0, -1]) cylinder(d=dia, h=hgt+2);
}
// mounting plate
difference()
{ union ()
{ cube ([30, 30, 3]); // holes also cut in this object
washer([ 5, 5, 3]);
washer([25, 5, 3]);
washer([ 5, 25, 3]);
washer([25, 25, 3]);
}
screw_hole([ 5, 5, 0], hgt=6);
screw_hole([25, 5, 0], hgt=6);
screw_hole([ 5, 25, 0], hgt=6);
screw_hole([25, 25, 0], hgt=6);
}
Note the screw_hole goes through the washer AND the 30x30x3 plate (cube).
On Tue, Nov 22, 2022 at 3:43 PM David Phillip Oster <
davidphilliposter@gmail.com> wrote:
I did run it. See attached. I'm running:
version 2021.01
Ha! I got it. Pretty ugly, but it works.
Thanks for your help.
module screw_mount(pr=[[0,0,0,0,0,0]])
{
difference()
{ union ()
{ children();
for (x = pr)
{ translate ([x[0],x[1],x[2]]) rotate ([x[3],x[4],x[5]])
cylinder (d=10, h=2);
}
}
for (x = pr)
{ translate ([x[0],x[1],x[2]]) rotate ([x[3],x[4],x[5]])
translate ([0, 0, -4]) cylinder (d=6, h=8);
}
}
}
// mounting plate
union ()
{
screw_mount ([ [ 5, 5, 3, 0, 0, 0],
[25, 5, 3, 0, 0, 0],
[ 5, 25, 3, 0, 0, 0],
[25, 25, 3, 0, 0, 0] ]) cube ([30, 30, 3]);
}
On Tue, Nov 22, 2022 at 4:43 PM Daniel Miner <dgminer@gmail.com> wrote:
> I'm getting closer. This works for ONE screw_mount but not two because
> the plate (cube) gets added again and that fills any previous hole.
>
> module screw_mount(pos=[0,0,0], rot=[0,0,0])
> {
> difference()
> { union ()
> { children();
> translate (pos) rotate (rot) cylinder (d=10, h=2);
> }
> translate (pos) rotate (rot) translate ([0, 0, -4]) cylinder (d=6,
> h=8);
> }
> }
>
> // mounting plate
> union ()
> {
> screw_mount ([ 5, 5, 3]) cube ([30, 30, 3]); // Only ONE is OK,
> screw_mount ([25, 5, 3]) cube ([30, 30, 3]); // but not when adding
> a second or more...
> // screw_mount ([ 5, 25, 3]) cube ([30, 30, 3]);
> // screw_mount ([25, 25, 3]) cube ([30, 30, 3]);
> }
>
> On Tue, Nov 22, 2022 at 4:36 PM Daniel Miner <dgminer@gmail.com> wrote:
>
>> I upgraded to version 2022.11.18 but I still don't get the subtract
>> (difference) when I execute.
>>
>> At least I now believe I understand how children() works - at least
>> partially.
>>
>> However it seems like your example does not do what I need to do.
>> I need to remove a cylinder from the cube but it ALSO needs to subtract
>> the cylinder from a previously existing object.
>> My initial code like this:
>>
>> module washer (pos=[0,0,0], rot=[0,0,0], dia=9, hgt=2)
>>> { translate (pos)
>>> rotate (rot)
>>> translate ([-dia/2, -dia/2, 0])
>>> cube ([dia, dia, hgt]); // was: cylinder(d=dia, h=hgt);
>>> }
>>>
>>> module screw_hole (pos=[0,0,0], rot=[0,0,0], dia=5, hgt=2)
>>> { translate (pos)
>>> rotate (rot)
>>> translate ([0, 0, -1]) cylinder(d=dia, h=hgt+2);
>>> }
>>>
>>> // mounting plate
>>> difference()
>>> { union ()
>>> { cube ([30, 30, 3]); // holes also cut in this object
>>> washer([ 5, 5, 3]);
>>> washer([25, 5, 3]);
>>> washer([ 5, 25, 3]);
>>> washer([25, 25, 3]);
>>> }
>>> screw_hole([ 5, 5, 0], hgt=6);
>>> screw_hole([25, 5, 0], hgt=6);
>>> screw_hole([ 5, 25, 0], hgt=6);
>>> screw_hole([25, 25, 0], hgt=6);
>>> }
>>>
>>
>> Note the screw_hole goes through the washer AND the 30x30x3 plate (cube).
>>
>> On Tue, Nov 22, 2022 at 3:43 PM David Phillip Oster <
>> davidphilliposter@gmail.com> wrote:
>>
>>> On Tue, Nov 22, 2022 at 1:41 PM Daniel Miner <dgminer@gmail.com> wrote:
>>>
>>>> I did run it. See attached. I'm running:
>>>>
>>>> version 2021.01
>>>>
>>> 2022.03.14 for me.
>>> _______________________________________________
>>> OpenSCAD mailing list
>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>
>>
DM
Daniel Miner
Tue, Nov 22, 2022 11:16 PM
Adrian,
I had not heard of BOSL2. Thanks for the pointer. It looks REALLY useful!
On Tue, Nov 22, 2022 at 4:55 PM Daniel Miner dgminer@gmail.com wrote:
Ha! I got it. Pretty ugly, but it works.
Thanks for your help.
module screw_mount(pr=[[0,0,0,0,0,0]])
{
difference()
{ union ()
{ children();
for (x = pr)
{ translate ([x[0],x[1],x[2]]) rotate ([x[3],x[4],x[5]])
cylinder (d=10, h=2);
}
}
for (x = pr)
{ translate ([x[0],x[1],x[2]]) rotate ([x[3],x[4],x[5]])
translate ([0, 0, -4]) cylinder (d=6, h=8);
}
}
}
// mounting plate
union ()
{
screw_mount ([ [ 5, 5, 3, 0, 0, 0],
[25, 5, 3, 0, 0, 0],
[ 5, 25, 3, 0, 0, 0],
[25, 25, 3, 0, 0, 0] ]) cube ([30, 30, 3]);
}
On Tue, Nov 22, 2022 at 4:43 PM Daniel Miner dgminer@gmail.com wrote:
I'm getting closer. This works for ONE screw_mount but not two because
the plate (cube) gets added again and that fills any previous hole.
module screw_mount(pos=[0,0,0], rot=[0,0,0])
{
difference()
{ union ()
{ children();
translate (pos) rotate (rot) cylinder (d=10, h=2);
}
translate (pos) rotate (rot) translate ([0, 0, -4]) cylinder
(d=6, h=8);
}
}
// mounting plate
union ()
{
screw_mount ([ 5, 5, 3]) cube ([30, 30, 3]); // Only ONE is OK,
screw_mount ([25, 5, 3]) cube ([30, 30, 3]); // but not when
adding a second or more...
// screw_mount ([ 5, 25, 3]) cube ([30, 30, 3]);
// screw_mount ([25, 25, 3]) cube ([30, 30, 3]);
}
On Tue, Nov 22, 2022 at 4:36 PM Daniel Miner dgminer@gmail.com wrote:
I upgraded to version 2022.11.18 but I still don't get the subtract
(difference) when I execute.
At least I now believe I understand how children() works - at least
partially.
However it seems like your example does not do what I need to do.
I need to remove a cylinder from the cube but it ALSO needs to subtract
the cylinder from a previously existing object.
My initial code like this:
module washer (pos=[0,0,0], rot=[0,0,0], dia=9, hgt=2)
{ translate (pos)
rotate (rot)
translate ([-dia/2, -dia/2, 0])
cube ([dia, dia, hgt]); // was: cylinder(d=dia, h=hgt);
}
module screw_hole (pos=[0,0,0], rot=[0,0,0], dia=5, hgt=2)
{ translate (pos)
rotate (rot)
translate ([0, 0, -1]) cylinder(d=dia, h=hgt+2);
}
// mounting plate
difference()
{ union ()
{ cube ([30, 30, 3]); // holes also cut in this object
washer([ 5, 5, 3]);
washer([25, 5, 3]);
washer([ 5, 25, 3]);
washer([25, 25, 3]);
}
screw_hole([ 5, 5, 0], hgt=6);
screw_hole([25, 5, 0], hgt=6);
screw_hole([ 5, 25, 0], hgt=6);
screw_hole([25, 25, 0], hgt=6);
}
Note the screw_hole goes through the washer AND the 30x30x3 plate (cube).
On Tue, Nov 22, 2022 at 3:43 PM David Phillip Oster <
davidphilliposter@gmail.com> wrote:
I did run it. See attached. I'm running:
version 2021.01
Adrian,
I had not heard of BOSL2. Thanks for the pointer. It looks REALLY useful!
On Tue, Nov 22, 2022 at 4:55 PM Daniel Miner <dgminer@gmail.com> wrote:
> Ha! I got it. Pretty ugly, but it works.
> Thanks for your help.
>
> module screw_mount(pr=[[0,0,0,0,0,0]])
> {
> difference()
> { union ()
> { children();
> for (x = pr)
> { translate ([x[0],x[1],x[2]]) rotate ([x[3],x[4],x[5]])
> cylinder (d=10, h=2);
> }
> }
> for (x = pr)
> { translate ([x[0],x[1],x[2]]) rotate ([x[3],x[4],x[5]])
> translate ([0, 0, -4]) cylinder (d=6, h=8);
> }
> }
> }
>
> // mounting plate
> union ()
> {
> screw_mount ([ [ 5, 5, 3, 0, 0, 0],
> [25, 5, 3, 0, 0, 0],
> [ 5, 25, 3, 0, 0, 0],
> [25, 25, 3, 0, 0, 0] ]) cube ([30, 30, 3]);
> }
>
>
> On Tue, Nov 22, 2022 at 4:43 PM Daniel Miner <dgminer@gmail.com> wrote:
>
>> I'm getting closer. This works for ONE screw_mount but not two because
>> the plate (cube) gets added again and that fills any previous hole.
>>
>> module screw_mount(pos=[0,0,0], rot=[0,0,0])
>> {
>> difference()
>> { union ()
>> { children();
>> translate (pos) rotate (rot) cylinder (d=10, h=2);
>> }
>> translate (pos) rotate (rot) translate ([0, 0, -4]) cylinder
>> (d=6, h=8);
>> }
>> }
>>
>> // mounting plate
>> union ()
>> {
>> screw_mount ([ 5, 5, 3]) cube ([30, 30, 3]); // Only ONE is OK,
>> screw_mount ([25, 5, 3]) cube ([30, 30, 3]); // but not when
>> adding a second or more...
>> // screw_mount ([ 5, 25, 3]) cube ([30, 30, 3]);
>> // screw_mount ([25, 25, 3]) cube ([30, 30, 3]);
>> }
>>
>> On Tue, Nov 22, 2022 at 4:36 PM Daniel Miner <dgminer@gmail.com> wrote:
>>
>>> I upgraded to version 2022.11.18 but I still don't get the subtract
>>> (difference) when I execute.
>>>
>>> At least I now believe I understand how children() works - at least
>>> partially.
>>>
>>> However it seems like your example does not do what I need to do.
>>> I need to remove a cylinder from the cube but it ALSO needs to subtract
>>> the cylinder from a previously existing object.
>>> My initial code like this:
>>>
>>> module washer (pos=[0,0,0], rot=[0,0,0], dia=9, hgt=2)
>>>> { translate (pos)
>>>> rotate (rot)
>>>> translate ([-dia/2, -dia/2, 0])
>>>> cube ([dia, dia, hgt]); // was: cylinder(d=dia, h=hgt);
>>>> }
>>>>
>>>> module screw_hole (pos=[0,0,0], rot=[0,0,0], dia=5, hgt=2)
>>>> { translate (pos)
>>>> rotate (rot)
>>>> translate ([0, 0, -1]) cylinder(d=dia, h=hgt+2);
>>>> }
>>>>
>>>> // mounting plate
>>>> difference()
>>>> { union ()
>>>> { cube ([30, 30, 3]); // holes also cut in this object
>>>> washer([ 5, 5, 3]);
>>>> washer([25, 5, 3]);
>>>> washer([ 5, 25, 3]);
>>>> washer([25, 25, 3]);
>>>> }
>>>> screw_hole([ 5, 5, 0], hgt=6);
>>>> screw_hole([25, 5, 0], hgt=6);
>>>> screw_hole([ 5, 25, 0], hgt=6);
>>>> screw_hole([25, 25, 0], hgt=6);
>>>> }
>>>>
>>>
>>> Note the screw_hole goes through the washer AND the 30x30x3 plate (cube).
>>>
>>> On Tue, Nov 22, 2022 at 3:43 PM David Phillip Oster <
>>> davidphilliposter@gmail.com> wrote:
>>>
>>>> On Tue, Nov 22, 2022 at 1:41 PM Daniel Miner <dgminer@gmail.com> wrote:
>>>>
>>>>> I did run it. See attached. I'm running:
>>>>>
>>>>> version 2021.01
>>>>>
>>>> 2022.03.14 for me.
>>>> _______________________________________________
>>>> OpenSCAD mailing list
>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>>
>>>
M
mikeonenine@web.de
Mon, Dec 26, 2022 6:11 AM
A bit late on this one perhaps, but I don’t check the forum regularly.
Don’t quite see what the fuss is about. Surely you only need “children” to arrange DIFFERENT objects, like for text. I have used children but don’t really understand how it works. This is how I would do it, with DM’s original for reference. The washers are $fn=3 to show orientation, though for round objects, it doesn’t matter.
BTW: It would be nice if “center=true” could be selected as default for a given script.
// Daniel Miner:
module screw_mount(pr=[[0,0,0]])
{
difference()
{
union ()
{
children();
for (x = pr)
{
translate ([x[0],x[1],x[2]+1])
cylinder (d=10, h=2, $fn=3); // washer
}}
for (x = pr)
{
translate ([x[0],x[1],x[2]])
translate ([0, 0, -4])
#cylinder (d=6, h=8); // hole
}}}
// mounting plate
union ()
{
screw_mount ([
[ 5, 5, 3],
[25, 5, 3],
[ 5, 25, 3],
[25, 25, 3] ])
cube ([30, 30, 3]); // plate
}
// If orientation doesn't matter, why not:
translate ([0, 0, 20])
{
difference()
{
union()
{
cube ([30, 30, 3], center=true); // plate
for (i=[0:90:270])
rotate ([0, 0, i])
translate ([10, 10, 3])
cylinder (d=10, h=2, $fn=3); // washer
}
for (i=[0:90:270])
rotate ([0, 0, i])
translate ([10, 10, -2])
#cylinder (d=6, h=8); // hole
}}
// For same orientation:
translate ([0, 0, 40])
for (i=[0:90:270])
rotate ([0, 0, i])
translate ([10, 10, 0])
rotate ([0, 0, -i]) // to correct orientation
cylinder (d=10, h=2, $fn=3); // washer
// Or just:
translate ([0, 0, 60])
for (i=[-10:20:10])
for (j=[-10:20:10])
translate ([i, j, 0])
cylinder (d=10, h=2, $fn=3); // washer
A bit late on this one perhaps, but I don’t check the forum regularly.
Don’t quite see what the fuss is about. Surely you only need “children” to arrange DIFFERENT objects, like for text. I have used children but don’t really understand how it works. This is how I would do it, with DM’s original for reference. The washers are $fn=3 to show orientation, though for round objects, it doesn’t matter.
BTW: It would be nice if “center=true” could be selected as default for a given script.
// Daniel Miner:
module screw_mount(pr=\[\[0,0,0\]\])
{
difference()
{
union ()
{
children();
for (x = pr)
{
translate (\[x\[0\],x\[1\],x\[2\]+1\])
cylinder (d=10, h=2, $fn=3); // washer
}}
for (x = pr)
{
translate (\[x\[0\],x\[1\],x\[2\]\])
translate (\[0, 0, -4\])
\#cylinder (d=6, h=8); // hole
}}}
// mounting plate
union ()
{
screw_mount (\[
\[ 5, 5, 3\],
\[25, 5, 3\],
\[ 5, 25, 3\],
\[25, 25, 3\] \])
cube (\[30, 30, 3\]); // plate
}
// If orientation doesn't matter, why not:
translate (\[0, 0, 20\])
{
difference()
{
union()
{
cube (\[30, 30, 3\], center=true); // plate
for (i=\[0:90:270\])
rotate (\[0, 0, i\])
translate (\[10, 10, 3\])
cylinder (d=10, h=2, $fn=3); // washer
}
for (i=\[0:90:270\])
rotate (\[0, 0, i\])
translate (\[10, 10, -2\])
\#cylinder (d=6, h=8); // hole
}}
// For same orientation:
translate (\[0, 0, 40\])
for (i=\[0:90:270\])
rotate (\[0, 0, i\])
translate (\[10, 10, 0\])
rotate (\[0, 0, -i\]) // to correct orientation
cylinder (d=10, h=2, $fn=3); // washer
// Or just:
translate (\[0, 0, 60\])
for (i=\[-10:20:10\])
for (j=\[-10:20:10\])
translate (\[i, j, 0\])
cylinder (d=10, h=2, $fn=3); // washer
GH
gene heskett
Mon, Dec 26, 2022 8:44 AM
A bit late on this one perhaps, but I don’t check the forum regularly.
Don’t quite see what the fuss is about. Surely you only need “children”
to arrange DIFFERENT objects, like for text. I have used children but
don’t really understand how it works. This is how I would do it, with
DM’s original for reference. The washers are $fn=3 to show orientation,
though for round objects, it doesn’t matter.
BTW: It would be nice if “center=true” could be selected as default for
a given script.
plus 1000, turn it false on a module by module basis if NOT wanted, save
a lot of typing at my 10-20.
[...]
Cheers, Gene Heskett.
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.
On 12/26/22 01:12, mikeonenine@web.de wrote:
> A bit late on this one perhaps, but I don’t check the forum regularly.
>
> Don’t quite see what the fuss is about. Surely you only need “children”
> to arrange DIFFERENT objects, like for text. I have used children but
> don’t really understand how it works. This is how I would do it, with
> DM’s original for reference. The washers are $fn=3 to show orientation,
> though for round objects, it doesn’t matter.
>
> BTW: It would be nice if “center=true” could be selected as default for
> a given script.
>
plus 1000, turn it false on a module by module basis if NOT wanted, save
a lot of typing at my 10-20.
[...]
Cheers, Gene Heskett.
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.
- Louis D. Brandeis
Genes Web page <http://geneslinuxbox.net:6309/>
AM
Adrian Mariano
Mon, Dec 26, 2022 2:43 PM
I think if you want center=true to be the default the way to do it is to
write yourself a new module, ccube() or something. Or you can use BOSL2
in which centered is the default for most objects. I suppose you could
write a new cube module that accepts a $ parameter for centering, which
would allow the requested behavior, but it seems like it could get
confusing.
On Mon, Dec 26, 2022 at 3:44 AM gene heskett gheskett@shentel.net wrote:
A bit late on this one perhaps, but I don’t check the forum regularly.
Don’t quite see what the fuss is about. Surely you only need “children”
to arrange DIFFERENT objects, like for text. I have used children but
don’t really understand how it works. This is how I would do it, with
DM’s original for reference. The washers are $fn=3 to show orientation,
though for round objects, it doesn’t matter.
BTW: It would be nice if “center=true” could be selected as default for
a given script.
plus 1000, turn it false on a module by module basis if NOT wanted, save
a lot of typing at my 10-20.
[...]
Cheers, Gene Heskett.
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
I think if you want center=true to be the default the way to do it is to
write yourself a new module, ccube() or something. Or you can use BOSL2
in which centered is the default for most objects. I suppose you could
write a new cube module that accepts a $ parameter for centering, which
would allow the requested behavior, but it seems like it could get
confusing.
On Mon, Dec 26, 2022 at 3:44 AM gene heskett <gheskett@shentel.net> wrote:
> On 12/26/22 01:12, mikeonenine@web.de wrote:
> > A bit late on this one perhaps, but I don’t check the forum regularly.
> >
> > Don’t quite see what the fuss is about. Surely you only need “children”
> > to arrange DIFFERENT objects, like for text. I have used children but
> > don’t really understand how it works. This is how I would do it, with
> > DM’s original for reference. The washers are $fn=3 to show orientation,
> > though for round objects, it doesn’t matter.
> >
> > BTW: It would be nice if “center=true” could be selected as default for
> > a given script.
> >
>
> plus 1000, turn it false on a module by module basis if NOT wanted, save
> a lot of typing at my 10-20.
>
> [...]
>
> Cheers, Gene Heskett.
> --
> "There are four boxes to be used in defense of liberty:
> soap, ballot, jury, and ammo. Please use in that order."
> -Ed Howdershelt (Author, 1940)
> If we desire respect for the law, we must first make the law respectable.
> - Louis D. Brandeis
> Genes Web page <http://geneslinuxbox.net:6309/>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>