Thursday, April 10, 2025

There Was Probably a More Efficient Way to Do This

But convergent sequence of a hexagon shrinking by mill radius until hexagon height less than mill radius seems to do the job.

#!/bin/bash
if [[ $# -lt 8 ]];
   then echo "$0 xstart ystart zstart zstep zend xyfeed zfeed height millradius"
   exit 2;
fi
cat prolog.nc >hexagon.nc
xstart=$1
ystart=$2
zstart=$3
zstep=$4
zend=$5
xyfeed=$6
zfeed=$7
height=$8
millradius=$9
xend=`echo "$xstart+$height" | bc -l`
while [ "$(bc <<< "$height > $millradius")" == 1 ];
do
    xstart=`echo "$xstart+$millradius/2.0" | bc -l`
    height=`echo "$height-$millradius/2.0" | bc -l`
        if [ "$(bc <<< "$height > $millradius")" == 1 ];
    then
    mkhexagon $xstart $ystart $zstart $zstep $zend $xyfeed $zfeed $height $millradius
    fi
done
cat epilog.nc >>hexagon.nc

And there is an increasingly excited sound it makes as the cuts get shorter and shorter.  Writing scripts instead of C always sounds faster than it is.  Bash scripts are never as simple as they should be and are far harder to debug than a C program where you have tools like gdb.

I may need to cut slightly larger to get the hex nuts to slide in more easily. 


2 comments:

  1. Have you considered threaded inserts? I know they're popular in 3D printing because you set them into a round hole with a soldering iron and adapter. For example: https://amzn.to/3ElOkF4 The knurled exterior also grips well in epoxy.

    ReplyDelete
    Replies
    1. I have them, and I will use them for sheets too thin for hex nuts.

      Delete