James Porter
- Architecture-style
- x,y,z
Always have a main function which returns an object
function main () {
return union(
difference(
cube({size: 3, center: true}),
sphere({r: 2, center: true})
),
intersection(
sphere({r: 1.3, center: true}),
cube({size: 2.1, center: true})
)
).translate([0, 0, 1.5]).scale(10);
}cube({size: 1, center: true})
cube({size: [1,2,3]})- size
sor[x,y,z] - center (location)
falseby default (at 'bottom' corner)
cylinder({r: 1, h: 10})- r for radius
- h for height
- again can
centeror not (default) fnto control detail
scale(2,obj)
scale([1,2,3],obj)- can scale in simple way
- or per x,y,z
translate([5,4,3], obj)- Move by
[x,y,z] - e.g. move up 5 units:
translate([0,0,5], obj)rotate([90,0,45], obj)- Rotate about
[x,y,z](respectively) - e.g. rotate about vertical by 90 degrees:
rotate([0,0,90], obj)NB Degrees not radians
- Glue stuff together
union([obj, another])
union(obj, another)sphere({r: 4})- r for radius
centeris true by default (unlike other primitive objects)fnto control detail
List of points to make a (2D) polygon on x,y plane
let p1 = polygon([ [0,0],[3,0],[3,3] ])
let p2 = polygon({ points: [ [0,0],[3,0],[3,3] ] })Then extrude with linear_extrude:
linear_extrude({ height: 10 }, p1);
linear_extrude({ height: 1 }, p2);- Bit in all the shapes
intersection(
sphere({r: 1.3, center: true}),
cube({size: 2.1, center: true})
)- Can take bunch of arguments or array
- First shape with rest carved out
difference(
cube({size: 3, center: true}),
sphere({r: 2, center: true})
)- Can take bunch of arguments or array
See the full docs
Adds some mathematical things like sin that work with degrees not radians.
You might want to use Math.{round,sin,cos,tan,floor,ceil,sqrt,random} to generate things in simple way.
the bottom link "See the full docs" doesn't work