Skip to content

Instantly share code, notes, and snippets.

@patmandenver
Last active December 30, 2018 18:17
Show Gist options
  • Select an option

  • Save patmandenver/1e8708b8c7741e128730430bc5ee2f15 to your computer and use it in GitHub Desktop.

Select an option

Save patmandenver/1e8708b8c7741e128730430bc5ee2f15 to your computer and use it in GitHub Desktop.
#!/bin/bash
TOTAL=18
CURRENT=1
STL_DIR="stl_chain_files"
PER_SET=5
SET=0
TOTAL_SETS=$((2*TOTAL/(PER_SET + 1)))
OPENSCAD_FILE="Chain_Generator_with_text_tweaked.scad"
#Making stl directory
mkdir -p $STL_DIR
while [ $CURRENT -le $TOTAL ]
do
if [ $((SET % 2)) -eq 0 ]
then
if [ $((CURRENT + PER_SET)) -gt $((TOTAL)) ]
then
echo "Creating STL file $((SET+1)) of $((TOTAL_SETS+1)) ($CURRENT-$TOTAL)"
openscad -o $STL_DIR/$((CURRENT))-$((TOTAL))_chain.stl $OPENSCAD_FILE -D num_one=$((CURRENT)) -D num_two=$((TOTAL))
CURRENT=$((CURRENT + PER_SET))
SET=$((SET + 1))
else
echo "Creating STL file $((SET+1)) of $((TOTAL_SETS+1)) ($CURRENT-$((CURRENT + PER_SET - 1)))"
openscad -o $STL_DIR/$((CURRENT))-$((CURRENT + PER_SET - 1))_chain.stl $OPENSCAD_FILE -D num_one=$((CURRENT)) -D num_two=$((CURRENT + PER_SET - 1))
CURRENT=$((CURRENT + PER_SET))
SET=$((SET + 1))
fi
else
echo "Creating STL file $((SET+1)) of $((TOTAL_SETS+1)) ($CURRENT)"
openscad -o $STL_DIR/$((CURRENT))_chain.stl $OPENSCAD_FILE -D num_one=$((CURRENT)) -D num_two=$((CURRENT)) -D rotate_chain=249
CURRENT=$((CURRENT + 1))
SET=$((SET + 1))
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment