Skip to content

Instantly share code, notes, and snippets.

@peterwake
Last active March 30, 2020 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterwake/d0dc88237484244f34b18b2b4d933f6c to your computer and use it in GitHub Desktop.
Save peterwake/d0dc88237484244f34b18b2b4d933f6c to your computer and use it in GitHub Desktop.
OpenJScad random structure
//openjscad.org
// Random structure
function main () {
var cube1 = cube({size:[4,4,4]}).translate([-2,-2,-2]);
var hole = cylinder({r:1, h: 4}).translate([0,0,-2]);
var nut1 = difference(cube1, hole);
var rod1 = cylinder({r:1, h: 10}).rotateX(90).translate([0,-2,0]);
var nut2 = nut1.translate([0,-14,0]);
var nut3 = nut1.translate([14,-14,0]);
var nut4 = nut1.translate([14,0,0]);
var rod2 = rod1.translate([14, 0, 0]);
var rod3 = rod1.rotateZ(90);
var rod4 = rod3.translate([0,-14,0]);
var struct1 = [nut1, rod1, nut2, nut3, nut4, rod2, rod3, rod4];
return struct1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment