Celtic knot design redone in OpenSCAD

Here is my take on @Jules’ Celtic Knot modelled in OpenSCAD . This script:-

od = 100;
id = 70;
border = 2;
thickness = 5;
engrave_depth = 1;
loops = 25;
o_loop_width = 2;
i_loop_width = 1;
loop_aspect = 1.7;
$fa = 1; 
$fs = 0.5;
band = (od - id) / 2 - 2 * border;
o_loop_d = band - 1;
i_loop_d = o_loop_d - o_loop_width * 2;
module ring(od, id, h, aspect = 1) {
    module elipse()
        scale([1, aspect])
            circle(d = (od + id) / 2);
    
    linear_extrude(convexity = 2, height = h)
        difference() {
            offset((od - id) / 4) elipse();
            offset((id - od) / 4) elipse();
        }
}
difference() {
    color("white")
        ring(od, id, thickness);
 
    color("grey")   
        translate([0, 0, thickness - engrave_depth])
            difference() {
                ring(od - 2 * border, id + 2 *border, engrave_depth + 1);
                
                
                for(i = [0 : loops - 1])
                    rotate([0, 0, i * 360 / loops])
                        translate([(od + id) / 4, 0, 0]) {
                            ring(o_loop_d, o_loop_d - o_loop_width, engrave_depth + 1, loop_aspect);
                            
                            ring(i_loop_d, i_loop_d - i_loop_width, engrave_depth + 1, loop_aspect);
                        }
            }
}

Produces a 3D model which looks like this: -

If I view it from above with no perspective then I almost get a depth map for 3D engraving.

The white is off white due to the lighting not being directly above. I can fix that by writing a script to convert the Z values in an STL file to shades of grey. I would also do it at a specified DPI to give better resolution.

My question for @dan is can the Glowforge accept an image like this and be able to both 3D engrave the ring and then cut it to separate the black regions, rather than burning them all away? Perhaps if the maximum engrave depth is set to the material thickness it can cut around black rather than engraving it to full depth?

31 Likes

That looks so cool…it’s making me want to run to the printer! :sunglasses:

(Adding your Tutorial to the Weekly Highlights as well, for other OpenSCAD users.)

4 Likes

Yes the benefit of modelling in 3D is it can be printed on any 3D printer, not just a Glowforge. Of course it would be much better if the Glowforge software accepted STL files and it would bolster its claim to being a 3D printer.

5 Likes

I draw almost exclusively in Solidworks. I agree it would be nice to be able to export an actual 3D file to the forge for engraving!

1 Like

Yes because a 3D file like STL has all the information needed to make the object if the GlowForge is clever enough. It saves having to generate separate cut lines, etc, and colour code them, and then tell Glowforge what to do with each colour.

1 Like

Will the forge be able to 3D engrave from any 3D file or only grey scale?

2 Likes

I think it only uses the levels of gray to engrave with variable power. Real 3D obviously doesn’t use that to fabricate.

1 Like

[pedantry on]

Another way to get the info out of openscad would be to do a bunch of projections of the design (essentially a cross-section at a particular height/depth) and turn each one a different color that could then be assigned a different depth, with export as svg…

1 Like

There are a few ways to do it, but it’s part of the file creation work flow (e.g. import into vectors software and put a cutline where you want it) rather than our software.

5 Likes

Disappointing but I can easily write a Python script to convert STL to a greyscale PNG and also output an SVG vector path of the outline. Given how easy it is I am surprised the Glowforge software won’t eventually do it. The workflow I am used to with 3D printers is export as STL, slice to gcode, upload to an OctoPrint webpage and press print. I don’t have to identify outlines, etc, manually. All the information is in one file and there is no ambiguity how the elements in it are to be processed by the machine.

Glowforge seems to be making 3D objects using 2D tools and files which makes a more complicated workflow than is necessary. I can see why, because it is coming from the traditional way laser cutters are used, but by considering cutting plus variable depth engrave to be a 3D object, not a 2D one, the workflow can be much easier and automatic. Whenever there is a repetitive manual operation there is the opportunity for a mistake and it is annoying to waste material.

3 Likes

Friggen epic!!