[OpenSCAD] User Poll: What do you want to see from OpenSCAD development?

Jordan Brown openscad at jordan.maileater.net
Tue Nov 12 17:50:39 EST 2019


On 11/12/2019 11:11 AM, Max Bond wrote:
> Another thing I forgot, I'd love it if the GUI had a ruler that could
> measure angles and distances 
>

I wrote a measuring-stick module.  It's not great, but it sort of
works.  Note that it sort of autoscales based on the view distance; move
the view to where you like and refresh.  You have to position it where
you need it in the model; there's no attempt to support "from <this
place> to <that place> measurements.  Rotating and sizing to run it from
a particular [x,y,z] to another [x,y,z] is left as an exercise for the
reader.

$measure = true;
measuringstick(100);

module measuringstick(len, interval=pow(10,floor(log($vpd)-1)), center=false) {
    if ($measure) {
        r = 0.5;
        mark = interval * 0.01;
        %translate([0, 0, center ? -len/2 : 0]) {
            for (z=[0:interval:len]) {
                mark1 = min(len-z, mark/2);
                if (mark1 > 0) {
                    translate([0,0,z]) color("black") cylinder(r=r, h=mark/2);
                }
                z2 = z + mark1;
                block = min(len-z2, interval-mark);
                if (block > 0) {
                    translate([0,0,z2]) cylinder(r=r, h=block);
                }
                z3 = z2 + block;
                mark2 = min(len-z3, mark/2);
                if (mark2 > 0) {
                    translate([0,0,z3]) color("black") cylinder(r=r, h=mark/2);
                }
            }
        }
    }
}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20191112/f4a0812c/attachment.html>


More information about the Discuss mailing list