Close



Page 1 of 8 123 ... LastLast
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

    OpenScad Help Centre

    From Wikipedia ( http://en.wikipedia.org/wiki/OpenSCAD )

    OpenSCAD is a free software application for creating solid 3D CAD objects. It is not an interactive modeler, but rather a 3D-compiler. OpenSCAD reads from a script and renders a3D model from it. It does constructive solid geometry (CSG). The results can be rendered into 3D STL files. OpenSCAD allows a designer to create accurate 3D models and parametric designs that can be easily adjusted by changing the parameters. OpenSCAD is a non-visual, programmer-oriented solid modeling tool. OpenSCAD has been recommended as an entry-level CAD tool for designing open source hardware such as scientific tools for research and education.

    The program can be obtained from here: http://www.openscad.org/downloads.html and there are lots of tutorial videos on Youtube (some good, some bad) which provide an introduction to using the program. At first glance, OpenScad looks to be a good program for designing things in the Art Deco style. A lot of members here who are more experienced in creating objects swear by OpenScad. On the other hand, there are other members whose thinking is more in the Art Nuveau style who prefer the Blender type of software. I don't want to start a discussion about which sytle is better. We are an eclectic lot here, and accept all comers.

    THE REASON for starting this thread is to provide a Help Centre for those who want to learn how to use OpenScad. Just pose your question using the [GO ADVANED] page so that you can create a title for your question. The Help posse is not too far away.

    Old Man Emu



  2. #2
    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

  3. #3
    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.

  4. #4
    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

  5. #5
    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!!!!)

  6. #6
    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

  7. #7
    Senior Engineer
    Join Date
    Jun 2014
    Location
    Burnley, UK
    Posts
    1,662
    Where I started, I just need to figure moving past this.

    http://blog.cubehero.com/2013/11/19/...s-in-openscad/
    Last edited by Roxy; 11-28-2014 at 06:06 PM. Reason: Fix spelling error

  8. #8
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,182
    On difference() and union() and intersection() the ()'s have to be there... But nothing goes inside them.

    The curly braces {} enclose lines of code to form a 'statement' or 'block'. Everything within the first set of curly braces gets operated on by difference(), union() and intersection. Instead of parameters getting passed within the () as in C, the things that are going to get operated on are in specific places with the {}'s. (ie. things get subtracted from the first object specified in the {}'s of a difference() ).

    But in cube(), sphere(), etc... Parameters are passed inside the ()'s. So you can say something like sphere(r=10); Or cube( [3,4,5] ); Or cylinder(r=4, h=20);

    The English text version of that example would read something like:

    First add together (using union()) a sphere of radius 20, and cone moved up somewhat). Add a little sphere to the top of that. And then take a slice out of the resulting object.

    You can put a # in front of any line of code in OpenScad to see what it is producing. The best thing to do would be to put a # on a line and see what it is generating on the redered picture.
    Last edited by Roxy; 11-29-2014 at 04:42 PM.

  9. #9
    Staff Engineer old man emu's Avatar
    Join Date
    Oct 2013
    Location
    Narellan, New South Wales, Australia
    Posts
    912
    What about the semi-colon; ?

    OME

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

    Understanding OpenScad Punctuation

    I have been studying the punctuation in OpenScad and think I've got it under control. I've written up my findings and present them here for your information and critique.

    Understanding OpenScad Punctuation
    The OpenScad manual goes on for pages and pages giving examples of code which explains the many functions the program can do, however, when someone without a background in programming first looks at some OpenScad coding for an object, or tries to create some, they find that there is no explanation of the punctuation used to get things done. If the punctuation is not correct, nothing works.
    Here are the punctuation symbols used by OpenScad, and how their function.

    PUNCTUATION SYMBOL FUNCTION
    //

    /* and */
    // is used to insert Coder’s comments into the coding. Anything written on the same line is invisible to the program. If the comment goes into two or more lines, each line must begin with // to continue hiding its content. If the comment goes on for more than three lines, mark the first comment line with /* and end the comment with */
    { and } Braces hold things in a group. They must be used in pairs with each opening brace { matched with a closing brace }
    ( and ) Parentheses are used to hold the parameters of an object or operator. The parameter could be the radius of a circle or sphere, or it could be the co-ordinates of a point in space. When used with Boolean operations, the parentheses are left empty.
    [ and ] Square Brackets are used to hold the parameters that describe width and height of squares and also the depth of cubes. When used with Transformations, they hold the x,y and z coordinates associated with the particular operator (Translate, Scale, Mirror etc.) within parentheses.
    ; Semi-colons are the symbol that says “Do it!” A semi-colon is placed at the end of the coding that defines the object to be created. If the semi-colon is omitted, nothing is created. The automatic debugging facility in OpenScad will place a marker in the code to indicate where the bug is hiding.

    Here is a bit of code that will make the top of a chess bishop. It was copied from here: http://blog.cubehero.com/2013/11/19/...us-in-openscad

    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) ;
    }

    Here is an explanation of what each line means and what OpenScad does with it:

    The Code The Meaning
    union() I am going to join some things together
    { all the code down to the colon after (r=6)} This is the group of things I am going to join
    // teardrop shape This is the name I gave to one of the parts of the object I am going to make.
    From sphere(r = 20); to r2 = 0 These steps are how I made the teardrop shape
    sphere(r = 20) This made a sphere with a radius of 20 units centred on the Origin (0,0,0)
    ; This ended the making of the sphere and let Openscad proceed to the next bit of the shape.
    translate([0, 0, 20 * sin(30)]) This told OpenScap to move the centre of the next shape I defined to a point (20 x sin (30) up the Z-axis above the Origin (0,0,0)
    cylinder(h = 30, r1 = 20 * cos(30), r2 = 0) This made a cone 30 units high with its base radius (20 * cos 30) and the top radius a point
    ; This ended the making and positioning of the cylinder and let Openscad proceed to the next bit of the shape
    // dollop This is the name of the next part of the thing I am going to make.
    From translate to the colon after (r = 6) These steps are how I made the dollop
    translate([0, 0, 30 + 20 * sin(30)]) This told OpenScap to move the centre of the next shape I defined to a point (20 x sin (30) up the Z-axis above the point (0,0,30)
    sphere(r = 6) This made a sphere with a radius of 6 units, centred on the point defined in the Translate command just before it.
    ; This ended the making of the dollop and let Openscad proceed to the next bit of the shape.
    } This told OpenScap that I had reached the end of the job of positioning and joining the shapes I made.
    Last edited by old man emu; 11-30-2014 at 02:48 PM. Reason: remove Caps from names as required

Page 1 of 8 123 ... LastLast

Posting Permissions

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