Close



Results 1 to 10 of 72

Hybrid View

  1. #1
    Staff Engineer old man emu's Avatar
    Join Date
    Oct 2013
    Location
    Narellan, New South Wales, Australia
    Posts
    912

    Please list the Primitives available in OpenScad

    Most of the tutorials show two primitives : cube and sphere. Are there any other Primitives?

    Old Man Emu

  2. #2
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,182
    Quote Originally Posted by old man emu View Post
    Most of the tutorials show two primitives : cube and sphere. Are there any other Primitives?

    Old Man Emu
    Section 3.1 of the Wikipedia User Manual says:

    3.1 Primitive Solids - cube, sphere, cylinder & polyhedron

    http://en.wikibooks.org/wiki/OpenSCA...imitive_Solids

    The Polyhedron is difficult to use. The points used to construct it have to be carefully ordered. But the other three are very straight forward to use.
    Last edited by Roxy; 11-28-2014 at 06:07 PM.

  3. #3
    Staff Engineer old man emu's Avatar
    Join Date
    Oct 2013
    Location
    Narellan, New South Wales, Australia
    Posts
    912

    What do the round and curly brackets mean?

    Here is a random bit of code I found in a tutorial:

    difference() {
    union() {
    // teardrop shape
    sphere(r = 20);
    translate([0, 0, 20 * sin(30)])
    cylinder(h = 30, r1 = 20 * cos(30), r2 = 0);

    // dollop
    translate([0, 0, 30 + 20 * sin(30)])
    sphere(r = 6);
    }
    //cut out slot
    rotate([45, 0, 0])
    translate([-20, 0, 0])
    cube([40, 5, 40]);
    }

    What is the meaning or function of:

    1. the round brackets - Difference () Union ()
    2. Wiggly brackets {lines of code}
    3. stuff inside square brackets [ ]

    I know that // indicates a coder's comment that does not get read when the code is run.

    OME

  4. #4
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,182
    Quote Originally Posted by old man emu View Post
    What is the meaning or function of:

    1. the round brackets - Difference () Union ()
    2. Wiggly brackets {lines of code}
    3. stuff inside square brackets [ ]

    I know that // indicates a coder's comment that does not get read when the code is run.
    OpenScad evolved and was never really well thought out in advance. The syntax of the language shows that. They wanted it to look like C but the fundamentals of the language are different. OpenScad does not even allow variables to change value during 'execution'. The parts of the language where it looks like that is happening are not real. For example the 'for' loops. The compiler is just in-line compiling the code blocks with different values of the index 'variable'.

    Probably, the round brackets on Difference() and Union() are just to denote that you are performing a 'function'. But that deviates from their usage in C where you are passing in parameters within the ().

    The square brackets are more consistent. If you see square brackets [], the contents is going to be used as a vector (or a point).

    OpenScad is a great tool. But IMHO it is an abomination from a syntax perspective. Just as people study different spoken languages to understand how one language or dialect evolved from another and influenced thought on this subject or that one... OpenScad provides a Computer Language equivalent. Somebody could write a PhD thesis on the subject.

    The syntax is chaotic and a mess.... (But I do like OpenScad!!!!)

  5. #5
    Staff Engineer old man emu's Avatar
    Join Date
    Oct 2013
    Location
    Narellan, New South Wales, Australia
    Posts
    912
    Thanks for those comments, but I think I asked the wrong question to get the answer I needed.

    The more correct questions would be:

    1. What does each type of bracket enclose, and what is the order of precedence?
    2. What would the example read like if it was written like a paragraph of text in a novel? In other words, what is the long hand version of this?

    OME

Posting Permissions

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