discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Centering cube axes independently

F
Frédéric
Sat, Dec 12, 2015 4:29 PM

On Mar 25, 2012 Whosawhatsis wrote:

It would be nice if OpenSCAD allowed you to select whether or not to
center squares and cubes on each axis independently. Here's the syntax I
suggest:

cube(10, center = [true, true, false]);

This should create a 10mm cube sitting on the center of the X/Y plane. I
know there are ways to do this using translate, but it would make the
code more elegant and easier to edit.

Hi!

I second this (old) proposition; I rarely need a cube centered on its 3
axes, and always have to use translate() to move, which is pretty annoying.
Especially when using global consts (for parametric code), it leads to
XXX/2, YYY/2...

Thanks,

PS : sphere is also not consistant with cylinder/cube, as it is always
centered...

--
Frédéric

On Mar 25, 2012 Whosawhatsis wrote: > It would be nice if OpenSCAD allowed you to select whether or not to > center squares and cubes on each axis independently. Here's the syntax I > suggest: > > cube(10, center = [true, true, false]); > > This should create a 10mm cube sitting on the center of the X/Y plane. I > know there are ways to do this using translate, but it would make the > code more elegant and easier to edit. Hi! I second this (old) proposition; I rarely need a cube centered on its 3 axes, and always have to use translate() to move, which is pretty annoying. Especially when using global consts (for parametric code), it leads to XXX/2, YYY/2... Thanks, PS : sphere is also not consistant with cylinder/cube, as it is always centered... -- Frédéric
P
Parkinbot
Sat, Dec 12, 2015 5:59 PM

You can implement features of this kind easily as your own library and
include it into you projects.

Have a look at: http://www.thingiverse.com/thing:644830

Rudolf

--
View this message in context: http://forum.openscad.org/Centering-cube-axes-independently-tp15128p15130.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

You can implement features of this kind easily as your own library and include it into you projects. Have a look at: http://www.thingiverse.com/thing:644830 Rudolf -- View this message in context: http://forum.openscad.org/Centering-cube-axes-independently-tp15128p15130.html Sent from the OpenSCAD mailing list archive at Nabble.com.
F
Frédéric
Sun, Dec 13, 2015 7:58 AM

Le samedi 12 décembre 2015, Parkinbot a écrit :

You can implement features of this kind easily as your own library and
include it into you projects.

Sure, but:

  1. is there any reason not to put it as a native feature?

  2. what about perfs? I guess it would be much faster if native...

--
Frédéric

Le samedi 12 décembre 2015, Parkinbot a écrit : > You can implement features of this kind easily as your own library and > include it into you projects. Sure, but: 1) is there any reason not to put it as a native feature? 2) what about perfs? I guess it would be much faster if native... -- Frédéric
P
Parkinbot
Sun, Dec 13, 2015 12:51 PM

Well, your proposal is in principle not bad. I also often missed this
feature.

@Kintel
In my eyes one would be better off having an automatically included
standard library
, where stuff like that is rewritable without having to put
further burden to the dev team. If there was also a qualified naming scheme
in OpenSCAD, the implementation could even be made fully transparent. This
would also be the perfect place to put in other customizations, like
includes for other libraries.

@fma
Be assured, you won't notice any increase in execution time with code like
this:

module yourcube(size = [1,1,1], center = false)
{
sz = (len(size) == 3)?size:[size,size,size];
if (len(center) == 1)
cube(size, center);
else

translate([center[0]?-sz[0]/2:0,center[1]?-sz[1]/2:0,center[2]?-sz[2]/2:0])
cube(size);
}

yourcube([6, 10, 12], [true, true, false]);  // testing it

--
View this message in context: http://forum.openscad.org/Centering-cube-axes-independently-tp15128p15145.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Well, your proposal is in principle not bad. I also often missed this feature. @Kintel In my eyes one would be better off having an *automatically included standard library*, where stuff like that is rewritable without having to put further burden to the dev team. If there was also a qualified naming scheme in OpenSCAD, the implementation could even be made fully transparent. This would also be the perfect place to put in other customizations, like includes for other libraries. @fma Be assured, you won't notice any increase in execution time with code like this: > module yourcube(size = [1,1,1], center = false) > { > sz = (len(size) == 3)?size:[size,size,size]; > if (len(center) == 1) > cube(size, center); > else > > translate([center[0]?-sz[0]/2:0,center[1]?-sz[1]/2:0,center[2]?-sz[2]/2:0]) > cube(size); > } > > yourcube([6, 10, 12], [true, true, false]); // testing it -- View this message in context: http://forum.openscad.org/Centering-cube-axes-independently-tp15128p15145.html Sent from the OpenSCAD mailing list archive at Nabble.com.
TP
Torsten Paul
Sun, Dec 13, 2015 1:22 PM

On 12/13/2015 01:51 PM, Parkinbot wrote:

In my eyes one would be better off having an automatically included
standard library
, where stuff like that is rewritable without having to put
further burden to the dev team. If there was also a qualified naming scheme
in OpenSCAD, the implementation could even be made fully transparent. This
would also be the perfect place to put in other customizations, like
includes for other libraries.

I guess there's full agreement on that. The issue list already contains
a number of things that would be nice and simple candidates for inclusion

e.g.:
https://github.com/openscad/openscad/issues/1517
https://github.com/openscad/openscad/issues/821

(Hmm, one of the 821 related issues might need to be reopened?!)

The challenges are "only":

  • No namespace support yet (MCAD dev works around that using mcad_ prefix)
  • Needs quite some work to define a stable API (maybe using some kind of
    staging area first which gives a warning for new stuff that might still
    be changed)
  • Needs lots of work to maintain once it's used in various projects
  • Needs a good name :-)

ciao,
Torsten.

On 12/13/2015 01:51 PM, Parkinbot wrote: > In my eyes one would be better off having an *automatically included > standard library*, where stuff like that is rewritable without having to put > further burden to the dev team. If there was also a qualified naming scheme > in OpenSCAD, the implementation could even be made fully transparent. This > would also be the perfect place to put in other customizations, like > includes for other libraries. > I guess there's full agreement on that. The issue list already contains a number of things that would be nice and simple candidates for inclusion e.g.: https://github.com/openscad/openscad/issues/1517 https://github.com/openscad/openscad/issues/821 (Hmm, one of the 821 related issues might need to be reopened?!) The challenges are "only": - No namespace support yet (MCAD dev works around that using mcad_ prefix) - Needs quite some work to define a stable API (maybe using some kind of staging area first which gives a warning for new stuff that might still be changed) - Needs lots of work to maintain once it's used in various projects - Needs a good name :-) ciao, Torsten.
DM
doug moen
Sun, Dec 13, 2015 7:58 PM

There is a feature requests open for this feature on github, from 2013
https://github.com/openscad/openscad/issues/265

And a pull request from 2014, so it has been implemented, but not accepted
into the tree yet.
https://github.com/openscad/openscad/pull/753

On 13 December 2015 at 02:58, Frédéric fma@gbiloba.org wrote:

Le samedi 12 décembre 2015, Parkinbot a écrit :

You can implement features of this kind easily as your own library and
include it into you projects.

Sure, but:

  1. is there any reason not to put it as a native feature?

  2. what about perfs? I guess it would be much faster if native...

--
Frédéric


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

There is a feature requests open for this feature on github, from 2013 https://github.com/openscad/openscad/issues/265 And a pull request from 2014, so it has been implemented, but not accepted into the tree yet. https://github.com/openscad/openscad/pull/753 On 13 December 2015 at 02:58, Frédéric <fma@gbiloba.org> wrote: > Le samedi 12 décembre 2015, Parkinbot a écrit : > > > You can implement features of this kind easily as your own library and > > include it into you projects. > > Sure, but: > > 1) is there any reason not to put it as a native feature? > > 2) what about perfs? I guess it would be much faster if native... > > -- > Frédéric > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >