Close



Results 1 to 10 of 74

Threaded View

  1. #15
    Senior Engineer
    Join Date
    Jun 2014
    Location
    Burnley, UK
    Posts
    1,662
    I don't understand this. I think Openscad is running out of resources ror something.

    This draws the toroid but why do I need the "assign" statement again.
    r0 = 100;
    r1 = 10;




    for (v = [0:10:180])
    {
    for (u = [0:10:360])
    {
    assign (A = ((r0 + r1 * cos(v)) * cos (u)), B = ((r0 + r1 * cos(v)) * sin (u)), C = (r1 * sin(v)))


    translate ([A,B,C])
    sphere (r=1);


    assign (A = ((r0 + r1 * cos(v)) * cos (u)), B = ((r0 + r1 * cos(v)) * sin (u)), C = (r1 * sin(v)))


    translate ([A,B,-C])
    sphere (r=1);
    }
    }

    This draws the top:

    r0 = 100;
    r1 = 10;




    for (v = [0:10:180])
    {
    for (u = [0:10:360])
    {
    assign (A = ((r0 + r1 * cos(v)) * cos (u)), B = ((r0 + r1 * cos(v)) * sin (u)), C = (r1 * sin(v)))


    translate ([A,B,C])
    sphere (r=1);


    // translate ([A,B,-C])
    // sphere (r=1);
    }
    }
    and this draws the bottom:

    r0 = 100;
    r1 = 10;




    for (v = [0:10:180])
    {
    for (u = [0:10:360])
    {
    assign (A = ((r0 + r1 * cos(v)) * cos (u)), B = ((r0 + r1 * cos(v)) * sin (u)), C = (r1 * sin(v)))


    // translate ([A,B,C])
    // sphere (r=1);


    translate ([A,B,-C])
    sphere (r=1);
    }
    }
    But, this does not draw it correctly:

    r0 = 100;
    r1 = 10;




    for (v = [0:10:180])
    {
    for (u = [0:10:360])
    {
    assign (A = ((r0 + r1 * cos(v)) * cos (u)), B = ((r0 + r1 * cos(v)) * sin (u)), C = (r1 * sin(v)))


    translate ([A,B,C])
    sphere (r=1);


    translate ([A,B,-C])
    sphere (r=1);
    }
    }
    It sticks the bottom half as an object in the centre. :baffled:


    Hmm, not so baffled, the assign statement only operates on the next statement so it does what it should in the above examples.


    Last edited by Mjolinor; 12-05-2014 at 11:56 AM. Reason: Brain started working

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •