Skip to content

Instantly share code, notes, and snippets.

@patmandenver
Last active February 4, 2024 22:21
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patmandenver/4a2368925e83552ab7453e30ecdbefe4 to your computer and use it in GitHub Desktop.
Save patmandenver/4a2368925e83552ab7453e30ecdbefe4 to your computer and use it in GitHub Desktop.
$fn=100;
grand_teton="grand_tetons.stl";
adjust=[0,0,2]; // X,Y,Z adjustments
just_display=false; //Set to false to split
split=true;//Set to false to adjust
//Split size in mm
edge=20;
//split per side
split_per_side=5;
//Total squares
square_max=split_per_side*split_per_side;
chosen_square=12; // <== Change me to chosen square
X = chosen_square % split_per_side;
Y = floor(chosen_square / split_per_side);
//Caclulate zero point in upper right
X_ZERO = (split_per_side * edge)/2;
Y_ZERO = -X_ZERO;
echo(X);
echo(Y);
if(just_display){
translate(adjust){
import(grand_teton, convexity=3);
}
}
else{
intersection(){
translate([adjust[0] + X_ZERO,
adjust[1] + Y_ZERO,
adjust[2]]){
import(grand_teton, convexity=3);
}
if(split){
linear_extrude(1000){
translate([X*edge,-Y*edge-edge]){
square(edge);
}
}
}
else{
//Remove nothing
}
}
}
@kernelsmith
Copy link

you probably know this, but thought I would mention it just in case:
at lines 37-39, you can replace those array indexes with .d where d is the axis, like

    translate([adjust.x + X_ZERO, 
               adjust.y + Y_ZERO, 
               adjust.z])

I'm not sure if that makes it easier, or harder, for readers who aren't already code monkeys, but I lean towards "maybe" lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment