Design rules
A design rule checks a drawing for a problem that would spoil the job: an outline that doesn't close, a cut too short for the knife, a line drawn twice, a crease too near a cut. File › Check Design runs every rule and lists what they find, each problem with Show me and, where its rule can put it right, Fix it (see Check Design and Fixing Problems). They are checked before every machine export (G-code, HP-GL and post-processors) too: if any finds a problem, you are asked whether to export anyway.
Declaring one
designRule({
name: "Holes big enough",
description: "Circles on the cutting layer are at least 3 mm across.",
severity: "error",
check(drawing) {
for (const e of drawing.elements)
if (e.kind === "CIRCLE" && e.cutting && e.radius < 1.5)
report(`${e.id} is only ${(2 * e.radius).toFixed(2)} across`, [e], e.start);
}
});
| Property | Meaning |
|---|---|
name, description |
As shown in the messages. |
severity |
"warning" (if left out) or "error": how its problems are shown. |
beforeExport |
false to check it only with Check Design, not before machine output. |
check(drawing) |
Looks at the drawing and calls report for each problem. |
fix(drawing, issue) |
Optional: puts a problem right (see Fixes). |
fixLabel |
What its fix does, shown on the Fix it button's tip and in the undo step's name ("Join the ends"). |
The drawing
| Property | Meaning |
|---|---|
name |
The drawing's file name, without its extension ("" if it hasn't been saved). |
units |
"mm" or "in". |
bounds |
The extent of its elements: {minX, minY, maxX, maxY, width, height} (null if there are none). |
layers |
The layer table: {layer, name, cutting} for each. |
elements |
Each element exported (not construction lines or those hidden from output). |
selected |
How many of them are selected. |
page |
The page worked on (its elements are the ones listed). |
nests |
The nests on every page, as below. |
frames |
Frames of mitred moulding: see Drawing API. |
notes |
The drawing's notes, by name: drawing.notes["Customer"] ({} if it has none). |
Each element has:
| Property | Meaning |
|---|---|
id |
"@12". |
kind |
Its command: "LINE", "ARC", "CIRCLE", "BEZIER", "POLYLINE", "POINT" … |
layer, layerName |
Its layer's number and name. |
cutting |
Whether that layer is cut through. |
selected |
Whether it is selected. |
length |
Its length (0 for a point). |
closed |
Whether it comes back to its start. |
area |
The area it encloses, if it is closed (0 if not). |
start, end |
Its ends, as {x, y}. |
bounds |
{minX, minY, maxX, maxY, width, height}. |
radius |
For a circle or arc. |
rule |
What kind of rule its layer is in a die: "cut", "crease", "reverseCrease", "partialCut", "perforation", "cutCrease" or "vCut"; null if it isn't a rule (dimensions, tape, your own layers). |
minRadius, minRadiusAt |
Its tightest bend: the smallest radius it curves round (its arcs, a polyline's arcs, or where a curve curves most), and where ({x, y}); null if it is straight. |
corners |
Where it turns by more than 10° (a polyline's corners), as {x, y}; its own ends aren't counted. |
pieces |
What it is made of, in order: a polyline's sides and bulges, a curve's segments, what a block made (or the element itself). Each has kind ("line", "arc" or "curve"), start, end, startTangent and endTangent (the way it runs at each end, as a unit {x, y}), layer and cutting; an arc also its centre, radius and sweep (in radians, anticlockwise positive; a circle's is a whole turn), and a curve points along it. |
bridges |
{count, width, at}, if it has bridges (nicks): at is where each goes, as Make Die places them ({x, y}). |
tool |
Its tool settings, those it is cut with (its own over its layer's), or null. |
Each nest has:
| Property | Meaning |
|---|---|
id, page, part |
Its id, the page it is on, and the part (or page) it nests. |
onPage, selected |
Whether it is on the page worked on, and selected. |
layerName |
Its layer's name. |
sheet |
{width, height, margin, gutterX, gutterY}, as the drawing is now. |
perSheet |
The copies on a sheet (0 if none fit). |
quantity |
The copies wanted (its QUANTITY; 0: one sheet's worth). |
sheets, made, spare |
The sheets those take, every sheet filled; the copies made; those beyond the copies wanted. |
sheetArea, usedArea |
A sheet's area, and the part of it used (the whole sheet). |
partsArea, partArea |
The area of the copies on a sheet, and of one copy. |
wasteArea, wastage |
A sheet's waste (the sheet less its copies), and as a fraction of it. |
utilisation |
The fraction of a sheet its copies cover. |
runWastage |
The run's wastage: all the sheets less the copies wanted, as a fraction (spare copies counted as waste). |
problem |
Why it has no layout (a part bigger than the sheet …), or null. |
Reports are given the drawing the same way.
Reporting and measuring
| Function | Meaning |
|---|---|
report(message, elements, at, fix) |
A problem: what it is; the elements it is about (an element, an array of them, or their ids), selected when it is shown; if it is at one place, where ({x, y}); and, if the rule can put it right, what its fix needs (any value; a label in it names that fix). Only message is needed; a problem reported without fix isn't offered one. |
distanceBetween(a, b) |
The shortest distance between two elements (0 where they meet or cross). |
crossings(a, b) |
Where two elements meet or cross: an array of {x, y}. |
made3D() |
What the drawing makes in 3D, as its 3D page makes it and put together by its mates: each body extruded, as {id, element, layer, thickness, materialThickness, ownThickness, noThickness, flush}: its outline's id (element, null if it has none of its own), how thick it is made, its material's thickness (its layer's THICK, else the drawing's T), whether its thickness is its own (RULE THICK), the thickness setting that comes to 0 or less ("RULE THICK", "LAYER3D THICK" or "T"; null if none does), and, for each body it is put into along its thickness (a back in its rebates, a panel in its grooves), {neighbour, element, by}: how far it stands proud of that body's face beside it (by more than 0) or below it. The 3D is made the first time a rule asks. |
The drawing API's reading functions can be used too: variable("L"), getPoint(4),
evaluate("…"). A rule's check can't change the drawing; its fix can.
Fixes
A rule with a fix offers Fix it for each problem it reported with a fourth value. The fix is given the drawing
(as check is) and the problem: {message, rule, elements, at, fix}, fix being what report was given. It changes
the drawing with the drawing API (command("…"), setVariable, newPoint …) and these:
| Function | Meaning |
|---|---|
removeElement(e) |
Takes an element (or an array of them) out of the drawing. |
joinEnds(e, at, other, to) |
Joins the end of e that is at at onto the end of other that is at to (both {x, y}): that end's point is defined as the other's, so it follows it. |
moveElements(e, dx, dy) |
Moves an element (or an array of them) by dx, dy, as dragging does: the amounts kept in new variables (MOVX1, MOVY1). |
setPartSetting(e, key, value) |
Sets a part's own 3D setting ("THICK", "Z", "DEPTH", "LOOK" …: see a part's 3D settings) to a value or expression, or takes it off (null), so its layer's is used. |
Everything a fix does is one step on the undo history, named Fix: … (its fixLabel). A fix that goes wrong, or
changes nothing, is taken back and the reason shown.
designRule({
name: "Holes big enough",
description: "Circles on the cutting layer are at least 3 mm across.",
fixLabel: "Remove the hole",
check(drawing) {
for (const e of drawing.elements)
if (e.kind === "CIRCLE" && e.cutting && e.radius < 1.5)
report(`${e.id} is only ${(2 * e.radius).toFixed(2)} across`, [e], e.start, { element: e.id });
},
fix(drawing, issue) {
removeElement(issue.fix.element);
}
});
Rules that come with the app
| Rule | Finds |
|---|---|
| Open cut lines (error) | An end of a cut line that meets no other cut line. Fix it joins an end to another cut's end (or the outline's own start) within 0.5 mm (0.02 in). |
| Very short cuts | Cut lines under 1 mm (0.04 in), or with no length. Fix it removes the cut. |
| Lines drawn twice | Two lines on one layer between the same two places. Fix it removes the second. |
| Creases too near cuts | A crease that comes within 2 mm (0.08 in) of a cut without meeting it. |
| Rules bent too tight | A cutting rule (cut, perforation, partial cut, cut-crease) curving tighter than a 1.5 mm (0.06 in) radius, or a creasing rule (crease, reverse crease) tighter than 3 mm (0.12 in): the rule can't be bent that tight. |
| Knives too close | Two cutting rules that don't meet but run side by side less than 3 mm (0.12 in) apart: too little die board between them, and no room for the rubber. Straight ones count only where they run alongside each other (nearly the same way, overlapping), not end to end or across a corner. |
| Bridge widths | Bridges narrower than 3 mm (0.12 in), too weak to hold the die board, or wider than 12 mm (0.5 in), leaving the rule unsupported. |
| Rules too short | A piece of rule shorter than 3 mm (0.12 in): a rule from end to end (counting a short element that carries straight on into one other rule at each end as part of that longer rule), or the pieces of a rule left between its bridges. Cuts under 1 mm are left to Very short cuts. |
| Bridges too near corners | A bridge whose edge comes within 3 mm (0.12 in) of a corner of its rule, an end of it, or another rule meeting or crossing it. |
| Holes too near glass and stone edges | In a drawing whose industry is Glass or Stone and tile: a hole (a round hole, or a slot: two half circles joined by straight sides, as one polyline or as lines and arcs) whose edge comes nearer an edge (its panel's, or a notch's or cut-out's) or another hole's edge than twice the panel's thickness (the drawing's T, or 6 mm, 0.25 in), or nearer a corner (the panel's, or a notch's or cut-out's inner one) than six times the thickness, or a hole smaller across (a slot: its width) than the panel is thick. A rounded corner is measured from where its sides would meet. Fix it moves a hole too near an edge straight away from it. See Glass. |
| Sharp inner corners in glass and stone | In a drawing whose industry is Glass or Stone and tile: an inner corner (a notch's, a cut-out's, or the panel's own, as in an L shape) that is sharp, or rounded tighter than the panel allows: in glass, its thickness and at least 10 mm (0.375 in); in stone, 10 mm (0.375 in). Arcs and a polyline's bulges count as rounded corners. See Holes near edges on the Glass page. |
| Notches too big in glass | In a drawing whose industry is Glass: a notch in the panel's outline (at an edge, or a corner cut away) more than a third of the panel's width across or a third of its height deep. See Glass. |
| Cut-outs too near glass and stone edges | In a drawing whose industry is Glass: a cut-out (a closed shape inside the panel that isn't a hole) with less glass between it and the panel's edges than half its width to its left and right, or half its height above and below it. In Stone and tile: a cut-out with less than 50 mm (2 in) of stone round it. See Glass. |
| 3D thickness not the material's | A part given its own 3D thickness (RULE THICK: see a part's 3D settings) that isn't its material's: its layer's 3D thickness, else the drawing's T. A part meant to be thinner (a 6 mm back) is listed too, as a reminder of the board it is cut from. Fix it takes its own thickness off. |
| Panels proud of or below their neighbours | A panel put into a rebate or groove of another by its mates whose face, once they are put together, stands proud of that one's face beside it or sits below it (by more than 0.05 mm, 0.002 in): a back thicker or thinner than its rebate is wide. |
| Bodies with no thickness (error) | A body made in 3D whose thickness comes to 0 or less: its own (RULE THICK less than 0; 0 there means its layer's), its layer's LAYER3D THICK, or the drawing's T (it is then made with the next one's, or a thin sheet). |
They are in rules.js in the app's Extensions folder. The first four take layer 0 as the cut and layer 1 as the crease;
the die rules go by each element's rule, so they work on any layer table, and their limits, in millimetres and in
inches (used for drawings in inches), are in the DIE table at the top of their part of the file. The limits are
starting points: check them against your die maker's rule and machines. Copy the file to your own folder to change the
limits or the layers; the glass and stone distances (in thicknesses), the inner corners' least radius, the notches'
largest share of the panel and the cut-outs' least distances from the edge are in its GLASS table. The last three make
the drawing 3D (made3D()), so they are checked by Check Design only, not before machine output; their limits are
in the MADE3D table.
Notes
- A rule that goes wrong is listed as a problem of its own, with the file and line, and the others are still checked.
- The problems are shown in the Interactive window, each as an error or a warning with its buttons, and in Check Design's list.
See also: Extensions, Drawing API, Making a Die.