K
kdtop
Sun, Nov 29, 2020 4:35 PM
Native OpenSCAD includes the ability to place a cube based on a center point,
rather than based on one corner. E.g.
*cube([10,10,10]);*
http://forum.openscad.org/file/t2397/Capture1.png
vs
*cube([10,10,10], center=true);*
http://forum.openscad.org/file/t2397/Capture2.png
I find, however, that I often need to center the cube in just one dimension,
for example y axis only. Thus I sometimes write the following code to
extend cube centering functionality:
*
module cube2(size, center=[0,0,0]) {
translate([-(size.x/2)*center.x, -(size.y/2)*center.y,
-(size.z/2)*center.z])
cube(size);
} *
Examples of use:
*TestSize = [10,10,10];
color("red") cube2(TestSize, center=[0,1,0]);
color("blue") cube2(TestSize, center=[1,0,1]);*
http://forum.openscad.org/file/t2397/Capture3.png
Feature request:
I would like to see this implemented into native OpenSCAD. Thus the
center parameter would be overloaded as follows:
-- If a boolean (true / false) is passed, then it would work as previously.
-- if an expression that evaluates to 0, then interpreted as false, if any
other number, then as true. (currently passing in "1" is interpreted as
false.)
-- if a vector ([1,1,1]) is passed, then each element is interpreted as
boolean for each dimension. E.g. center.x would be parameter for centering
in x axis, and so on for .y and .z
I suspect this would be a relatively easy bit of code to implement.
Yes, I can just make my own custom library and include this for my own use.
But does anyone else think this would be a helpful addition to the native
language?
Thanks
Kevin T
--
Sent from: http://forum.openscad.org/
Native OpenSCAD includes the ability to place a cube based on a center point,
rather than based on one corner. E.g.
*cube([10,10,10]);*
<http://forum.openscad.org/file/t2397/Capture1.png>
vs
*cube([10,10,10], center=true);*
<http://forum.openscad.org/file/t2397/Capture2.png>
I find, however, that I often need to center the cube in just one dimension,
for example y axis only. Thus I sometimes write the following code to
extend cube centering functionality:
*
module cube2(size, center=[0,0,0]) {
translate([-(size.x/2)*center.x, -(size.y/2)*center.y,
-(size.z/2)*center.z])
cube(size);
} *
Examples of use:
*TestSize = [10,10,10];
color("red") cube2(TestSize, center=[0,1,0]);
color("blue") cube2(TestSize, center=[1,0,1]);*
<http://forum.openscad.org/file/t2397/Capture3.png>
Feature request:
I would like to see this implemented into native OpenSCAD. Thus the
center parameter would be overloaded as follows:
-- If a boolean (true / false) is passed, then it would work as previously.
-- if an expression that evaluates to 0, then interpreted as false, if any
other number, then as true. (currently passing in "1" is interpreted as
false.)
-- if a vector ([1,1,1]) is passed, then each element is interpreted as
boolean for each dimension. E.g. center.x would be parameter for centering
in x axis, and so on for .y and .z
I suspect this would be a relatively easy bit of code to implement.
Yes, I can just make my own custom library and include this for my own use.
But does anyone else think this would be a helpful addition to the native
language?
Thanks
Kevin T
--
Sent from: http://forum.openscad.org/
A
adrianv
Sun, Nov 29, 2020 4:54 PM
Much more useful extensions have been rejected as unnecessary complication,
so I doubt you'll see this in native OpenSCAD. Especially since it is easy
to do what you want with user-written modules...or many would argue by just
sticking a translate() in front of your cube.
The BOSL2 library supports this via a syntax like:
cuboid([10,10,10], anchor=LEFT)
which places the center of the left side of the cube on the origin, or
equivalently anchor=[-1,0,0]. (So that's centered in y and z.)
You could use anchor=[-1,0,-1] or equivalently anchor=LEFT+BOTTOM to center
on Y only.
kdtop wrote
Native OpenSCAD includes the ability to place a cube based on a center
point,
rather than based on one corner. E.g.
*cube([10,10,10]);*
<http://forum.openscad.org/file/t2397/Capture1.png>
vs
*cube([10,10,10], center=true);*
<http://forum.openscad.org/file/t2397/Capture2.png>
I find, however, that I often need to center the cube in just one
dimension,
for example y axis only.
Much more useful extensions have been rejected as unnecessary complication,
so I doubt you'll see this in native OpenSCAD. Especially since it is easy
to do what you want with user-written modules...or many would argue by just
sticking a translate() in front of your cube.
The BOSL2 library supports this via a syntax like:
cuboid([10,10,10], anchor=LEFT)
which places the center of the left side of the cube on the origin, or
equivalently anchor=[-1,0,0]. (So that's centered in y and z.)
You could use anchor=[-1,0,-1] or equivalently anchor=LEFT+BOTTOM to center
on Y only.
kdtop wrote
> Native OpenSCAD includes the ability to place a cube based on a center
> point,
> rather than based on one corner. E.g.
>
> *cube([10,10,10]);*
>
> <http://forum.openscad.org/file/t2397/Capture1.png>
>
> vs
>
> *cube([10,10,10], center=true);*
>
> <http://forum.openscad.org/file/t2397/Capture2.png>
>
> I find, however, that I often need to center the cube in just one
> dimension,
> for example y axis only.
--
Sent from: http://forum.openscad.org/
AC
A. Craig West
Sun, Nov 29, 2020 4:55 PM
It seems useful, but also pretty trivial to implement in userspace. The
cube I use in most of my code specifies x, y, and z offsets for the faces.
There are any number of ways to specify a cube, and it is difficult to
justify any particular ones as being necessary
On Sun, 29 Nov 2020, 11:36 kdtop, kdtop3@gmail.com wrote:
Native OpenSCAD includes the ability to place a cube based on a center
point,
rather than based on one corner. E.g.
*cube([10,10,10]);*
http://forum.openscad.org/file/t2397/Capture1.png
vs
*cube([10,10,10], center=true);*
http://forum.openscad.org/file/t2397/Capture2.png
I find, however, that I often need to center the cube in just one
dimension,
for example y axis only. Thus I sometimes write the following code to
extend cube centering functionality:
*
module cube2(size, center=[0,0,0]) {
translate([-(size.x/2)*center.x, -(size.y/2)*center.y,
-(size.z/2)*center.z])
cube(size);
} *
Examples of use:
*TestSize = [10,10,10];
color("red") cube2(TestSize, center=[0,1,0]);
color("blue") cube2(TestSize, center=[1,0,1]);*
http://forum.openscad.org/file/t2397/Capture3.png
Feature request:
I would like to see this implemented into native OpenSCAD. Thus the
center parameter would be overloaded as follows:
-- If a boolean (true / false) is passed, then it would work as
previously.
-- if an expression that evaluates to 0, then interpreted as false, if any
other number, then as true. (currently passing in "1" is interpreted as
false.)
-- if a vector ([1,1,1]) is passed, then each element is interpreted as
boolean for each dimension. E.g. center.x would be parameter for centering
in x axis, and so on for .y and .z
I suspect this would be a relatively easy bit of code to implement.
Yes, I can just make my own custom library and include this for my own
use.
But does anyone else think this would be a helpful addition to the native
language?
Thanks
Kevin T
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
It seems useful, but also pretty trivial to implement in userspace. The
cube I use in most of my code specifies x, y, and z offsets for the faces.
There are any number of ways to specify a cube, and it is difficult to
justify any particular ones as being necessary
On Sun, 29 Nov 2020, 11:36 kdtop, <kdtop3@gmail.com> wrote:
> Native OpenSCAD includes the ability to place a cube based on a center
> point,
> rather than based on one corner. E.g.
>
> *cube([10,10,10]);*
>
> <http://forum.openscad.org/file/t2397/Capture1.png>
>
> vs
>
> *cube([10,10,10], center=true);*
>
> <http://forum.openscad.org/file/t2397/Capture2.png>
>
> I find, however, that I often need to center the cube in just one
> dimension,
> for example y axis only. Thus I sometimes write the following code to
> extend cube centering functionality:
> *
> module cube2(size, center=[0,0,0]) {
> translate([-(size.x/2)*center.x, -(size.y/2)*center.y,
> -(size.z/2)*center.z])
> cube(size);
> } *
>
> Examples of use:
>
> *TestSize = [10,10,10];
> color("red") cube2(TestSize, center=[0,1,0]);
> color("blue") cube2(TestSize, center=[1,0,1]);*
>
> <http://forum.openscad.org/file/t2397/Capture3.png>
>
> Feature request:
> I would like to see this implemented into native OpenSCAD. Thus the
> center parameter would be overloaded as follows:
> -- If a boolean (true / false) is passed, then it would work as
> previously.
> -- if an expression that evaluates to 0, then interpreted as false, if any
> other number, then as true. (currently passing in "1" is interpreted as
> false.)
> -- if a vector ([1,1,1]) is passed, then each element is interpreted as
> boolean for each dimension. E.g. center.x would be parameter for centering
> in x axis, and so on for .y and .z
>
> I suspect this would be a relatively easy bit of code to implement.
>
> Yes, I can just make my own custom library and include this for my own
> use.
> But does anyone else think this would be a helpful addition to the native
> language?
>
> Thanks
> Kevin T
>
>
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
JL
Jean-Paul Louis
Sun, Nov 29, 2020 4:59 PM
Kevin,What you're asking is the perfect example of feature creep. A feature that does not add any value to the existing code. If you really want it, create a module that will do what you want, and don't bloat a good feature with useless stuff.
Just my two cents,Jean-Paul N1JPL
Sent from Yahoo Mail on Android
On Sun, Nov 29, 2020 at 11:36 AM, kdtopkdtop3@GMAIL.COM wrote: Native OpenSCAD includes the ability to place a cube based on a center point,
rather than based on one corner. E.g.
cube([10,10,10]);
http://forum.openscad.org/file/t2397/Capture1.png
vs
cube([10,10,10], center=true);
http://forum.openscad.org/file/t2397/Capture2.png
I find, however, that I often need to center the cube in just one dimension,
for example y axis only. Thus I sometimes write the following code to
extend cube centering functionality:
*
module cube2(size, center=[0,0,0]) {
translate([-(size.x/2)*center.x, -(size.y/2)*center.y,
-(size.z/2)*center.z])
cube(size);
} *
Examples of use:
TestSize = [10,10,10];
color("red") cube2(TestSize, center=[0,1,0]);
color("blue") cube2(TestSize, center=[1,0,1]);
http://forum.openscad.org/file/t2397/Capture3.png
Feature request:
I would like to see this implemented into native OpenSCAD. Thus the
center parameter would be overloaded as follows:
-- If a boolean (true / false) is passed, then it would work as previously.
-- if an expression that evaluates to 0, then interpreted as false, if any
other number, then as true. (currently passing in "1" is interpreted as
false.)
-- if a vector ([1,1,1]) is passed, then each element is interpreted as
boolean for each dimension. E.g. center.x would be parameter for centering
in x axis, and so on for .y and .z
I suspect this would be a relatively easy bit of code to implement.
Yes, I can just make my own custom library and include this for my own use.
But does anyone else think this would be a helpful addition to the native
language?
Thanks
Kevin T
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Kevin,What you're asking is the perfect example of feature creep. A feature that does not add any value to the existing code. If you really want it, create a module that will do what you want, and don't bloat a good feature with useless stuff.
Just my two cents,Jean-Paul N1JPL
Sent from Yahoo Mail on Android
On Sun, Nov 29, 2020 at 11:36 AM, kdtop<kdtop3@GMAIL.COM> wrote: Native OpenSCAD includes the ability to place a cube based on a center point,
rather than based on one corner. E.g.
*cube([10,10,10]);*
<http://forum.openscad.org/file/t2397/Capture1.png>
vs
*cube([10,10,10], center=true);*
<http://forum.openscad.org/file/t2397/Capture2.png>
I find, however, that I often need to center the cube in just one dimension,
for example y axis only. Thus I sometimes write the following code to
extend cube centering functionality:
*
module cube2(size, center=[0,0,0]) {
translate([-(size.x/2)*center.x, -(size.y/2)*center.y,
-(size.z/2)*center.z])
cube(size);
} *
Examples of use:
*TestSize = [10,10,10];
color("red") cube2(TestSize, center=[0,1,0]);
color("blue") cube2(TestSize, center=[1,0,1]);*
<http://forum.openscad.org/file/t2397/Capture3.png>
Feature request:
I would like to see this implemented into native OpenSCAD. Thus the
center parameter would be overloaded as follows:
-- If a boolean (true / false) is passed, then it would work as previously.
-- if an expression that evaluates to 0, then interpreted as false, if any
other number, then as true. (currently passing in "1" is interpreted as
false.)
-- if a vector ([1,1,1]) is passed, then each element is interpreted as
boolean for each dimension. E.g. center.x would be parameter for centering
in x axis, and so on for .y and .z
I suspect this would be a relatively easy bit of code to implement.
Yes, I can just make my own custom library and include this for my own use.
But does anyone else think this would be a helpful addition to the native
language?
Thanks
Kevin T
--
Sent from: http://forum.openscad.org/
_______________________________________________
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
NH
nop head
Sun, Nov 29, 2020 5:02 PM
I often want the XY centred and not Z, or perhaps vice versa. That can be
done by linear_extude() square() because you get two separate center
parameters.
On Sun, 29 Nov 2020 at 16:59, Jean-Paul Louis via Discuss <
discuss@lists.openscad.org> wrote:
Kevin,
What you're asking is the perfect example of feature creep. A feature that
does not add any value to the existing code.
If you really want it, create a module that will do what you want, and
don't bloat a good feature with useless stuff.
Just my two cents,
Jean-Paul
N1JPL
Sent from Yahoo Mail on Android
https://go.onelink.me/107872968?pid=InProduct&c=Global_Internal_YGrowth_AndroidEmailSig__AndroidUsers&af_wl=ym&af_sub1=Internal&af_sub2=Global_YGrowth&af_sub3=EmailSignature
On Sun, Nov 29, 2020 at 11:36 AM, kdtop
kdtop3@GMAIL.COM wrote:
Native OpenSCAD includes the ability to place a cube based on a center
point,
rather than based on one corner. E.g.
*cube([10,10,10]);*
http://forum.openscad.org/file/t2397/Capture1.png
vs
*cube([10,10,10], center=true);*
http://forum.openscad.org/file/t2397/Capture2.png
I find, however, that I often need to center the cube in just one
dimension,
for example y axis only. Thus I sometimes write the following code to
extend cube centering functionality:
*
module cube2(size, center=[0,0,0]) {
translate([-(size.x/2)*center.x, -(size.y/2)*center.y,
-(size.z/2)*center.z])
cube(size);
} *
Examples of use:
*TestSize = [10,10,10];
color("red") cube2(TestSize, center=[0,1,0]);
color("blue") cube2(TestSize, center=[1,0,1]);*
http://forum.openscad.org/file/t2397/Capture3.png
Feature request:
I would like to see this implemented into native OpenSCAD. Thus the
center parameter would be overloaded as follows:
-- If a boolean (true / false) is passed, then it would work as
previously.
-- if an expression that evaluates to 0, then interpreted as false, if any
other number, then as true. (currently passing in "1" is interpreted as
false.)
-- if a vector ([1,1,1]) is passed, then each element is interpreted as
boolean for each dimension. E.g. center.x would be parameter for centering
in x axis, and so on for .y and .z
I suspect this would be a relatively easy bit of code to implement.
Yes, I can just make my own custom library and include this for my own
use.
But does anyone else think this would be a helpful addition to the native
language?
Thanks
Kevin T
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
I often want the XY centred and not Z, or perhaps vice versa. That can be
done by linear_extude() square() because you get two separate center
parameters.
On Sun, 29 Nov 2020 at 16:59, Jean-Paul Louis via Discuss <
discuss@lists.openscad.org> wrote:
> Kevin,
> What you're asking is the perfect example of feature creep. A feature that
> does not add any value to the existing code.
> If you really want it, create a module that will do what you want, and
> don't bloat a good feature with useless stuff.
>
> Just my two cents,
> Jean-Paul
> N1JPL
>
> Sent from Yahoo Mail on Android
> <https://go.onelink.me/107872968?pid=InProduct&c=Global_Internal_YGrowth_AndroidEmailSig__AndroidUsers&af_wl=ym&af_sub1=Internal&af_sub2=Global_YGrowth&af_sub3=EmailSignature>
>
> On Sun, Nov 29, 2020 at 11:36 AM, kdtop
> <kdtop3@GMAIL.COM> wrote:
> Native OpenSCAD includes the ability to place a cube based on a center
> point,
> rather than based on one corner. E.g.
>
> *cube([10,10,10]);*
>
> <http://forum.openscad.org/file/t2397/Capture1.png>
>
> vs
>
> *cube([10,10,10], center=true);*
>
> <http://forum.openscad.org/file/t2397/Capture2.png>
>
> I find, however, that I often need to center the cube in just one
> dimension,
> for example y axis only. Thus I sometimes write the following code to
> extend cube centering functionality:
> *
> module cube2(size, center=[0,0,0]) {
> translate([-(size.x/2)*center.x, -(size.y/2)*center.y,
> -(size.z/2)*center.z])
> cube(size);
> } *
>
> Examples of use:
>
> *TestSize = [10,10,10];
> color("red") cube2(TestSize, center=[0,1,0]);
> color("blue") cube2(TestSize, center=[1,0,1]);*
>
> <http://forum.openscad.org/file/t2397/Capture3.png>
>
> Feature request:
> I would like to see this implemented into native OpenSCAD. Thus the
> center parameter would be overloaded as follows:
> -- If a boolean (true / false) is passed, then it would work as
> previously.
> -- if an expression that evaluates to 0, then interpreted as false, if any
> other number, then as true. (currently passing in "1" is interpreted as
> false.)
> -- if a vector ([1,1,1]) is passed, then each element is interpreted as
> boolean for each dimension. E.g. center.x would be parameter for centering
> in x axis, and so on for .y and .z
>
> I suspect this would be a relatively easy bit of code to implement.
>
> Yes, I can just make my own custom library and include this for my own
> use.
> But does anyone else think this would be a helpful addition to the native
> language?
>
> Thanks
> Kevin T
>
>
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
RW
Rob Ward
Sun, Nov 29, 2020 5:20 PM
It is also the perfect example of why the "OpenSCAD language - replace it with Python3" discussion thread is worth reading.
Cheers, RobW
On 30 November 2020 3:59:04 am AEDT, Jean-Paul Louis via Discuss discuss@lists.openscad.org wrote:
Kevin,What you're asking is the perfect example of feature creep. A
feature that does not add any value to the existing code. If you really
want it, create a module that will do what you want, and don't bloat a
good feature with useless stuff.
Just my two cents,Jean-Paul N1JPL
Sent from Yahoo Mail on Android
On Sun, Nov 29, 2020 at 11:36 AM, kdtopkdtop3@GMAIL.COM wrote:
Native OpenSCAD includes the ability to place a cube based on a center
point,
rather than based on one corner. E.g.
cube([10,10,10]);
http://forum.openscad.org/file/t2397/Capture1.png
vs
cube([10,10,10], center=true);
http://forum.openscad.org/file/t2397/Capture2.png
I find, however, that I often need to center the cube in just one
dimension,
for example y axis only. Thus I sometimes write the following code to
extend cube centering functionality:
*
module cube2(size, center=[0,0,0]) {
translate([-(size.x/2)*center.x, -(size.y/2)*center.y,
-(size.z/2)*center.z])
cube(size);
} *
Examples of use:
TestSize = [10,10,10];
color("red") cube2(TestSize, center=[0,1,0]);
color("blue") cube2(TestSize, center=[1,0,1]);
http://forum.openscad.org/file/t2397/Capture3.png
Feature request:
I would like to see this implemented into native OpenSCAD. Thus the
center parameter would be overloaded as follows:
-- If a boolean (true / false) is passed, then it would work as
previously.
-- if an expression that evaluates to 0, then interpreted as false, if
any
other number, then as true. (currently passing in "1" is interpreted
as
false.)
-- if a vector ([1,1,1]) is passed, then each element is interpreted as
boolean for each dimension. E.g. center.x would be parameter for
centering
in x axis, and so on for .y and .z
I suspect this would be a relatively easy bit of code to implement.
Yes, I can just make my own custom library and include this for my own
use.
But does anyone else think this would be a helpful addition to the
native
language?
Thanks
Kevin T
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
It is also the perfect example of why the "OpenSCAD language - replace it with Python3" discussion thread is worth reading.
Cheers, RobW
On 30 November 2020 3:59:04 am AEDT, Jean-Paul Louis via Discuss <discuss@lists.openscad.org> wrote:
>Kevin,What you're asking is the perfect example of feature creep. A
>feature that does not add any value to the existing code. If you really
>want it, create a module that will do what you want, and don't bloat a
>good feature with useless stuff.
>Just my two cents,Jean-Paul N1JPL
>
>Sent from Yahoo Mail on Android
>
>On Sun, Nov 29, 2020 at 11:36 AM, kdtop<kdtop3@GMAIL.COM> wrote:
>Native OpenSCAD includes the ability to place a cube based on a center
>point,
>rather than based on one corner. E.g.
>
> *cube([10,10,10]);*
>
><http://forum.openscad.org/file/t2397/Capture1.png>
>
>vs
>
> *cube([10,10,10], center=true);*
>
><http://forum.openscad.org/file/t2397/Capture2.png>
>
>I find, however, that I often need to center the cube in just one
>dimension,
>for example y axis only. Thus I sometimes write the following code to
>extend cube centering functionality:
>*
> module cube2(size, center=[0,0,0]) {
> translate([-(size.x/2)*center.x, -(size.y/2)*center.y,
>-(size.z/2)*center.z])
> cube(size);
> } *
>
>Examples of use:
>
> *TestSize = [10,10,10];
> color("red") cube2(TestSize, center=[0,1,0]);
> color("blue") cube2(TestSize, center=[1,0,1]);*
>
><http://forum.openscad.org/file/t2397/Capture3.png>
>
>Feature request:
> I would like to see this implemented into native OpenSCAD. Thus the
>center parameter would be overloaded as follows:
>-- If a boolean (true / false) is passed, then it would work as
>previously.
>-- if an expression that evaluates to 0, then interpreted as false, if
>any
>other number, then as true. (currently passing in "1" is interpreted
>as
>false.)
>-- if a vector ([1,1,1]) is passed, then each element is interpreted as
>boolean for each dimension. E.g. center.x would be parameter for
>centering
>in x axis, and so on for .y and .z
>
>I suspect this would be a relatively easy bit of code to implement.
>
>Yes, I can just make my own custom library and include this for my own
>use.
>But does anyone else think this would be a helpful addition to the
>native
>language?
>
>Thanks
>Kevin T
>
>
>
>
>
>--
>Sent from: http://forum.openscad.org/
>
>_______________________________________________
>OpenSCAD mailing list
>Discuss@lists.openscad.org
>http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
KT
Kevin Toppenberg
Sun, Nov 29, 2020 6:06 PM
Thanks for the replies. I guess I will just keep it in a library for
myself.
Kevin T
On Sun, Nov 29, 2020 at 12:20 PM Rob Ward rl.ward@bigpond.com wrote:
It is also the perfect example of why the "OpenSCAD language - replace it
with Python3" discussion thread is worth reading.
Cheers, RobW
On 30 November 2020 3:59:04 am AEDT, Jean-Paul Louis via Discuss <
discuss@lists.openscad.org> wrote:
Kevin,
What you're asking is the perfect example of feature creep. A feature
that does not add any value to the existing code.
If you really want it, create a module that will do what you want, and
don't bloat a good feature with useless stuff.
Just my two cents,
Jean-Paul
N1JPL
Sent from Yahoo Mail on Android
https://go.onelink.me/107872968?pid=InProduct&c=Global_Internal_YGrowth_AndroidEmailSig__AndroidUsers&af_wl=ym&af_sub1=Internal&af_sub2=Global_YGrowth&af_sub3=EmailSignature
On Sun, Nov 29, 2020 at 11:36 AM, kdtop
kdtop3@GMAIL.COM wrote:
Native OpenSCAD includes the ability to place a cube based on a center
point,
rather than based on one corner. E.g.
*cube([10,10,10]);*
http://forum.openscad.org/file/t2397/Capture1.png
vs
*cube([10,10,10], center=true);*
http://forum.openscad.org/file/t2397/Capture2.png
I find, however, that I often need to center the cube in just one
dimension,
for example y axis only. Thus I sometimes write the following code to
extend cube centering functionality:
*
module cube2(size, center=[0,0,0]) {
translate([-(size.x/2)*center.x, -(size.y/2)*center.y,
-(size.z/2)*center.z])
cube(size);
} *
Examples of use:
*TestSize = [10,10,10];
color("red") cube2(TestSize, center=[0,1,0]);
color("blue") cube2(TestSize, center=[1,0,1]);*
http://forum.openscad.org/file/t2397/Capture3.png
Feature request:
I would like to see this implemented into native OpenSCAD. Thus the
center parameter would be overloaded as follows:
-- If a boolean (true / false) is passed, then it would work as
previously.
-- if an expression that evaluates to 0, then interpreted as false, if any
other number, then as true. (currently passing in "1" is interpreted as
false.)
-- if a vector ([1,1,1]) is passed, then each element is interpreted as
boolean for each dimension. E.g. center.x would be parameter for
centering
in x axis, and so on for .y and .z
I suspect this would be a relatively easy bit of code to implement.
Yes, I can just make my own custom library and include this for my own
use.
But does anyone else think this would be a helpful addition to the native
language?
Thanks
Kevin T
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Thanks for the replies. I guess I will just keep it in a library for
myself.
Kevin T
On Sun, Nov 29, 2020 at 12:20 PM Rob Ward <rl.ward@bigpond.com> wrote:
> It is also the perfect example of why the "OpenSCAD language - replace it
> with Python3" discussion thread is worth reading.
> Cheers, RobW
>
> On 30 November 2020 3:59:04 am AEDT, Jean-Paul Louis via Discuss <
> discuss@lists.openscad.org> wrote:
>>
>> Kevin,
>> What you're asking is the perfect example of feature creep. A feature
>> that does not add any value to the existing code.
>> If you really want it, create a module that will do what you want, and
>> don't bloat a good feature with useless stuff.
>>
>> Just my two cents,
>> Jean-Paul
>> N1JPL
>>
>> Sent from Yahoo Mail on Android
>> <https://go.onelink.me/107872968?pid=InProduct&c=Global_Internal_YGrowth_AndroidEmailSig__AndroidUsers&af_wl=ym&af_sub1=Internal&af_sub2=Global_YGrowth&af_sub3=EmailSignature>
>>
>> On Sun, Nov 29, 2020 at 11:36 AM, kdtop
>> <kdtop3@GMAIL.COM> wrote:
>> Native OpenSCAD includes the ability to place a cube based on a center
>> point,
>> rather than based on one corner. E.g.
>>
>> *cube([10,10,10]);*
>>
>> <http://forum.openscad.org/file/t2397/Capture1.png>
>>
>> vs
>>
>> *cube([10,10,10], center=true);*
>>
>> <http://forum.openscad.org/file/t2397/Capture2.png>
>>
>> I find, however, that I often need to center the cube in just one
>> dimension,
>> for example y axis only. Thus I sometimes write the following code to
>> extend cube centering functionality:
>> *
>> module cube2(size, center=[0,0,0]) {
>> translate([-(size.x/2)*center.x, -(size.y/2)*center.y,
>> -(size.z/2)*center.z])
>> cube(size);
>> } *
>>
>> Examples of use:
>>
>> *TestSize = [10,10,10];
>> color("red") cube2(TestSize, center=[0,1,0]);
>> color("blue") cube2(TestSize, center=[1,0,1]);*
>>
>> <http://forum.openscad.org/file/t2397/Capture3.png>
>>
>> Feature request:
>> I would like to see this implemented into native OpenSCAD. Thus the
>> center parameter would be overloaded as follows:
>> -- If a boolean (true / false) is passed, then it would work as
>> previously.
>> -- if an expression that evaluates to 0, then interpreted as false, if any
>> other number, then as true. (currently passing in "1" is interpreted as
>> false.)
>> -- if a vector ([1,1,1]) is passed, then each element is interpreted as
>> boolean for each dimension. E.g. center.x would be parameter for
>> centering
>> in x axis, and so on for .y and .z
>>
>> I suspect this would be a relatively easy bit of code to implement.
>>
>> Yes, I can just make my own custom library and include this for my own
>> use.
>> But does anyone else think this would be a helpful addition to the native
>> language?
>>
>> Thanks
>> Kevin T
>>
>>
>>
>>
>>
>> --
>> Sent from: http://forum.openscad.org/
>>
>> _______________________________________________
>> OpenSCAD mailing list
>> Discuss@lists.openscad.org
>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>
>> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
T
Troberg
Sun, Nov 29, 2020 6:06 PM
I just made my own cube module, which has three extra arguments, xalign,
yalign and zalign. If they are 0, it's centered, if -1, the bottom (or, more
precisely, the negative side) aligns with the axis, if 1, the top (the
positive side) aligns with the axis.
Literally a 5 minute job to make.
I don't see a need for this in the core language.
--
Sent from: http://forum.openscad.org/
I just made my own cube module, which has three extra arguments, xalign,
yalign and zalign. If they are 0, it's centered, if -1, the bottom (or, more
precisely, the negative side) aligns with the axis, if 1, the top (the
positive side) aligns with the axis.
Literally a 5 minute job to make.
I don't see a need for this in the core language.
--
Sent from: http://forum.openscad.org/
RD
Revar Desmera
Sun, Nov 29, 2020 8:23 PM
Before I added the anchor= functionality to BOSL2, I used to have upcube(), leftcube(), etc modules that centered the cube above, to the left, etc of the origin.
-Revar
On Nov 29, 2020, at 10:07 AM, Kevin Toppenberg kdtop3@gmail.com wrote:
Thanks for the replies. I guess I will just keep it in a library for myself.
Kevin T
On Sun, Nov 29, 2020 at 12:20 PM Rob Ward rl.ward@bigpond.com wrote:
It is also the perfect example of why the "OpenSCAD language - replace it with Python3" discussion thread is worth reading.
Cheers, RobW
On 30 November 2020 3:59:04 am AEDT, Jean-Paul Louis via Discuss discuss@lists.openscad.org wrote:
Kevin,
What you're asking is the perfect example of feature creep. A feature that does not add any value to the existing code.
If you really want it, create a module that will do what you want, and don't bloat a good feature with useless stuff.
Just my two cents,
Jean-Paul
N1JPL
Sent from Yahoo Mail on Android
On Sun, Nov 29, 2020 at 11:36 AM, kdtop
kdtop3@GMAIL.COM wrote:
Native OpenSCAD includes the ability to place a cube based on a center point,
rather than based on one corner. E.g.
*cube([10,10,10]);*
http://forum.openscad.org/file/t2397/Capture1.png
vs
*cube([10,10,10], center=true);*
http://forum.openscad.org/file/t2397/Capture2.png
I find, however, that I often need to center the cube in just one dimension,
for example y axis only. Thus I sometimes write the following code to
extend cube centering functionality:
*
module cube2(size, center=[0,0,0]) {
translate([-(size.x/2)*center.x, -(size.y/2)*center.y,
-(size.z/2)*center.z])
cube(size);
} *
Examples of use:
*TestSize = [10,10,10];
color("red") cube2(TestSize, center=[0,1,0]);
color("blue") cube2(TestSize, center=[1,0,1]);*
http://forum.openscad.org/file/t2397/Capture3.png
Feature request:
I would like to see this implemented into native OpenSCAD. Thus the
center parameter would be overloaded as follows:
-- If a boolean (true / false) is passed, then it would work as previously.
-- if an expression that evaluates to 0, then interpreted as false, if any
other number, then as true. (currently passing in "1" is interpreted as
false.)
-- if a vector ([1,1,1]) is passed, then each element is interpreted as
boolean for each dimension. E.g. center.x would be parameter for centering
in x axis, and so on for .y and .z
I suspect this would be a relatively easy bit of code to implement.
Yes, I can just make my own custom library and include this for my own use.
But does anyone else think this would be a helpful addition to the native
language?
Thanks
Kevin T
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Before I added the anchor= functionality to BOSL2, I used to have upcube(), leftcube(), etc modules that centered the cube above, to the left, etc of the origin.
-Revar
> On Nov 29, 2020, at 10:07 AM, Kevin Toppenberg <kdtop3@gmail.com> wrote:
>
>
> Thanks for the replies. I guess I will just keep it in a library for myself.
>
> Kevin T
>
>> On Sun, Nov 29, 2020 at 12:20 PM Rob Ward <rl.ward@bigpond.com> wrote:
>> It is also the perfect example of why the "OpenSCAD language - replace it with Python3" discussion thread is worth reading.
>> Cheers, RobW
>>
>>> On 30 November 2020 3:59:04 am AEDT, Jean-Paul Louis via Discuss <discuss@lists.openscad.org> wrote:
>>> Kevin,
>>> What you're asking is the perfect example of feature creep. A feature that does not add any value to the existing code.
>>> If you really want it, create a module that will do what you want, and don't bloat a good feature with useless stuff.
>>>
>>> Just my two cents,
>>> Jean-Paul
>>> N1JPL
>>>
>>> Sent from Yahoo Mail on Android
>>>
>>> On Sun, Nov 29, 2020 at 11:36 AM, kdtop
>>> <kdtop3@GMAIL.COM> wrote:
>>> Native OpenSCAD includes the ability to place a cube based on a center point,
>>> rather than based on one corner. E.g.
>>>
>>> *cube([10,10,10]);*
>>>
>>> <http://forum.openscad.org/file/t2397/Capture1.png>
>>>
>>> vs
>>>
>>> *cube([10,10,10], center=true);*
>>>
>>> <http://forum.openscad.org/file/t2397/Capture2.png>
>>>
>>> I find, however, that I often need to center the cube in just one dimension,
>>> for example y axis only. Thus I sometimes write the following code to
>>> extend cube centering functionality:
>>> *
>>> module cube2(size, center=[0,0,0]) {
>>> translate([-(size.x/2)*center.x, -(size.y/2)*center.y,
>>> -(size.z/2)*center.z])
>>> cube(size);
>>> } *
>>>
>>> Examples of use:
>>>
>>> *TestSize = [10,10,10];
>>> color("red") cube2(TestSize, center=[0,1,0]);
>>> color("blue") cube2(TestSize, center=[1,0,1]);*
>>>
>>> <http://forum.openscad.org/file/t2397/Capture3.png>
>>>
>>> Feature request:
>>> I would like to see this implemented into native OpenSCAD. Thus the
>>> center parameter would be overloaded as follows:
>>> -- If a boolean (true / false) is passed, then it would work as previously.
>>> -- if an expression that evaluates to 0, then interpreted as false, if any
>>> other number, then as true. (currently passing in "1" is interpreted as
>>> false.)
>>> -- if a vector ([1,1,1]) is passed, then each element is interpreted as
>>> boolean for each dimension. E.g. center.x would be parameter for centering
>>> in x axis, and so on for .y and .z
>>>
>>> I suspect this would be a relatively easy bit of code to implement.
>>>
>>> Yes, I can just make my own custom library and include this for my own use.
>>> But does anyone else think this would be a helpful addition to the native
>>> language?
>>>
>>> Thanks
>>> Kevin T
>>>
>>>
>>>
>>>
>>>
>>> --
>>> Sent from: http://forum.openscad.org/
>>>
>>> _______________________________________________
>>> OpenSCAD mailing list
>>> Discuss@lists.openscad.org
>>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>> _______________________________________________
>> OpenSCAD mailing list
>> Discuss@lists.openscad.org
>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
JB
Jordan Brown
Sun, Nov 29, 2020 9:06 PM
I have a module jcube (for justified cube) that takes dims and a
[jz,jy,jz] justify vector where -1 means the cube goes negative from the
origin, 0 means centered, and +1 means positive from the origin.
It's based on a more general justify module that similarly justifies its
children. It takes a bounding box (either [dx,dy,dz] dimensions with an
implied origin at [0,0,0], or [[ox,oy,oz], [dx,dy,dz]]) and a justify
vector as above.
Both also take a simple boolean center equivalent to j=[0,0,0], but I
don't know if I've ever used it since it's longer.
With respect to whether such a feature should be in the base... undecided.
It could certainly be in MCAD and so available in every installation.
Argument for putting it in the base: so you don't have to have a module
that is almost, but not quite, the same as "cube". Also helps to
establish a convention for how to represent this sort of justification,
so that it's obvious how justifying a cylinder, or sphere, or whatever
would work.
Argument against: it doesn't need to be. (But note: "center" doesn't
need to be either, so we aren't strictly minimal.)
use <default.scad>
// @brief Given an [x,y] or an [x,y,z], return an [x,y,z].
// @param a A two- or three- element array
// @returns A three-element array
function make3(a) =
assert(len(a) == 2 || len(a) == 3)
len(a) == 3 ? a : concat(a, 0);
// @brief Justify children as specified by argument.
// @param center Equivalent to justify=[0,0,0].
// @param j [jx,jy,jz]:
// +1 toward-positive
// 0 center
// -1 toward-negative
// @param bb Bounding box:
// [dimx,dimy,dimz]
// [ [ox,oy,oz], [dimx,dimy,dimz] ]
// @children Object(s) to be justified.
// @note Works for two- or three- dimensional objects.
// @note If more than one object is supplied as a child, they
// are all justified en mass with respect to the specified
// bounding box.
module justify(center, j, bb) {
origin = make3(
assert(is_list(bb))
is_list(bb[0])
? assert(len(bb) == 2) bb[0]
: [0,0,0]
);
dims = make3(
is_list(bb[0])
? bb[1]
: bb
);
j = make3(default(j, center ? [0,0,0] : [1,1,1]));
function o(flag, dim) = flag > 0 ? 0 :
flag < 0 ? -dim :
-dim/2;
translate([o(j[0], dims[0]),
o(j[1], dims[1]),
o(j[2], dims[2])])
translate(-origin) // Move BB minima to [0,0,0]
children();
}
// @brief A justified cube
// @param dims Dimensions of the cube
// @param center Equivalent to j=[0,0,0]
// @param j As for justify() above
module jcube(dims, center, j) {
justify(center=center, j=j, bb=dims) cube(dims);
}
// Test/demos
for (xj=[-1:1], yj=[-1:1], zj=[-1:1]) {
justify(j=[xj,yj,zj], bb=[[-10,-10,-10],[20,20,20]])
color([(xj+1)/2, (yj+1)/2, (zj+1)/2]) sphere(r=10);
}
translate([30,0]) for (xj=[-1:1], yj=[-1:1]) {
justify(j=[xj,yj], bb=[[-10,-10],[10,10]])
color([(xj+1)/2, (yj+1)/2, 0]) circle(r=10);
}
It depends on a trivial function "default":
function default(val, def) = is_undef(val) ? def : val;
I have a module jcube (for justified cube) that takes dims and a
[jz,jy,jz] justify vector where -1 means the cube goes negative from the
origin, 0 means centered, and +1 means positive from the origin.
It's based on a more general justify module that similarly justifies its
children. It takes a bounding box (either [dx,dy,dz] dimensions with an
implied origin at [0,0,0], or [[ox,oy,oz], [dx,dy,dz]]) and a justify
vector as above.
Both also take a simple boolean center equivalent to j=[0,0,0], but I
don't know if I've ever used it since it's longer.
With respect to whether such a feature should be in the base... undecided.
It could certainly be in MCAD and so available in every installation.
Argument for putting it in the base: so you don't have to have a module
that is almost, but not quite, the same as "cube". Also helps to
establish a convention for how to represent this sort of justification,
so that it's obvious how justifying a cylinder, or sphere, or whatever
would work.
Argument against: it doesn't need to be. (But note: "center" doesn't
need to be either, so we aren't strictly minimal.)
use <default.scad>
// @brief Given an [x,y] or an [x,y,z], return an [x,y,z].
// @param a A two- or three- element array
// @returns A three-element array
function make3(a) =
assert(len(a) == 2 || len(a) == 3)
len(a) == 3 ? a : concat(a, 0);
// @brief Justify children as specified by argument.
// @param center Equivalent to justify=[0,0,0].
// @param j [jx,jy,jz]:
// +1 toward-positive
// 0 center
// -1 toward-negative
// @param bb Bounding box:
// [dimx,dimy,dimz]
// [ [ox,oy,oz], [dimx,dimy,dimz] ]
// @children Object(s) to be justified.
// @note Works for two- or three- dimensional objects.
// @note If more than one object is supplied as a child, they
// are all justified en mass with respect to the specified
// bounding box.
module justify(center, j, bb) {
origin = make3(
assert(is_list(bb))
is_list(bb[0])
? assert(len(bb) == 2) bb[0]
: [0,0,0]
);
dims = make3(
is_list(bb[0])
? bb[1]
: bb
);
j = make3(default(j, center ? [0,0,0] : [1,1,1]));
function o(flag, dim) = flag > 0 ? 0 :
flag < 0 ? -dim :
-dim/2;
translate([o(j[0], dims[0]),
o(j[1], dims[1]),
o(j[2], dims[2])])
translate(-origin) // Move BB minima to [0,0,0]
children();
}
// @brief A justified cube
// @param dims Dimensions of the cube
// @param center Equivalent to j=[0,0,0]
// @param j As for justify() above
module jcube(dims, center, j) {
justify(center=center, j=j, bb=dims) cube(dims);
}
// Test/demos
for (xj=[-1:1], yj=[-1:1], zj=[-1:1]) {
justify(j=[xj,yj,zj], bb=[[-10,-10,-10],[20,20,20]])
color([(xj+1)/2, (yj+1)/2, (zj+1)/2]) sphere(r=10);
}
translate([30,0]) for (xj=[-1:1], yj=[-1:1]) {
justify(j=[xj,yj], bb=[[-10,-10],[10,10]])
color([(xj+1)/2, (yj+1)/2, 0]) circle(r=10);
}
It depends on a trivial function "default":
function default(val, def) = is_undef(val) ? def : val;