Lets3dPrint

Lets3dPrint scripts

A project's timeline written as plain lines you can read, change and run. Every step of the timeline is one line (a sketch is a short block). Change a number and press Run: the part rebuilds. Or write a script from scratch, with variables and loops.

# A plate with a row of pegs
w = 80          # Width (40 to 200)
d = 50          # Depth (20 to 120)
pegs = 5        # Pegs (1 to 12)

base = sketch on xy
  rect (-w/2, -d/2) to (w/2, d/2)
end
plate = extrude base by 5 as "Plate"

repeat i from 1 to pegs
  cylinder r 3 h 10 on xy offset 5 at (-w/2 + i * w / (pegs + 1), 0) join into plate
end
fillet plate edges 1, 3 r 2

Values and script files

The numbers set at the top of a script (outside sketches and loops) appear above it as Values: a field for each, and a slider when its comment ends with a range. The comment is its label. Change one and the part rebuilds.

cables = 6       # Cables (1 to 12)
cable = 5        # Cable diameter (2 to 12)
gap = 4          # Wall between cables

The comment lines at the very top describe the script. Save Script… in the script panel writes it as a .l3dscript file (plain text). File → Run Script File… (⇧⌘R, also in Create and ⌘K) opens one in any project: set its values, then add its steps to the end of the timeline, or let it replace the project. A script added to a project can use the project's steps and bodies by the names the script view gives them (plate, "Base plate").

Basics

Any step can end with named "Its name" (its name in the timeline), as "Body name" (the body it creates) and suppressed.

Planes, faces, edges, operations

Sketches

s = sketch on xy            # or: on face 6 of plate offset 2
  line (0, 0) to (40, 0) as base_line
  rect (0, 0) to (20, 10)
  circle (10, 5) r 3        # or d 6
  arc (0, 0) from (5, 0) to (0, 5)      # centre, start, end; add cw for clockwise
  curve (0, 0) (5, 10) (15, 10) (20, 0) # Bézier with two control points
  spline (0, 0) (10, 5) (20, 0)
  ellipse (0, 0) major (10, 0) minor 4
  polygon (0, 0) through (10, 0) sides 6   # add circumscribed
  slot (0, 0) to (20, 0) r 4
  text "Hello" at (0, 0) height 10 font "Helvetica-Bold" angle 0
  point (5, 5)
end

Add construction to a curve to keep it out of profiles. Name a curve with as to use it later: line s.base_line as an axis, or as a path.

Steps

