Nabble has removed Mailing-list integration.
Posts created here DO NOT GET SENT TO THE MAILING LIST.
Mailing-list emails DO NOT GET POSTED TO THE FORUM.
So basically the Forum is now out of date, we are looking into migrating the history.

For now you should send emails, people will see them, discuss@lists.openscad.org.

Re: openscad: child count

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

Re: openscad: child count

Clifford Wolf
Hi,

On Wed, Mar 03, 2010 at 10:13:27PM +0000, Giles Bathgate wrote:
> Clifford,
>
> Suppose I wanted to do something like the following:
> [...]
> So is there any way I can get the child count, rather than having to pass it as a parameter?
> perhaps there could be a childcount() function that would be used along with the child(i) function?
> or perhaps another way of doing it would be to allow you to do something like this
> [...]

The variable $children always holds the number of children. So your script
would look like this:

        module RotateAndTranslate() {
          for (i = [0 : $children-1])
            translate([ 10, 10, 10 ]) rotate([10,10,10]) child(i);
        }
       
        RotateAndTranslate()
        {
                sphere(1);
                cube([1,1,1]);
                cylinder(r=1,h=1);
        }

yours,
 - clifford

--
bash -c "gcc -o mysdldemo -Wall -O2 -lSDL -lm -pthread -x c <( echo -e '
#include <SDL/SDL.h>\n#include <complex.h>\nint main(){SDL_Surface*s;SDL_Event
e;int x,y,n;SDL_Init(SDL_INIT_VIDEO);s=SDL_SetVideoMode(640,480,32,0);for(x=0;
x<640;x++)for(y=0;y<480;y++){float _Complex z=0, c=((x-400)/200.0) + ((y-240)/
200.0)*1.0fi;for(n=1;n<64;n++){z=z*z+c;if(cabsf(z)>2){((Uint32*)s->pixels)[x+y
*640]=n<<3;n=99;}}}SDL_UpdateRect(s,0,0,s->w,s->h);do SDL_WaitEvent(&e); while
(e.type!=SDL_QUIT&&e.type!=SDL_KEYDOWN);SDL_Quit();return 0;}' ); ./mysdldemo"

Reply | Threaded
Open this post in threaded view
|

Re: openscad: child count

Zach Smith
wow, that is cool!

On Thu, Mar 4, 2010 at 3:10 AM, Clifford Wolf <[hidden email]> wrote:
Hi,

On Wed, Mar 03, 2010 at 10:13:27PM +0000, Giles Bathgate wrote:
> Clifford,
>
> Suppose I wanted to do something like the following:
> [...]
> So is there any way I can get the child count, rather than having to pass it as a parameter?
> perhaps there could be a childcount() function that would be used along with the child(i) function?
> or perhaps another way of doing it would be to allow you to do something like this
> [...]

The variable $children always holds the number of children. So your script
would look like this:

       module RotateAndTranslate() {
         for (i = [0 : $children-1])
           translate([ 10, 10, 10 ]) rotate([10,10,10]) child(i);
       }

       RotateAndTranslate()
       {
               sphere(1);
               cube([1,1,1]);
               cylinder(r=1,h=1);
       }

yours,
 - clifford

--
bash -c "gcc -o mysdldemo -Wall -O2 -lSDL -lm -pthread -x c <( echo -e '
#include <SDL/SDL.h>\n#include <complex.h>\nint main(){SDL_Surface*s;SDL_Event
e;int x,y,n;SDL_Init(SDL_INIT_VIDEO);s=SDL_SetVideoMode(640,480,32,0);for(x=0;
x<640;x++)for(y=0;y<480;y++){float _Complex z=0, c=((x-400)/200.0) + ((y-240)/
200.0)*1.0fi;for(n=1;n<64;n++){z=z*z+c;if(cabsf(z)>2){((Uint32*)s->pixels)[x+y
*640]=n<<3;n=99;}}}SDL_UpdateRect(s,0,0,s->w,s->h);do SDL_WaitEvent(&e); while
(e.type!=SDL_QUIT&&e.type!=SDL_KEYDOWN);SDL_Quit();return 0;}' ); ./mysdldemo"
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad



--
Zach Smith
MakerBot Industries
Reply | Threaded
Open this post in threaded view
|

exponentiation operator

Giles Bathgate
In reply to this post by Clifford Wolf
I don't know if there is a good reason for not adding an exponentiation
operator to openscad, as an alternative to using pow(5,2) but I think
its neater to
write 5^2 so I implemented it. (patch attached)

I think I got the operator precedence correct, because it seemed to work
with some basic tests, however I am a bison novice.

Regards

Giles Bathgate.

exponention-operator.patch (2K) Download Attachment