Results 11 to 20 of 32
Thread: First attempts in openSCAD
Hybrid View
-
03-12-2021, 09:11 AM #1$fn=60; // set 50 facets to give us nice round holes that rendet fairly fast
module box(){
difference(){
translate([0,0,25])cube([100,100,50],center=true); // start with a block of wood - because it is centred in all 3 axis, we'll lift it 25mm with translate so that's at 0 on the z axis.
cylinder(d=20,h=55); // cylinders are always centred on 0,0,0 before youmove them. so we drill a 30mm hole through the centre of the block
// we'll cut another couple of holes
translate([35,30,-5]) cylinder(d=3,h=10);
translate([35,-30,-5]) cylinder(d=3,h=10);
translate([0,0,27]) cube([92,92,50],center=true); // we remove a chunk from center of the the box to leave a 2mm floor and 4mm walls all around.
translate([2,0,46.5]) cube([96,96,2.5],center=true); // creates a 2.5mm groove in three sides.
translate([48,0,51]) cube([10,92,10],center=true); // we then remove the excess wood to make it easier to print
} // end diff
} // end module
Ah but wait, we have isolated the script - but we haven't told openscad what to do with it.
so the generate the module box()
we need to tell openscad that's what we want to do:
$fn=60; // set 50 facets to give us nice round holes that rendet fairly fast
module box(){
difference(){
translate([0,0,25])cube([100,100,50],center=true); // start with a block of wood - because it is centred in all 3 axis, we'll lift it 25mm with translate so that's at 0 on the z axis.
cylinder(d=20,h=55); // cylinders are always centred on 0,0,0 before youmove them. so we drill a 30mm hole through the centre of the block
// we'll cut another couple of holes
translate([35,30,-5]) cylinder(d=3,h=10);
translate([35,-30,-5]) cylinder(d=3,h=10);
translate([0,0,27]) cube([92,92,50],center=true); // we remove a chunk from center of the the box to leave a 2mm floor and 4mm walls all around.
translate([2,0,46.5]) cube([96,96,2.5],center=true); // creates a 2.5mm groove in three sides.
translate([48,0,51]) cube([10,92,10],center=true); // we then remove the excess wood to make it easier to print
} // end diff
} // end module
box();
Now we need to make our sliding box lid. Essentiall just a basic cube.
We know how large the cube was that crated the groove - so we make the lid a little smaller in width and thickness so it slides in and out easily.
we create module lid() and comment out module box() - so that when we press f5 or f6 - we only generate the part we want to export as an stl file.
$fn=60; // set 50 facets to give us nice round holes that rendet fairly fast
module box(){
difference(){
translate([0,0,25])cube([100,100,50],center=true); // start with a block of wood - because it is centred in all 3 axis, we'll lift it 25mm with translate so that's at 0 on the z axis.
cylinder(d=20,h=55); // cylinders are always centred on 0,0,0 before youmove them. so we drill a 30mm hole through the centre of the block
// we'll cut another couple of holes
translate([35,30,-5]) cylinder(d=3,h=10);
translate([35,-30,-5]) cylinder(d=3,h=10);
translate([0,0,27]) cube([92,92,50],center=true); // we remove a chunk from center of the the box to leave a 2mm floor and 4mm walls all around.
translate([2,0,46.5]) cube([96,96,2.5],center=true); // creates a 2.5mm groove in three sides.
translate([48,0,51]) cube([10,92,10],center=true); // we then remove the excess wood to make it easier to print
} // end diff
} // end module
module lid(){
cube([95.5,96,2]);
} // end mod
//box();
lid();
Although on reflection it would be a total bastard to print. I was concentrating more on the openscad tutorial side than the actual box I'm afraid.
But yeah, thinking like a wood worker is how i tend to do it.
You are either removing bits of a shape or sticking other bits to it.
I'll have some lunch and make a better bird box lol
Finally the basic script - without all the waffle:
$fn=60;
module box(){
difference(){
translate([0,0,25])cube([100,100,50],center=true); axis.
cylinder(d=20,h=55);
// we'll cut another couple of holes
translate([35,30,-5]) cylinder(d=3,h=10);
translate([35,-30,-5]) cylinder(d=3,h=10);
translate([0,0,27]) cube([92,92,50],center=true);
translate([2,0,46.5]) cube([96,96,2.5],center=true); // creates a 2.5mm groove in three sides.
translate([48,0,51]) cube([10,92,10],center=true);
} // end diff
} // end module
module lid(){
cube([95.5,96,2]);
} // end mod
//box();
lid();
-
03-12-2021, 11:41 AM #2
- Join Date
- Mar 2021
- Posts
- 63
Excellent, thanks a bunch, really appreciate your putting so much time and effort into that.
It's going to take me a while to step through it methodically, but it's already clear that your help will greatly accelerate my crawl up the learning curve!
-
03-12-2021, 11:49 AM #3
- Join Date
- Jun 2014
- Posts
- 885
@terrypin, I've used both OpenSCAD and Fusion360 and like both of them for what little I can do in either program. I've learned that some people take well to OpenSCAD and others run away. FreeCAD is now on my machine, but I'll probably put off the hours of YouTube tutorials, especially if I can get the job done with F360 or OpenSCAD.
If you can build your code from square one using parameters and relationships, you'll have a good start. I like to test my code by changing a value, to see if the other settings follow. Sometimes the hole you thought would adjust to the new figure ends up in outer space and you debug to find the failed relationship. That's part of the fun (sometimes).
-
03-12-2021, 02:03 PM #4
- Join Date
- Mar 2021
- Posts
- 63
Thanks Fred. Sounds like we share a similar practical attitude to this stuff.
-
03-12-2021, 01:06 PM #5
Tinkercad used to be useful.
But as you can't seem to either import or export anymore, seems to have gone downhill since the last update.
Yet another argument against cloud software.
At least with normal programs you can get hold of the older versions that actually work ????
-
03-12-2021, 02:23 PM #6
- Join Date
- Jun 2014
- Posts
- 885
I'd forgotten about Tinkercad, although a friend uses it exclusively. I just signed in and found that download and export (.obj, .stl) work, as does import. Something amiss?
-
03-14-2021, 06:32 AM #7
- Join Date
- Aug 2020
- Location
- United Kingdom
- Posts
- 249
Hi I am sorry to here you have had trouble getting Fusion360. as Fred-u-dot says it has a completely different approach to OpensCad. I have used both but having come up through AutoDesk prodects since AcadV13 in 1982 I am more comfortable in their approach.
-
03-14-2021, 12:43 PM #8
- Join Date
- Mar 2021
- Posts
- 63
Thanks printbus. I'm stepping through examples here and in several tutorials, so making progress.
But patience isn't one of my strong points, so it's good to have others' models and code to build on. When working on that first box I changed only its dimensions so felt on reasonbly safe ground.
-
03-15-2021, 08:58 AM #9
here's some homework then.
take the 'birdbox'.
remove the end where the lid slides in.
Then create a seperate piece that glues there (two cubes one on top of the other would do it).
That way you can orient the box on the bed with the grooves vertical for easy printing and print the lid and side flat and seperately.
That's what I was going to do - but I got sidetracked, I frequently get sidetracked for days, sometimes years...
-
03-15-2021, 03:47 PM #10
- Join Date
- Mar 2021
- Posts
- 63
Thanks, a fascinating possible exercise. But I'm in the same boat: in fact I'm currently in a sub-sidetrack of a sidetrack!
Qidi X Plus 3 Paper thin first...
05-27-2024, 01:15 AM in General 3D Printing Discussion