Skip to content

Instantly share code, notes, and snippets.

@robbintt
Last active December 30, 2017 01:03
Show Gist options
  • Save robbintt/822583b88cd772e841fe49f68fc3fa80 to your computer and use it in GitHub Desktop.
Save robbintt/822583b88cd772e841fe49f68fc3fa80 to your computer and use it in GitHub Desktop.
scad-clj demo
;; this example could go a lot of different directions
;; you could bind the difference between the min cube size and max cube size to an interval and extrude N objects over the distance between 0 and PI.
;; lots of other cool parametric things are possible before the code gets translated.
;; bring primitives into namespace or whatever
(ns scad-demo.core
(:use [scad-clj.scad])
(:use [scad-clj.model]))
;; make primitives
(def primitives
(union
(->> (rotate (* Math/PI (/ 0 4)) [0 0 1])
(->> (cube 5 5 5)
(rotate (/ Math/PI 4) [1 1 1])
(translate [150 0 0]))
)
(->> (rotate (* Math/PI (/ 1 4)) [0 0 1])
(->> (cube 10 10 10)
(rotate (/ Math/PI 4) [1 1 1])
(translate [150 0 0]))
)
(->> (rotate (* Math/PI (/ 2 4)) [0 0 1])
(->> (cube 20 20 20)
(rotate (/ Math/PI 4) [1 1 1])
(translate [150 0 0]))
)
(->> (rotate (* Math/PI (/ 3 4)) [0 0 1])
(->> (cube 30 30 30)
(rotate (/ Math/PI 4) [1 1 1])
(translate [150 0 0]))
)
(->> (rotate (* Math/PI (/ 4 4)) [0 0 1])
(->> (cube 40 40 40)
(rotate (/ Math/PI 4) [1 1 1])
(translate [150 0 0]))
)
)
)
;; export to scad
(spit "example.scad" (write-scad primitives))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment