$center

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

$center

stonysmith
I'd like to suggest adding a global variable such as $center where we can set center=true on all primitives.
I find that my source code is commonly riddled with extra text that could be removed if this option could be set globally
Reply | Threaded
Open this post in threaded view
|

Re: $center

kintel
Administrator
On Dec 23, 2011, at 03:01 AM, [hidden email] wrote:

> I'd like to suggest adding a global variable such as $center where we can set center=true on all primitives.
> I find that my source code is commonly riddled with extra text that could be removed if this option could be set globally

I agree that this is a bit annoying.
I feel that introducing more global variables like this messes up the language a bit, so I'm uncertain how be best deal with this. I also assume that more similar things will come up in the future.

If anyone have good ideas how to handle such functionality, I'm interested in opinions.

In any case, I'll put this off to after the release - then we have more opportunities to play around with features.

I've added it to the wishlist for now.

Cheers,

 -Marius


Reply | Threaded
Open this post in threaded view
|

Re: $center

nophead
It would break libraries unless you had a global that could be overridden on a per file basis and then restored. Like #pragma pack, push and pop on VC++. Not nice!

I think it would be cleaner to have have it being able to be be set per file, but not affecting included and used files.

On 23 December 2011 13:29, Marius Kintel <[hidden email]> wrote:
On Dec 23, 2011, at 03:01 AM, [hidden email] wrote:

> I'd like to suggest adding a global variable such as $center where we can set center=true on all primitives.
> I find that my source code is commonly riddled with extra text that could be removed if this option could be set globally

I agree that this is a bit annoying.
I feel that introducing more global variables like this messes up the language a bit, so I'm uncertain how be best deal with this. I also assume that more similar things will come up in the future.

If anyone have good ideas how to handle such functionality, I'm interested in opinions.

In any case, I'll put this off to after the release - then we have more opportunities to play around with features.

I've added it to the wishlist for now.

Cheers,

 -Marius

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad

Reply | Threaded
Open this post in threaded view
|

Re: $center

Whosawhatsis
That's a possible issue, through using the same syntax as the other $ variables would be the best way to do it, and you could always put $center = false in the arguments when you call a library module if it breaks, until the libraries are updates to explicitly set it for themselves.

On Friday, December 23, 2011 at 10:46 AM, nop head wrote:

It would break libraries unless you had a global that could be overridden on a per file basis and then restored. Like #pragma pack, push and pop on VC++. Not nice!

I think it would be cleaner to have have it being able to be be set per file, but not affecting included and used files.

On 23 December 2011 13:29, Marius Kintel <[hidden email]> wrote:
On Dec 23, 2011, at 03:01 AM, [hidden email] wrote:

> I'd like to suggest adding a global variable such as $center where we can set center=true on all primitives.
> I find that my source code is commonly riddled with extra text that could be removed if this option could be set globally

I agree that this is a bit annoying.
I feel that introducing more global variables like this messes up the language a bit, so I'm uncertain how be best deal with this. I also assume that more similar things will come up in the future.

If anyone have good ideas how to handle such functionality, I'm interested in opinions.

In any case, I'll put this off to after the release - then we have more opportunities to play around with features.

I've added it to the wishlist for now.

Cheers,

 -Marius

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad

_______________________________________________
OpenSCAD mailing list

Reply | Threaded
Open this post in threaded view
|

Re: $center

donbright
stonysmith  "I find that my source code is commonly riddled with extra text"

What about using the Kanji character for 'middle' as a special suffix
that makes things centered?

sphere(4,center=true);

becomes

sphere中(4);


cube([5,2,4],center=true);

becomes

cube中([5,2,4]);



union() {
  cube([5,2,4],center=true);
  sphere(6,center=true);
  cube([-1,2,4],center=true);
}

becomes

union() {
  cube中([5,2,4]);
  sphere中(6);
  cube中([-1,2,4]);
}

-DB

Reply | Threaded
Open this post in threaded view
|

Re: $center

Whosawhatsis
You could do the same thing with, say, a C (which would be easier to type) and have sphereC, cubeC, cylinderC, etC. Of course, these could just be modules that you write yourself and include as a small library.

On Friday, December 23, 2011 at 3:51 PM, Don Bright wrote:

stonysmith "I find that my source code is commonly riddled with extra text"

What about using the Kanji character for 'middle' as a special suffix
that makes things centered?

sphere(4,center=true);

becomes

sphere中(4);


cube([5,2,4],center=true);

becomes

cube中([5,2,4]);



union() {
cube([5,2,4],center=true);
sphere(6,center=true);
cube([-1,2,4],center=true);
}

becomes

union() {
cube中([5,2,4]);
sphere中(6);
cube中([-1,2,4]);
}

-DB
_______________________________________________
OpenSCAD mailing list

Reply | Threaded
Open this post in threaded view
|

Re: $center

William Adams
In reply to this post by stonysmith
Perhaps just normalizing all geometries around origin, like sphere is currently.

No matter how things go, your code will have to adjust, either with center=true+translate, or just translate.

I'd be happy with unit geometries centered around origin, with boundary info.

From: Whosawhatsis
Sent: 12/23/2011 5:24 PM
To: [hidden email]
Subject: Re: [OpenSCAD] $center

You could do the same thing with, say, a C (which would be easier to type) and have sphereC, cubeC, cylinderC, etC. Of course, these could just be modules that you write yourself and include as a small library.

On Friday, December 23, 2011 at 3:51 PM, Don Bright wrote:

stonysmith "I find that my source code is commonly riddled with extra text"

What about using the Kanji character for 'middle' as a special suffix
that makes things centered?

sphere(4,center=true);

becomes

sphere中(4);


cube([5,2,4],center=true);

becomes

cube中([5,2,4]);



union() {
cube([5,2,4],center=true);
sphere(6,center=true);
cube([-1,2,4],center=true);
}

becomes

union() {
cube中([5,2,4]);
sphere中(6);
cube中([-1,2,4]);
}

-DB
_______________________________________________
OpenSCAD mailing list


You could do the same thing with, say, a C (which would be easier to type) and have sphereC, cubeC, cylinderC, etC. Of course, these could just be modules that you write yourself and include as a small library.  


On Friday, December 23, 2011 at 3:51 PM, Don Bright wrote:

> stonysmith "I find that my source code is commonly riddled with extra text"
>  
> What about using the Kanji character for 'middle' as a special suffix
> that makes things centered?
>  
> sphere(4,center=true);
>  
> becomes
>  
> sphere中(4);
>  
>  
> cube([5,2,4],center=true);
>  
> becomes
>  
> cube中([5,2,4]);
>  
>  
>  
> union() {
> cube([5,2,4],center=true);
> sphere(6,center=true);
> cube([-1,2,4],center=true);
> }
>  
> becomes
>  
> union() {
> cube中([5,2,4]);
> sphere中(6);
> cube中([-1,2,4]);
> }
>  
> -DB
> _______________________________________________
> OpenSCAD mailing list
> [hidden email] (mailto:[hidden email])
> http://rocklinux.net/mailman/listinfo/openscad
>  
>  


You could do the same thing with, say, a C (which would be easier to type) and have sphereC, cubeC, cylinderC, etC. Of course, these could just be modules that you write yourself and include as a small library.

On Friday, December 23, 2011 at 3:51 PM, Don Bright wrote:

stonysmith "I find that my source code is commonly riddled with extra text"

What about using the Kanji character for 'middle' as a special suffix
that makes things centered?

sphere(4,center=true);

becomes

sphere中(4);


cube([5,2,4],center=true);

becomes

cube中([5,2,4]);



union() {
cube([5,2,4],center=true);
sphere(6,center=true);
cube([-1,2,4],center=true);
}

becomes

union() {
cube中([5,2,4]);
sphere中(6);
cube中([-1,2,4]);
}

