Parametric & Surface Modeling

Rhino, SolidWorks, Fusion 360, CATIA, AutoCAD 3D - all driven by the same sketch-to-solid pipeline and assembly constraint system.

Sketch-Based Features

Sketch, Extrude, Fillet
NEW CAD SKETCH ON PLANE "XY" SET ?sketch
AFTER CAD ?sketch RECTANGLE FROM 0,0 TO 80,40 SET ?outline
AFTER CAD EXTRUDE ?sketch HEIGHT 10 SET ?bracket

AFTER CAD ?bracket EDGE AT 80,0,5 SET ?e1
AFTER CAD ?bracket EDGE AT 80,40,5 SET ?e2
AFTER CAD FILLET EDGES [?e1 AND ?e2] RADIUS 4 ON ?bracket SET ?bracket
Revolve
NEW CAD SKETCH ON PLANE "XZ" SET ?profile
AFTER CAD ?profile ARC CENTER 0,0 RADIUS 20 START 0 END 180 SET ?arc
AFTER CAD REVOLVE ?profile AXIS ?arc ANGLE 360 SET ?sphere
A Primitive Solid
NEW CAD BOX SIZE 20,10,5 SET ?block
AFTER EMIT ?block("volume")
(* 1000 - a solid exists immediately, without a sketch *)

A box is the one solid that requires no profile. Every other form begins with a sketch, which carries its geometry until a feature consumes it: extruding a circular sketch produces a cylinder, extruding a rectangular one produces a block. The sketch itself is not a solid, and its volume is only defined once a feature has been applied.

Sketch to Solid
NEW CAD SKETCH ON PLANE "XY" SET ?sk
AFTER CAD ?sk CIRCLE CENTER 0,0 RADIUS 10 SET ?profile
AFTER CAD EXTRUDE ?profile HEIGHT 20 SET ?cylinder
AFTER EMIT ?cylinder("volume")
(* 6283.19 - pi x 10^2 x 20 *)
Sweep and Loft
NEW CAD SKETCH ON PLANE "XY" SET ?circle
AFTER CAD ?circle CIRCLE CENTER 0,0 RADIUS 5 SET ?profile
AFTER CAD SWEEP ?circle PATH ?helixPath TWIST 180 SET ?spring
Sweep and Loft (a second example)
NEW CAD SKETCH ON PLANE "XY" SET ?s1
AFTER NEW CAD SKETCH ON PLANE "XY" SET ?s2
AFTER CAD LOFT PROFILES [?s1 AND ?s2] SET ?blended
Shell, Pattern, Mirror, Boolean
CAD SHELL ?bracket THICKNESS 1 REMOVE FACES [?topFace] SET ?bracket
AFTER CAD PATTERN LINEAR ?holeSolid DIRECTION 1,0,0 COUNT 4 SPACING 20 SET ?bracket
AFTER CAD MIRROR ?bracket PLANE ?midPlane SET ?mirrored
AFTER CAD BOOLEAN UNION ?bracket WITH ?mirrored SET ?final

Freeform Surfacing

NURBS Surface from Curves
NEW CAD SURFACE FROM CURVES [?c1 AND ?c2 AND ?c3] SET ?surf
AFTER CAD SURFACE ?surf CONTROL POINT ?pt(3) MOVE TO 10,5,2
AFTER CAD SURFACE ?surf DEGREE U 5 V 5
AFTER CAD SOLID FROM SURFACES [?surf AND ?base AND ?sides] SET ?solid

Assemblies, Mates & Multibody Dynamics

Static mates are constraints. Real motion needs mass, inertia, and a dynamics solver - the same distinction as SolidWorks Motion versus a plain assembly.

Assembly with Mates
NEW CAD ASSEMBLY SET ?asm
AFTER CAD ?asm INSERT COMPONENT ?bracket AS "bracket" SET ?c1
AFTER CAD ?asm INSERT COMPONENT ?housing AS "housing" SET ?c2
AFTER CAD ?asm MATE ?c1 FACE ?f1 COINCIDENT WITH ?c2 FACE ?f2
AFTER CAD ?asm MATE ?c1 AXIS ?a1 CONCENTRIC WITH ?c2 AXIS ?a2
AFTER CAD ?asm INTERFERENCE CHECK SET ?clashes
Rigid-Body Dynamics - Two-Link Arm
NEW CAD ASSEMBLY SET ?asm
AFTER CAD ?asm INSERT COMPONENT ?base AS "base" SET ?baseComp
AFTER CAD ?asm INSERT COMPONENT ?link1 AS "link1" SET ?link1Comp
AFTER CAD ?asm INSERT COMPONENT ?link2 AS "link2" SET ?link2Comp

AFTER CAD ?link1Comp MASS 5 INERTIA 0.1,0.1,0.2
AFTER CAD ?link2Comp MASS 3 INERTIA 0.05,0.05,0.1

AFTER CAD ?asm JOINT REVOLUTE BETWEEN ?baseComp AND ?link1Comp AXIS "z" SET ?joint1
AFTER CAD ?asm JOINT REVOLUTE BETWEEN ?link1Comp AND ?link2Comp AXIS "z" SET ?joint2

AFTER CAD ?asm TORQUE ?joint1 AMOUNT 2 WAVEFORM "sine" FREQUENCY 0.5
AFTER CAD ?asm MOTION SIMULATE DURATION 5 STEP 0.01 SET PROMISE ?motion
AFTER WAIT FOR ?motion SET ?trajectory
AFTER CAD ?trajectory EXTRACT POSITION OF ?link2Comp SET ?path

Rigid-Body Motion

A link is a body in a chain: a mass on an arm, hinged at one end. NEW CAD LINK describes one and returns it as a value - nothing is created and no document is touched. An array of them is a linkage, and CAD SIMULATE MOTION integrates it forward under gravity.

Every quantity is in the same units the rest of CAD uses: millimetres, kilograms, degrees, and gravity in mm/s². Earth is -9810, which is the default and the reason it is negative - down.

On NEW CAD LINK Meaning Default
MASSMass of the body, kg1
LENGTHDistance from its hinge to its mass, mm100
ANGLEStarting angle, degrees. 0 is horizontal - where gravity pulls hardest. ±90 is vertical0
VELOCITYStarting angular velocity, deg/s0
TORQUEConstant torque applied at the hinge, Nmm0
DAMPINGResistance at the hinge. Zero swings forever0
INERTIAMoment of inertia. Zero derives it from mass and length0
A Pendulum, Released Horizontally
NEW CAD LINK MASS 1 LENGTH 1000 ANGLE 0 SET ?arm
AFTER NEW ARRAY SET ?links
AFTER APPEND ?arm TO ?links
AFTER CAD SIMULATE MOTION ?links DURATION 4 STEP 0.001 SET ?run
AFTER EMIT ?run

Angles are measured from horizontal. At 0 the arm is level and gravity has the most leverage on it; at -90 it hangs straight down; at 90 it stands straight up. The torque follows cos of the angle, which is why a link starting at exactly 90 does not move - it is balanced, and the solver is right to leave it there. Nudge it with ANGLE 89 and it falls.

Released from horizontal, an undamped pendulum swings down through the bottom and up the far side to -180, where its mass is level with the pivot again, then returns to 0. It should never pass either end. That is the check worth running first: angles beyond the pair mean the step is too coarse and the integrator is adding energy rather than conserving it. Halve STEP until it settles.

A Double Pendulum
NEW CAD LINK MASS 1 LENGTH 500 ANGLE 0 SET ?upper
AFTER NEW CAD LINK MASS 0.5 LENGTH 400 ANGLE 0 SET ?lower
AFTER NEW ARRAY SET ?chain
AFTER APPEND ?upper TO ?chain
AFTER APPEND ?lower TO ?chain
AFTER CAD SIMULATE MOTION ?chain DURATION 6 STEP 0.0005 SET ?run
AFTER EMIT ?run

Order matters: the first link hinges on the world, and each one after hinges on the end of the one before it.

Each link is integrated independently and its angle is relative to the one before it, so a chain is a sequence of driven arms rather than a fully coupled multibody solve. For a linkage under load that is what you want; for a chaotic double pendulum, expect the shape of the motion rather than a trajectory that matches a reference to many decimal places.

A driven joint is torque, not motion. There is no way to say “rotate at this speed”, because a rigid-body solver answers what the physics does rather than what you wanted. Apply TORQUE and add DAMPING, and the steady speed falls out of the two.
Gravity in millimetres. -9810 rather than -9.81, because every length in CAD is a millimetre. Passing -9.81 gives a world where everything falls a thousand times too slowly, and nothing in the output says so.

CAD THICKEN

Gives a surface thickness, turning it into a solid. A lofted or swept surface has area but no volume - it cannot be printed, meshed for analysis, or subtracted from anything. THICKNESS is in millimetres and the material is added to one side.

A Surface Made Printable
CAD LOFT PROFILES ?sections SET ?skin
AFTER CAD THICKEN ?skin THICKNESS 2 SET ?shell
AFTER CAD EXPORT ?shell AS "stl" INTO "/root/cad/shell.stl"

Check it worked by measuring: a surface reports a volume of zero, a thickened one does not.

Proving It Is Solid
CAD MEASURE ?shell SET ?m
AFTER EMIT "volume: " & ?m("volume")