Skip to content

Instantly share code, notes, and snippets.

@mattdees
Created August 10, 2022 06:29
Show Gist options
  • Save mattdees/30ac0ba48286a9998ff3bd89c2ad0608 to your computer and use it in GitHub Desktop.
Save mattdees/30ac0ba48286a9998ff3bd89c2ad0608 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import subprocess
# https://www.thingiverse.com/thing:3867358
SCAD_SCRIPT = "LEGOTextBrick-v2p0.scad"
SCAD_BINARY = "openscad"
bricks = [
["A", "B", "C", "D"],
["E", "F", "G", "H"],
["I", "J", "K", "L"],
["M", "N", "O", "P"],
["Qu", "R", "S", "T"],
["U", "V", "W", "X"],
["Y", "Z", " ", " "],
[".", ",", "!", "?"]
]
for brick in bricks:
brickname = " ".join(brick)
brickname = brickname.replace(".", "PER").replace(",", "COM").replace("!", "EXC").replace("?", "QUES")
cmd = [
SCAD_BINARY,
"-o", f"2x2{brickname}.stl",
"-D", f"frontText=\"{brick[0]}\"",
"-D", f"backText=\"{brick[1]}\"",
"-D", f"rightText=\"{brick[2]}\"",
"-D", f"leftText=\"{brick[3]}\"",
"-D", f"brickLength=2",
"-D", f"brickWidth=2",
SCAD_SCRIPT
]
# print(f"{' '.join(cmd)}")
subprocess.run(cmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment