OpenSCAD Tips and Tricks

OpenSCAD Tips and Tricks


Right triangles

in the OpenSCAD documentation they say how to make a triangle. They use an array of points and then you can use another array to make each and every face on the object. Now I see that this can be helpful on some things! But this is a terrible example, because a triangle is simple to make

module triangle(){
        rotate([0,0,45]) cube([50,50,50]);

This will make a triangle with a 90 degree angle!

Equilateral Triangle

If you want to make a equilateral triangle you use a cylinder, this is kind of a weird thing to think of. But we are using a cylinder with a specified number of sides, this can be extremely useful in a number of ways. But we can use it this time to make a triangle.

cylinder(r=5, h=5, $fn=3);

That $fn=3 is the magic! This tells the program that it is only allowed to use 3 sides to make a cylinder, and the best it can do it a equilateral triangle.

Define the number of sides

$fn and $fs

I'm not sure using $fn is a proper etiquette, but I am going to use it anyways. This tells whatever shape that it can only use that number of sides, this is only really helpful with cylinders and spheres. a cube always has 6 sides, and can never change. So say you want a low-poly sphere, this could be cool to make some low-poly art projects. You can use $fn to say how low you want to poly count on the sphere.

resolution = 5;
$fn = resolution;

You can set the number of faces as a global thing. if you just put a $fn at the top of the file it will be applied to everything in the file.

resolution = 5;
$fs = resolution;

If you use $fs it will take the default number of faces on your object and take away thing number or faces, so if you want large things to be more rounded, because they are large, but you still want it to be more low-poly you can use this. A small cylinder might turn into a triangle, but a large cylinder would turn into something like a octagon.

Modify STL files

If you have an STL file and you want to modify it in a specific way you can. Everyone know that taking something into blender is not perfect every time, so if you want to make a hole larger. You can import a STL file and then do a difference with that model and the cylinder that is a diameter that you want.

module stl(){

cylinder(r=5, h=10);

So you have to put the STL file in a module you can not just use it like any other object. But if you remember that then you are good to go, once it is in a module you can modify it in any way that you want to.


Popular posts from this blog

Rounded corners in openScad

m31 finger magnet rejection