[OpenSCAD] Feature request: transformation modules

Whosawhatsis whosawhatsis at gmail.com
Tue Nov 29 20:08:55 CET 2011


If you replace "transform" with "module", the above code works.

On Tuesday, November 29, 2011 at 11:05 AM, Brad Pitcher wrote:

> I know this isn't exactly the right time to be discussing new features, so please forgive me, I just wanted to share the idea while it was fresh. Also, please accept my apologies if this has been discussed before.
> I found numerous situations where I want to apply a group of similar transformations to objects at different places in the code, and of course it would be better not to repeat the code. My idea was that we could have something that is analagous to a module, but used like a transformation. Here's an example with possible syntax (sorry if the indentation doesn't come out right):
> 
> transform my_transform(rotation = [0, 90, 0], translation = [0, 0, 10], scale = [1, 1, 2]) {
>     rotate(rotation)
>     translate(translation)
>     scale(scale)
>     difference() {
>         child();              // in this case, sphere(10);
>         cube([1, 1, 30])
>     }
> }
> 
> my_transform() {
>     sphere(10);
> }
> 
> This example would rotate/translate/scale the object and then punch a hole in it.  This is a very simple example and might not seem useful, but I haven't figured out how to do this currently without repeating a lot of code.
> Please let me know what you think. Cheers,
> Brad
> _______________________________________________
> OpenSCAD mailing list
> OpenSCAD at rocklinux.org (mailto:OpenSCAD at rocklinux.org)
> http://rocklinux.net/mailman/listinfo/openscad
> 
> 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rocklinux.net/pipermail/openscad/attachments/20111129/6bcca083/attachment.html


More information about the OpenSCAD mailing list