Results 1 to 10 of 72
Thread: OpenScad Help Centre
Threaded View
-
11-30-2014, 12:25 PM #11
Few simple tips that became quick tutorial on the HULL command :-)
Great idea emu :-)
In the tips side of the equation.
1) use diameter NOT radius. ie: cylinder(d=10,h=5);
several reasons. 1) it's much easier to visualise if you don't have to keep doubling the radius in your head.
2) makes calculations much easier when you don't have to double everything.
Example: a sphere with a radius of 6mm is actually 12mm across. So why not just use d=12 and never have to worry about how big it is.
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 under stand the polygon command' ?
Okay lets use a real world example of a model rocket.
The cylinder is easy and the pointy top is just another cylinder with different starting and finishing diameters.
$fn=100;
cylinder (d=20,h=40);
translate([0,0,40]) cylinder(d1=20, d2=1, h=20);
This gives you the basic rocket trunk - I like round things to be round and we're not going to get complicated here, so facets = 100: is set as a global variable.
Now to make fins you could make a thin cube, then make another cube the same size and rotate and translate it in a difference command to remove half the cube and leave a triangle. Or you could set a cylinder to have 3 facets and then stretch it. Both of which are unnecessarily complicated
OR
You can do this:
//making rocket fin
hull() {
translate([-1,0,0]) cube([2,25,0.1]);
translate([-1,0,40]) cube([1.5,0.1,0.1]);
} //end of hull command
So we're drawing a long thin cube that sticks out from the bottom of the rocket. Then we're drawing a small cube further up the rocket.
Pretty useless so far. But then we tell opesncad to form a shape or HULL between the two cubes and viola, we have a fin.
We can then duplicate and rotate this to make more fins:
//second fin
rotate([0,0,120]) {
hull() {
translate([-1,0,0]) cube([2,25,0.1]);
translate([-1,0,40]) cube([1.5,0.1,0.1]);
}
} //end of rotate
//third fin
rotate([0,0,240]) {
hull() {
translate([-1,0,0]) cube([2,25,0.1]);
translate([-1,0,40]) cube([1.5,0.1,0.1]);
}
} //end of rotate
we now have: a solid rocket with 3 fins:
All that's left is to remove a hole for the rocket motor.
Now because I don't do elegant, I can't just remove a cylinder from the rocket centre. Because that would leave the fins behind in the hole.
So what I'm going to do is stitch everything together with a union command (openscad's equivalent of duct tape)
And then I can remove a hole for the motor from the entire rocket:
Which gives the finished rocket:
$fn=100;
difference() { //removes cylinder from entire ducttaped model
union() {
cylinder (d=20,h=40);
translate([0,0,40]) cylinder(d1=20, d2=1, h=20);
hull() {
translate([-1,0,0]) cube([2,25,0.1]);
translate([-1,0,40]) cube([1.5,0.1,0.1]);
}
//second fin
rotate([0,0,120]) {
hull() {
translate([-1,0,0]) cube([2,25,0.1]);
translate([-1,0,40]) cube([1.5,0.1,0.1]);
}
} //end of rotate
//third fin
rotate([0,0,240]) {
hull() {
translate([-1,0,0]) cube([2,25,0.1]);
translate([-1,0,40]) cube([1.5,0.1,0.1]);
}
} //end of rotate
} //end of union to stitch the whole model together
cylinder (d=16,h=38); //removes hole for rocket motor
} //end of difference to remove hole for motor
Now this is all well and good and gives a conventional rocket with straight fins.
But say you want to give a little slant to your fins to spin the rocket.
You could piss about with rotate and rotate the fins on another axis. Or you could simply move the top cube:
hull() {
translate([-1,0,0]) cube([2,25,0.1]);
translate([-5,0,40]) cube([1.5,0.1,0.1]);
}
Change the fin code so that the top cube is moved an extra 4mm to the right and you end up with this:
Last edited by curious aardvark; 11-30-2014 at 12:40 PM.
Please explain to me how to...
Yesterday, 12:15 PM in 3D Printer Parts, Filament & Materials