![]() ![]() But how do we combine shapes conveniently? Often, we have a shape to repeat in different places, like PCB support pillars with the hole for a screw and a bevel at the base. Parametric designs are probably one of the most important characteristics of Openscad. Two "mugs" made from the same source code: only two numbers were changed ( height and width) ! ![]() Why? Because if you needed to add a regular cylindrical hole in the intersection for example, it would be itself ellipsoidal! And this is exactly what we wanted: it makes life easier than to intersect a regular cube with a sphere and then elongate the whole even though the result is the same. Here we apply it only to one primitive, the sphere, to elongate it vertically so it matches the cuboid. Nothing is "square" anymore (or respectively, well-oriented)! A good indicator that an operator is used "too soon" in the CSG tree is when you suddenly feel the need to reverse its effect (un-scale or de-rotate before you add sub-shapes).īetter use "scale( )" sparingly, and only when required, closest to the shape that needs it. Just like rotation, scale is an annoying operator because all subsequent axis geometry gets modified. In the above parametrized source, the formerly almost global "scale( )" operator was moved "down in the CSG tree". Especially, there should be one and only one place to set the geometric dimensions. Most of the internal stuff is computed out of a minimum set of variables that make sense in the design. First, extract and name appropriately the main characteristics of your design:Ī "good" Openscad source code should almost have no numerical values. depends on variables)īack to our mug to make it parametric. Parametric rewrite of the mug source (i.e. In fact, readability is a second benefit, because the foremost advantage is to get rid of rogue "20" or "10" in the source code that are anonymously related to the body size! It is easier to read a source code with variables because you can give meaningful names to them: this "body_diameter" makes more sense than any number buried in a mathematical expression.įor example, you can now replace an obscure shape like this:īy this one, which is much more readable: There are two advantages to use variables: readability and convenience. Once a variable is given a value, it can be used as if it was a number. You can also use underscores and digits, but the first letter must be a letter and no space is allowed in the name: hence "width", "my_cube_width", "cubeDim1" are three valid variable names (without the double quotes!). ![]() We are first going to replace most of the numbers by straightforward expressions that refer to variables instead of numbers.Ī variable is just an "alphanumeric tag": it is a name made of letters that mean something for you.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |