OpenSCAD: International Ruler of Mystery

Pretty! I’d love to see the code.

2 Likes

I’d be interested in the OpenSCAD sketch. I’ve been wanting to do some rulers but haven’t gotten back to it since I wanted both measurements on. I have a local sawmill I’m going to be visiting and I thought I would come with some gifts to sweeten the negotiations.

Very nice. This looks pretty good. I would guess that if you engrave the vector tick marks, the kerf of the cutout will trim the ruler such that the ticks are flush with the edges. Nice effect.

The numbers have a lot of nodes. That will be interesting to see how they work out, but vector engraving should be fine.

I’m curious as to what the green fill of the vectors will do in terms of engraving. I have been surprised before by the interpretations of a filled color in relation to power level when I’m doing vector engraving.

This will also be a good way to test vector engraves. I can’t recall at the moment how they work, but I believe it is engraving within the lines. In the GFUI they look thick, but might not actually engrave that way.

9 Likes

One additional comment: when a ruler has both systems, should they be mirrored? So the metric should read right to left so that it can serve as a top when measuring under something. I am always counting backwards when I measure metric! Then put two Glowforge logos, one flipped over so no one is slighted. After all, metric users should not feel inferior. It’s only the Imperial users who have to exaggerate size.

6 Likes

So something I should mention about this SVG I attached, versus the actual output from OpenSCAD…

  • OpenSCAD currently doesn’t support line colors for SVG exports.
    I had to run some parts of my code for the cut layer, and run another part of code for the engrave layer – exporting each respective output as two SVGs – and recombine them in Inkscape by hand.
  • The (green) engrave layer actually exports as grey fill + black line, I have to manually change it in Inkscape to green fill + no line.
  • The (red) cut layer also had to be changed from grey+black to no fill+red line.
  • The large number of nodes in numerals is out of my control, unfortunately. It’s 1:1 the nodes from the actual TrueType font. I can swap in a more basic font like Comic Sans, if needed.
  • The scale is backwards. That was intentional, because I’m always converting millimeters to inches, and it’s a handy reference. My rational is that it’s easier to use as an upside down ruler than it is to do the conversion maths.
  • Why inches is larger than the metric scale: You hit double-digits pretty quickly with centimeters, so it was more an aesthetic choice for space concerns of longer rulers. (Did I mention the code can generate rulers of any length?)
  • I redid the Glowforge logo in DXF before reading that newer dev releases of OpenSCAD support SVG importing, so I’ll probably eventually switch back to the Glowforge-provided SVG file. I’ll rotate the logo 90° counter-clockwise for symmetry, eventually.
9 Likes

It’s a great file. I appreciate the extra work for the color. Although, since it is only the bounding box for the red cut layer it seems you could export it all as one SVG and simply change that one object to a different color, unless I am missing something. You definitely did some work on this because the letters and numbers with counters in them and the right side gear image are filled correctly to leave the holes where they need.

Good explanation of the metric positioning. Didn’t think of that I’m always asking Siri.

3 Likes

It’s a limitation of OpenSCAD. It forces you to work with everything as solid polygons. It doesn’t have a concept of “lines”, per se, except to define the shape of a polygon - that’s the only purpose in it. And every polygon must be a closed solid, unless you run some binary combination (union(), difference(), intersection()) on two+ polygons to make more polygons.

So the short answer is: I had to do it that way so the cut-layer was a path and not “a solid rectangle with smaller, hollowed out rectangle in front of it” looking polygon.

Visual: The left is a path. The right is the aforementioned “polygon with a hole in it”.

4 Likes

And if you try to lie to it about your polygons or the shapes made from them to get the results you want, Openscad will tell you that your design is not manifold (i.e. does not obey the rules for making stuff that can be analysed for 3D-printing with simple math) and refuse to render it properly, or at all.

4 Likes

Thanks for the explanation. I’ve just been working with the letter form outlines using @palmercr’s sketch and @m_raynsford’s flex box and these have had to do some post processing.

1 Like

@marmak3261 - Just a heads up, I updated the OP based on feedback and concerns I had about the tick marks being too thick (as I wasn’t taking kerf into account when choosing the original thickness).

2 Likes

Any reason you didn’t just make them score lines?

2 Likes

Partly because OpenSCAD doesn’t export attributes in the SVG (line color, fill color, line thickness). Mostly for reasons answered in this post.

2 Likes

Oops. Sorry. I read that one earlier and then saw your latest and didn’t connect the two. I need to get some sleep :smile:

It’s funny because my center rule has lines as ticks and I thought the Founder Ruler did too and I couldn’t get mine to engrave while the Founder one did. I converted them to scores and it worked fine. Then found out that the Founder one had tiny rectangles too - wonder if they did the design in OpenSCAD?

2 Likes

Looks pretty nice with the thinner lines. Imports great into GFUI. Will test it out tonight. Thanks.

2 Likes

I never really dissected the Founder Ruler, so I can’t really speak of what they used. Chances are they actually just used Illustrator, but they could have used any scripting language I suppose. Maybe someone just hammered something together in a shell script, with handwritten code.

The whole “paths and polygons” discussion can really do a number on you. I had experience thanks to the mental trauma dealing with PostScript.

The most common mistake people make is when they draw a stroke, make it nice and thick to look an inch wide, and promptly declare it to be a rectangle. To me, these are the same people who use multiple spaces instead of tabs in a Word document: You change the font size, and all control goes out the window with it.

Using strokes and line thickness alone doesn’t scale. If you scale it twice the size, the shape may proportionally be larger, but the stroke is still only an inch wide. So a doubling of size makes a 1-inch thick line look 1/2-inch thick after scaling.

If you do the same thing with polygons, then the “apparent” thickness scales in proportion to the dimensions, because math makes the square bigger.

And because I like sharing my pain:
The Adobe PostScript Language Reference Manual

Review section 4.5 Painting on p.193

7 Likes

In my laser design model there are strokes (designed to be cut and always 0.001mm width) and bounded objects (polygons, etc) which are designed to be engraved. A thick line is an error because it won’t cut like that - maybe the laser software will do repetitive cuts side by side to try to make it or it will ignore the thickness and it will be a skinny cut. Can’t have the machine make the determination because it might not be what I wanted. So it’s helpful that I’m used to designing for multiple machines. But it does mean some of the shortcuts aren’t quite as useful for me.

4 Likes

It’s a ruler, they don’t cut very well.

I guess you could make it out of steel and sharpen the edge, but then is it still just a ruler?

13 Likes

Snortle!

3 Likes

Maybe add some space?

Many rulers are not flush at the end. Zero is inset from the edge. Rulers made of wood can become worn from use.

3 Likes

Here is the finished product. Brought straight into the Glowforge without any changes.

In the bed with masking. Proofgrade walnut plywood.

Unfinished hardware store plywood with 5% engrave at 340 lpi.

Proofgrade 1/8 walnut ply, 10% power, 340 lpi.

Turned out very well. Nice proportions and lettering. Might even go up a bit with the engrave power. Thanks for sharing!

30 Likes

Did you measure it with another ruler to see if the lengths & ticks are in the right places to be accurate?

1 Like