-DB
_______________________________________________
OpenSCAD mailing list


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
Reply | Threaded
Open this post in threaded view
|

Re: $center

flip

Flip here, former Pixar person. 

Not that this should have anything to do with anything- but
the Renderman and menv primitives are mostly center=true (only exceptions = explicitly defined things like polys, patches, etc), which just makes for better modeling practices in the long run. 

It would likely break all sorts of legacy code, of course, for that to be the default... but if there's ever going to be a major rev, etc. 


-fp

(n.b. the 中 solution, while syntactically sugary, is aesthetically awesome.)
-- 
www.skidmore.edu/flip


On Dec 23, 2011, at 8:25 PM, William Adams wrote:

Perhaps just normalizing all geometries around origin, like sphere is currently.

No matter how things go, your code will have to adjust, either with center=true+translate, or just translate.

I'd be happy with unit geometries centered around origin, with boundary info.
________________________________
From: Whosawhatsis
Sent: 12/23/2011 5:24 PM
To: [hidden email]
Subject: Re: [OpenSCAD] $center

You could do the same thing with, say, a C (which would be easier to type) and have sphereC, cubeC, cylinderC, etC. Of course, these could just be modules that you write yourself and include as a small library.


On Friday, December 23, 2011 at 3:51 PM, Don Bright wrote:

stonysmith "I find that my source code is commonly riddled with extra text"

What about using the Kanji character for 'middle' as a special suffix
that makes things centered?

sphere(4,center=true);

becomes

sphere中(4);


cube([5,2,4],center=true);

becomes

cube中([5,2,4]);



union() {
cube([5,2,4],center=true);
sphere(6,center=true);
cube([-1,2,4],center=true);
}

becomes

union() {
cube中([5,2,4]);
sphere中(6);
cube中([-1,2,4]);
}

-DB
_______________________________________________
OpenSCAD mailing list
[hidden email] (mailto:[hidden email])
http://rocklinux.net/mailman/listinfo/openscad




_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad



Reply | Threaded
Open this post in threaded view
|

Re: $center

Triffid Hunter
fwiw, using center=true is the unusual case for me. I frequently
organise my code so that cube origins are somewhere sensible vs other
objects, and the length or some other dimension is controlled by some
parametric variable

Reply | Threaded
Open this post in threaded view
|

Re: $center

Laszlo KREKACS
On Sat, Dec 24, 2011 at 3:11 AM, Triffid Hunter
<[hidden email]> wrote:
> fwiw, using center=true is the unusual case for me. I frequently
> organise my code so that cube origins are somewhere sensible vs other
> objects, and the length or some other dimension is controlled by some
> parametric variable


I often model the cube like centering X,Y but not Z.
The cylinder works like this. (ie. the circle is centered, but the
bottom of the object is at Z=0).
Some consistency would be awesome. (ie. the cylinder could be
displaced translate([r,r,0]) to
follow the cube behaviour, or the cube could be centered in X,Y to
follow the cylinder behaviour)

Best,
 Laszlo

Reply | Threaded
Open this post in threaded view
|

Re: $center

Whosawhatsis
I often want to do this too. It can be accomplished without a
translation by making a square with center=true and then extruding it
with (implicit) center=false.

On Dec 28, 2011, at 0:40, Laszlo KREKACS <[hidden email]> wrote:

> On Sat, Dec 24, 2011 at 3:11 AM, Triffid Hunter
> <[hidden email]> wrote:
>> fwiw, using center=true is the unusual case for me. I frequently
>> organise my code so that cube origins are somewhere sensible vs other
>> objects, and the length or some other dimension is controlled by some
>> parametric variable
>
>
> I often model the cube like centering X,Y but not Z.
> The cylinder works like this. (ie. the circle is centered, but the
> bottom of the object is at Z=0).
> Some consistency would be awesome. (ie. the cylinder could be
> displaced translate([r,r,0]) to
> follow the cube behaviour, or the cube could be centered in X,Y to
> follow the cylinder behaviour)
>
> Best,
> Laszlo
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad