Results 1 to 10 of 32
Thread: First attempts in openSCAD
-
03-10-2021, 11:28 AM #1
- Join Date
- Mar 2021
- Posts
- 63
First attempts in openSCAD
I'm completely new to 3D Printing and am not a programmer. I've assembled a generous gift of an Ender 3 V2 and yesterday successfully printed a small model from thingiverse, unchanged (3hrs 22m). But now I want to learn how to design my own or, more likely, to customise others' models.
openSCAD-FirstUse.jpg
In thingiverse I found a possibly suitable model called 'Ultimate_Box_Generator ' and Download Files delivered these two files:
Box_Template.scad
Ultimate_Box_Generator.scad
I wasn't sure but chose the second file (62 KB).
Q1: When would I need the template file (12 KB)?
I'd seen openSCAD recommended here and elsewhere so I installed that and opened the file. It looked dauntingly complicated (see screenshot) but the thing that puzzles me most is
Q2: Why are there so many 'errors' in its Error Log and Console?
Q3: What should I have done about them? (What I actually did was ignore them!)
I made my changes: x = 100, y = 50, z = 35. I think I may have also changed the 'wall' to 2.5. (My first attempt at this was directly from thingiverse Customizer. It froze and behaved in other quirky ways, which triggered my search for an off-line version.)
Apparently I could do this trivial editing directly in the code, near the top, or using the marginally friendlier Customizer section. I saved the revised scad file with a new name.
After also reading that Ultimaker Cura was popular I then opened the scad file in that and saved it as a gcode file.
Q4: Must 3D printers be presented with a gcode file, no other types, and in the root of the SD card?
Q5: Is there anything else I should have done in Cura apart from clicking the Slicer button?
The Ender 3 V2 is now printing - despite those numerous 'errors'!
Terry, UKLast edited by terrypin; 03-27-2021 at 12:42 PM.
-
03-10-2021, 05:42 PM #2
- Join Date
- Jun 2014
- Posts
- 892
Congratulations on trying your modeling by using OpenSCAD. I've found that sometimes it can be far more challenging to solve problems in someone else's code.
Unfortunately, your screen shot resolution is too low to see the error messages.
-
03-11-2021, 08:03 AM #3
well that is insanely long for a simple box generator. I suppose it does have a lid as well.
But honestly you are better off starting by making your own. #
A simple box is a great way to start:
difference(){
cube ([50,20,10],center=true);
translate([0,0,2]) cube ([46,16,10],center=true);
} // end difference
To make this parametric you just need to indulge in a little algebra and throw in some variables
bl=50; // box length
bw=20; // box width
bh=10; //box height
wt=2; // wall thickness
bt=1; // base thickness
difference(){
cube ([bl,bw,bh],center=true);
translate([0,0,bt])cube ([bl-2*wt,bw-2*wt,bh],center=true);
} // end difference
To make a different shape box you use cylinders instead of cubes and change the number of facets to the shape you want.
so a 4 facet cylinder is a cube and a 3 facet cylinder is a triangle. You use a resize command to change the shape from a fixed diameter 'cylinder' to the length and breadth you specify. :
bl=50; // box length
bw=20; // box width
bh=10; //box height
wt=2; // wall thickness
bt=1; // base thickness
bs=3; // box shape
difference(){
resize([bl,bw,bh]) cylinder(d=10,h=10,$fn=bs);
translate([0,0,bt]) resize([bl-2*wt,bw-2*wt,bh]) cylinder(d=10,h=10,$fn=bs);
} // end difference
So you start with a simple centred cube and difference a smaller cube - if you center it you don't have to muck about with moving it about to get it centred yourself.
wall thickness happens on both sides of the shape - so you always have to multiply it by 2.
In the second example you use algebra to make the sizes variable.
And in the third example you use different number sided 'cylinders' to change the number of sides of the shape.
A resize command over rules all subsequent sizes - so it doesn't matter what size you make the original cylinder.
I don't do programming - so i approach openscad very differently to programmers.
I like to make it easy to read what I've done - so I use short variables and never indent anything. Most programmers use whole sentences for variables and end up with something almost unguessable - in my opinion ;-)
The beauty of openscad is that you can write the scripts any way you like.
The way I approach a design problem is also simple.
work out what you want to make and then break it down into simple shapes. Then work out what shapes need to be added or removed and where they need to be and go from there.
It does seem daunting at first.
But once you've got your own script style that you can read and have worked out what the commands do - it's really a lot better and more precise than moving stuff around with a mouse.
And so much faster !
Also - and one of it's best points - everything generated by a script is a solid shape that will print.
No errors.
As far as all the different brackets and why they are where there are, goes, don't sweat it.
Just get into the habit of putting them where the cheatsheet says they should go and don't worry about what they do :-)
Last edited by curious aardvark; 03-11-2021 at 08:21 AM.
-
03-11-2021, 08:17 AM #4
Actually, it turns out that a 4 sided cylinder make a diamond shape.
This is one of the things I like about openscad - things don't always turn out how you think they will and you probably learn more by this kind of rndom accident than by anything else :-)
Attachment 16078
-
03-11-2021, 11:44 AM #5
- Join Date
- Mar 2021
- Posts
- 63
Thanks, and I agree that screenshot resolution is very poor, sorry.
Here is the scad file:
https://www.dropbox.com/s/stuqnbril2...tor.scad?raw=1
And here is a list of the errors:
https://www.dropbox.com/s/u2dirnlt7z...rors.txt?raw=1
-
03-11-2021, 02:41 PM #6
- Join Date
- Mar 2021
- Posts
- 63
[QUOTE=curious aardvark;150378]well that is insanely long for a simple box generator. I suppose it does have a lid as well.
[quote]
Yes. Here's a photo:
Well, I inserted one but it didn't show up! I'll try a link:
https://www.dropbox.com/s/44mfvefp2p...id-2.jpg?raw=1
I'll look into the speed issue, but others don't appear to think that's an unrealistic time. I used the default settings for everything on my Ender 3 V2
But honestly you are better off starting by making your own. #
A simple box is a great way to start:
difference(){
cube ([50,20,10],center=true);
translate([0,0,2]) cube ([46,16,10],center=true);
} // end difference
viola - a box with 2mm thick walls and base and 50mm long by 20 wide and 10mm tall - good for screws and bits.
To make this parametric you just need to indulge in a little algebra and throw in some variables
That's not immediately intuitive, right? I'd assumed I'd build it as I would with simple woodwork, by making six rectangles and gluing or pinning five together, and then thinking how to handle the sixth (the lid). But presumably that wouldn't work for 3D printing, as the main five pieces would not be joined?
And that's a 2 line cubic box generator.
To make a different shape box you use cylinders instead of cubes and change the number of facets to the shape you want.
so a 4 facet cylinder is a cube and a 3 facet cylinder is a triangle. You use a resize command to change the shape from a fixed diameter 'cylinder' to the length and breadth you specify. :
Cases.jpg
2 line infinite shape box generator.
So you start with a simple centred cube and difference a smaller cube - if you center it you don't have to muck about with moving it about to get it centred yourself.
wall thickness happens on both sides of the shape - so you always have to multiply it by 2.
SimplestBox-NotCentred.jpg
In the second example you use algebra to make the sizes variable.
And in the third example you use different number sided 'cylinders' to change the number of sides of the shape.
A resize command over rules all subsequent sizes - so it doesn't matter what size you make the original cylinder.
I don't do programming - so i approach openscad very differently to programmers.
I like to make it easy to read what I've done - so I use short variables and never indent anything. Most programmers use whole sentences for variables and end up with something almost unguessable - in my opinion ;-)
The beauty of openscad is that you can write the scripts any way you like.
The way I approach a design problem is also simple.
work out what you want to make and then break it down into simple shapes. Then work out what shapes need to be added or removed and where they need to be and go from there.
It does seem daunting at first.
But once you've got your own script style that you can read and have worked out what the commands do - it's really a lot better and more precise than moving stuff around with a mouse.
And so much faster !
Also - and one of it's best points - everything generated by a script is a solid shape that will print.
No errors.
As far as all the different brackets and why they are where there are, goes, don't sweat it.
Just get into the habit of putting them where the cheatsheet says they should go and don't worry about what they do :-)
- How do I get a bottom on the box?
- And a hole of R mm diameter in one of the surfaces?
The reason I started with thingiverse was because although I might be able to manage a very basic box myself, I was sure that other essential elements would be beyond me. Such as lids (either sliding or screw-on), and holes, and grooves on the sides for circuit boards, etc.
I have been considering trying FreeCAD but must say I do like openSCAD and think that's the one I'll be using.
Terry, UK
-
03-12-2021, 07:57 AM #7
- Join Date
- Aug 2020
- Location
- United Kingdom
- Posts
- 249
A good alternative to opencad is Fusion360 which has a free version for non commercial use.
-
03-12-2021, 08:58 AM #8
stick with openscad.
Once you get used to how things work - it's amazing how easy it is.
I use diameters NOT radius - the reason being.
1)I do not know anything about complicaed geometry and sins and cosin and the like.
2) If I set the diameter of a cylinder - the cylinder will be that size. If I set the radius of a xylinder I will need to double that number to get the size I actually wanted. So I never use radius always diameter :-)
You don't actually need to be good at maths to use openscad (obviously) but you do need to know what you want to do.
Also it is a good idea to put comments in your scripts. This really helps when coming back to a complicated script.
{ - curly brackets are used to enclose a series of commands, usually.
so difference() {
shape 1
shape 2
} // end diff
shape 2 is removed from shape one. It's actually a lot better than that as you can have as many shapes as you like removed from shape 1.
the () brackets are there for a reason I do not know. you just always add them - and that's all I need to know lol
No doubt if I had an idea what they were for they might be useful. But I don't.
One thing I will say is that the manual is almost incomprehensible. After about 8 years, 90% of the openscad still makes no sense to me.
It's written by programmers for programmers - no actual humans were involved.
I pretty much stick to the cheatsheet and the odd wuestion askd in th openscad forum on thingiverse.
Although if you get a programmer answering - it's invariably incomprehensible and massively over complicated.
So from a wood working point of view:
$fn=60; // set 50 facets to give us nice round holes that rendet fairly fast
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
So what we do is to put a % in front of the shape we want to see.
In this case I wanted to see where the last piece I removed was, because it's easier to just move stuff around till it's where you want it than to actually work it out mathematically - well it is for me:
You need to remove the % before you do an f6 render as otherwise it won't be actioned.
It's purely so you can see where things are.
Okay so we now have a hollow box with a groove cut for a sliding lid and some mysterious holes cut in the bottom.
Do you know what it is yet ?
I'll give you a clue. it's spring on the way and this could go in your garden ;-)
So the only thing we need now is a lid.
BUT !
how can we add a lid and then generate two seperate models to print ?
Hmmmm.....
! I know. we can use the: 'module' - one of the most useful commands you have.
You can divide different parts of your script into chinks called 'modules'. The clever thing about a module is that you can use it as a single shape. in another script. Or call it on it's own.
So first we need to turn our box into a module:
I'll continue below :-)
-
03-12-2021, 09:11 AM #9$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:30 AM #10
- Join Date
- Mar 2021
- Posts
- 63
Thanks Gambo. I have actually been trying to do that, to make an informed comparison. But after many attempts over three days I have still not received a verification email.
I successfully registered. I downloaded the program as the file Fusion 360 Client Downloader.exe When I try to run that by signing in I get told I haven't verified my account and that a verification email will be sent (and a message pops up saying 'Sent'). But it never arrives. Not in trash. Tried Resend a dozen times yesterday and this morning. Nor did following other options via Contact get anywhere. All loop back to the same stuff, Catch 22, no verification. Life's too short, so I've abandoned Fusion.
I have also installed FreeCAD. But the more I get into practical learning with openSCAD, such as in this thread, the more I think that will be my choice for now.
(And on first opening FreeCAD with the same Ultimate Box under discussion, everything was a dull grey and I couldn't immediately move it around, which gave me a negative first impression - albeit shamefully irrational!)
Ender 3v2 poor printing quality
10-28-2024, 09:08 AM in Tips, Tricks and Tech Help