CommandExample
Extrudeextrude s at (5, 5) by 10 symmetric cut into plate · extrude face 3 of plate by 2
Revolverevolve s at (12, 5) around line s.axis by 270 · around x axis, sketch y, edge 4 of plate
Box, cylinder, sphere, torus, coilbox 20, 20, 10 on xy at (0, 0) · cylinder r 5 h 20 · sphere r 10 · torus 15, 4 · coil r 10 pitch 5 turns 4 section 1.5
Fillet, chamferfillet plate edges 1, 2 r 2 · chamfer plate edges 5 d 1
Move, copymove plate by (40, 0, 0) rotate (0, 0, 90) about (0, 0, 0) copy
Patternpattern peg along x 5 every 12 and y 2 every 20 · pattern peg around z axis 6 over 360 new
Scalescale plate by 2 · scale plate by (1, 1, 0.5) about (0, 0, 0)
Combinecombine plate with peg, bolt cut keep
Splitsplit plate with xz offset 4 · with a twist lock (push in, turn): split plate with xy offset 20 twist lugs 3 turn 30 (also size 16, clearance 0.2, count 2, nodetent, unkeyed) · with pins or magnets instead: split plate with xy offset 20 pins 1.75 depth 6 (hole depth in each part), magnets 6 by 2 (Ø by thickness), then fit press, count 2 (per cut face; else one every 40 mm, two at least) · to the bed, pieces that each fit it: split arm with bed 170 by 170 by 170 (the biggest piece: x, y, height), then x 2, y 1, z 1 (pieces along an axis; else as few as fit), nolabels (no A1, A2… on the cut faces) and pins or magnets as above · along sketch curves, with locks: split plate with grid.c1, grid.c2 lock jigsaw size 10 clearance 0.15 · every curve of a sketch: split map with grid lock dovetail size 8 clearance 0.2 every 40 whole · also count 2, tabs left, wall 2, round 0.5, noextend, and changes to single locks: flip 1 at 0.5, remove 2 at 0.3, add 3 at 0.25, move 1 at 0.2 to 0.4 (edge number, then where along it, 0 to 1)
Holehole on face 6 of plate at (10, 10), (30, 30) diameter 5 depth 8 counterbore 9 by 3 · through · countersink 9 at 90 · flat · tip 118 · on its side: teardrop or flatroof · over a counterbore or nut trap facing the bed: bridge 0.2 · nut trap: nut 5.5 by 2.7 (across flats, depth) · a fit from the list, its gap added on each side of every diameter: fit slide (exact, press, tight, slide, loose, inplace) · what it is for (shown in the panel): for insert "M3 × 5.7" (screw, sockethead, selftapping, insert, nut, magnet)
Pipe, sweep, ribpipe along path.l1, path.l2 diameter 6 wall 1 · sweep s at (0, 10) along path.l1 · rib along s.l1 thickness 2 depth 10
Loftloft a at (0, 0), b at (0, 0) ruled
Embossemboss label at (3, 4), (9, 4) depth 1 · add deboss to sink it
Shellshell box1 open 6 wall 2
Mirrormirror plate across yz · add new to keep it a separate body
Threadthread face 3 of bolt M6 pitch 1 clearance 0.2 length 10 · or fit slide instead of the clearance · other standards instead of M6: unc "1/4-20", unf "#10-32", pipe "G1/2" (BSPP, 55°), bottle (PCO-1881 soda bottle), jar 70 or jar 86 (mason jar 70-450 / 86-450); a number that names no size is the diameter in that standard's shape: pipe 30 pitch 2
Fitfit is the project's Slide gap (0.2 mm a side plus the printer's offset from the Fit test): cylinder d peg + 2 * fit h 4. Split and twist locks take fit slide instead of clearance
Imported meshmesh "Bracket.stl" (the mesh stays in the project)
Imported STEPstep "Board" (the file stays in the project; each solid is a body)
Texturetexture box faces top knurlDiamond depth 0.6 scale 3 · also rotate, seed, margin, solid (real faces and edges: fillet them, sketch on them, export them to STEP)
Surface waveswaves box at (0, 0, 10), (20, 5, 10) amplitude 0.8 wavelength 8 · also faces top, decay, phase, solid
Smart objectobject peg "Peg" … its own script … end
Place copiesplace peg over plate faces top every 10 inset 3 bind h "5 + d / 10" join into plate · at (x, y, z), … · grid on xy 4 by 3 every 10
Data to 3Ddata "Sales" bars cell 5 gap 0.5 height 30 base 2 · surface, columns, log
Brim earsears plate diameter 10 thick 0.4
Flow linesflowlines "Shade" radius "60 - 18*t" height 160 lines 24 path "k * p * t" with k 3 from 0.5 to 8 · also one way, phase 7.5, width 2.4, thickness 1.6 both (outward, inward), rims 3 5, detail 0.8, on xy, at (x, y), join into plate. The radius is in mm, of z (mm) and t (0 at the bottom, 1 at the top); the path is in degrees, of t, z, i (the line's number), n (the number of lines) and p (360 / n)
Function to bodyfunction "Sombrero" z "sin(r) / r" x -10 to 10 y -10 to 10 width 80 height 20 grid 80 base 2 · parametric "x", "y", "z" u 0 to 2*pi v 0 to 2*pi with R 2, r 1 inside · implicit "F" x … y … z … thickness 1.2 both
Gear systemgears "Gearbox" module 2 width 6 layers 2 input at (0, 0) teeth 20 clockwise output 1/4 opposite output 3 same at (70, 20) layer 2 fit slide pin 5 bore round plate 3 margin 6. One output per output: its speed as a number or fraction (out / in), same or opposite, at (x, y) for a fixed axle, layer n; or ring 6 of 1/4 instead: six outputs round the input, every one at that speed, each meshing with the input gear. Then teeth 12 to 80 (the range the solver may use), gap 0.6 (between layers), hole 3 / screw (M3) / filament 1.75 instead of pin, bore d 4.5 / bore hex, no plate, on xz. A layout made by hand follows as shaft 2 at (40, 0) output 1, gear 2 shaft 2 layer 1 teeth 40 idler, mesh 1 2 (numbers from 1). Every shaft becomes a body (its gears fused with a hub), the plate another
Map to bodymap "tatra.hgt" data width 150 exaggerate 2 base 2 · map "heat.png" colours "Viridis" values 0 to 40 · map "hills.svg" contours interval 10 terraces · map noise ridged seed 48213 size 30 falloff 0.6 width 120 height 20 floor 0.35 shape data · globe r 50 wall 2

Function to body

A formula made into a body: z "…" for a graph z = f(x, y) (also r, the distance from the centre), parametric "x", "y", "z" for a surface of u and v, or implicit "F" for F(x, y, z) = 0, inside where F < 0. Formulas are in quotes and use radians, + - * / ^, pi, e, sin cos tan asin acos atan atan2 sinh cosh tanh sqrt abs exp ln log10 min max floor ceil round sign pow hypot clamp, and the fractals mandelbrot(x, y, n), mandelbulb(x, y, z, n, iterations) and julia(x, y, z, a, b, c, d, iterations).

Map to body

A map file kept in the project (import it first with Generate → Import Map), or generated noise, made into a relief.