2D Shapes and Extrusions

Up until now we have been exclusively dealing with 3D objects, and putting them together, normally this is enough, but some objetcs are easier to create in 2D first.

In 2D we have 3 main primative objects, circles, squares and text. Lets first discuss text as this is the least useful of the primative objects in 2D.

text("String of text"); will result in the text being displayed in the x-y plane. pressing crtl+4 will reorientate the dislay so that you are looking down from the top onto your 2D objects. There are a few additional options you can include when creating a text object: size, the approximate extension along y of the text characters; font,the font of the text; halign, 3 options “left”,”right” and “center” remembering to include the quotation marks; valign, four options this time, “top”, “bottom”, “center” and “baseline, normally “baseline” and “bottom” would be the same unless you have letters that extend down (gjpqy) for which “bottom” aligns to the bottom of the lowest letter and “baseline” to the what would be the bottom of most letters; spacing, determines the letter spacing, with spacing=2 spacing the letters at twice the normal sepperation ; direction, four options “ltr”,”rtl”,”ttb” and “btt” again with the quotation marks included standing for left to right, right to left, top to bottom and bottom to top respectively; language, the language in which the string is written; script, the type of script use for the text.

Now lets move on to what are the more useful (in my opinion) of the primitive 2D objects, circle() and square(). As with sphere and cube there are a few ways to define their properties, either using the circles radius or diameter, and setting center =true for the square. but in principle these properties are the same as their 3D counter parts. our transformations (union, intersection, difference, minkowski and hull) all work as before for these objects too.

Now where 2D objects come into there own is when you use them to construct 3D shapes, either through rotating them, or by extruding them. Lets start with an example of rotate_extrude on the above object, cut in half so that we can see what is going on inside:

As you can see the result has been a Torus type object with a void in the shape of the text that cuts through it. There are a few things to bare in mind for now when using the rotate_extrude() command, firstly make sure that your objects are all positive in x before you rotate otherwise things wont work, and secondly the object you lay out in x-y will now be the y-z cross section. Provided you keep these things in mind this is a great way to model anything with rotational symetry.

Next up is the linear_extrude(){...} command. This takes a 2D shape and stretches it along the z-axis to construct a 3D object. In its simplest form you pass run linear_extrude(height=z){...}, where z is the distance you would like to extrude the 2D shape. As well as extruding a distance the linear extrude also alows you to rotate the 2D shape around as it is extruded. This can be used to create shapes that sprial around. Lets look at an example of using this to make a spiral shape


So as we can see here, first we make a cross section for our auger, and extrude it up by 200 and twist it through 360 degrees. This helix shape is then used in an intersection to give it a point on one end. A point to note is that the rotation that is applied will always be around the z-axis, this allows you to make things like spirals without having a central axis.

Another parameter you can pass to the linear_extrude function is center=true, with causes final extrusion to be centred at z=0, extending both up and down. A final parameter for linear_extrude(){...} is slices=n, this tells the extrusion process how many layers to make up the final 3d shape from, this is especially useful if you have a part with a large number of twists but will not normally be needed, but use this if you make an extrusion that looks a little rough.

Share This:

Leave a Reply

Your email address will not be published. Required fields are marked *