Gleanings from this thread.
In an attempt to consolidate the important things that have been said, I went through this thread and pulled out the tid-bits of information that advanced the topic. I've indicated who made the post, and the post number.
I don't expect any replies to this current post. It is meant to be a hold-all so we can move on.
Roxy Post # 4
The Polyhedron is difficult to use. The points used to construct it have to be carefully ordered.
Roxy Post # 6
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).
Roxy Post # 8
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);
You can put a # in front of any line of code in OpenScad to see what it is producing.
Old Man Emu Post # 10
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.
curious aardvark Post # 12
1) use diameter NOT radius. ie: cylinder(d=10,h=5);
2) the hull command.
This is a brilliant command and answers a lot of questions. Like: how do i make a wedge ? Can i make non equalatrial triangles. And 'how on earth do I make an irregular shape without having to try and understand the polygon command' ?
curious aardvark Post # 17
Don't forget that openscad is text based - so you can use normal text tools. I used copy and paste in the above script. But say you haven't made fins a module (which i didn't), but want to change all three at once. Click edit and select Find and Replace. Then put -5 in the find box and -7 in the replace box. Hit all and f5. And the angle of all three fins changes.
Admittedly this only works if you haven't used a -5 anywhere else.
Old Man Emu Post #22
Transformations have to be coded before the object the operate upon.
Roxy Post #34
A sphere and cylinder are always generated at (0,0). So when you translate them... what ever amount you translated them... Is where the center's are.
In OpenScad you should have a 'Top Level' geometry. That is what that first singleduploblock(); is. It references other stuff, but it is at the top level.singleduploblock() does not have any parameters, and certainly does not need its name passed in as a parameter.
curious aardvark Post #38
But the really weird thing is that you used a cube command with no square brackets. And it worked. cube (32,32,20);
Roxy Post # 39
I suggest you put the [32,32,20] inside of brackets. If for no other reason than everybody else does and expects to see that.
Roxy Post # 49
What's a facet command? Searching the OpenScad manual doesn't find any reference to that. Update: I figured out what you meant. I suspect you are talking about the $fn parameter
Roxy Post # 62 in http://3dprintboard.com/showthread.php?8855-Need-some-geometry-help
the pow() function takes two parameters. The first number is the base and the second parameter is the exponent. pow(x,y) will raise x^y. Using a pow(3,4) would be equivalent to saying 3*3*3*3. You are raising 3 to the 4th power.
Old Man Emu
Modules - OpenScad's answer to toolbar icons?
I was reading this, http://blog.cubehero.com/2013/12/18/...d-code-part-i/ and came across this example of a module,
module ring(height, radius, radial_width) {
difference() {
cylinder(h = height, r = radius + radial_width / 2);
translate([0, 0, -1])
cylinder(h = height + 2, r = radius - radial_width / 2);
}}
After studying it for a while, it dawned on me that the module was like an icon on the object creation toolbar of a GUI based progam like Rhino. With Rhino, if I want to create a 3D object, or perform some action on one, I click on an icon on a toolbar, or in a drop-down menu. Then the program prompts me to input the parameters necessary to achieve the particular result at the time. In OpenScad, there is no icon, but a block of text called a "module". These modules are user created and result in the creation of a specific object.
Having created a general set of steps that OpenScad must take to create an object, it only requires the user to provide the parameters specific to the object being made at the time. This is done by writing this:
ring (height, radius, radial width) in the body of the code. To keep with convention, this would actually be coded as ring(h,r,rw)
This would be how it would appear in practice:
// ring implemented with rotational extrusion
module ring(height, radius, radial_width) {
rotate_extrude()
translate([radius, 0, 0])
square([radial_width, height]);
}
// There might be lines and lines of code before the need to enter specific values //to create the ring
ring(4,10,5);
QUESTIONS:
1. Say I've just created a module to make a whatsit, and I'm going to be making whatsits of various sizes in the future. If I click on <Save As> in Openscad do I save my .scad file here
C:\Program Files\OpenSCAD\Libraries?
2. If I've saved my module as whatsit.scad, can i create a whatsit using this bit of code:
use <whatsit.scad>
whatsit (parameters);
3. Which is better practice, putting this in the code:
module ring(height, radius, radial_width)
{ difference()
{ cylinder(h = height, r = radius + radial_width / 2);
translate([0, 0, -1])
cylinder(h = height + 2, r = radius - radial_width / 2);
}}
or this:
use <ring.scad>
ring(h,r,rw);
OME