Parametric from the first line: PiQ Lang in five minutes
ยท By The ParametrIQ team
A ParametrIQ CAD drawing is a PiQ Lang program. The .piq file is a list of PiQ Lang lines, and everything you draw
with the mouse is saved as them. So anything you draw can be written, read and changed as text, and anything you write
can be opened and drawn on. Here is the language in five minutes. Type along in the Playground: it runs
each statement you type and shows its value.
Definitions, not copies
A variable is a name for a value, made with =. It keeps its definition, not the value it had when it was made:
WIDTH=50
DEPTH=WIDTH/2
WIDTH=80
DEPTH
DEPTH is 40: "half of WIDTH", always. That is what makes a design parametric: a whole drawing is defined from a few
variables, and changing them redraws it. See Variables.
Points that follow
A drawing is built on points, P and a number. Every drawing starts with four, the corners of the box: P0 at the
origin, P1 L to its right, P2 W above P1, and P3 to the left of P2. A new point keeps its definition too, so a point
made from other points moves when they do: P4=DOWN(P0,WALL) is always WALL below P0. See Points.
A whole design
Put together, a dozen lines define the blank for a tray: a base L by W, creased, with a wall WALL high on each
side, its outline cut.
WALL=40,"Wall height"
P4=DOWN(P0,WALL)
P5=DOWN(P1,WALL)
P6=RIGHT(P1,WALL)
P7=RIGHT(P2,WALL)
P8=UP(P2,WALL)
P9=UP(P3,WALL)
P10=LEFT(P3,WALL)
P11=LEFT(P0,WALL)
POLYLINE @1,[P0,P1,P2,P3],TRUE,1
POLYLINE @2,[P0,P4,P5,P1,P6,P7,P2,P8,P9,P3,P10,P11],TRUE,0
L=300
Nothing in it is at a fixed position except P0: every corner is worked out from the box's size and WALL. Change L
to 500, and the blank is redrawn for a tray 500 long. The "Wall height" after WALL labels the variable: ParametrIQ CAD
shows the label in the Variables panel and asks for it by that name. See
A whole design.
Where next
- The PiQ Lang primer goes on to loops and choices, functions of your own and drawings within drawings.
- Expressions lists every operator and function, and Interactive every command.
- Templates written this way run unchanged through the ParametrIQ SaaS API, so your own programs can make the same drawing at any size.