The drafting guide

What the package is made of, how it meets DXF, a brief Octave primer, and tutorials that build parts and drawings step by step. Every picture is made by the code above it, and every output is what that code printed.

How the package is built

  • Package layout: the five namespaces, the classes, and how an object of one becomes an object of another.
  • DXF and the classes: what each class is written as, what each entity is read as, and how frames, layers and versions are kept.

New to Octave?

  • A brief Octave primer: The Octave the tutorials use, for readers coming from OpenSCAD or from another language.

Tutorials

  1. A first part: A mounting plate from sketch to files: an outline drawn as a region, made solid, drilled, edged, measured, and saved for a CAD program and a slicer.
  2. Outlines: polylines, splines, paths and regions: The four classes every shape in the package is drawn with: a polyline of lines and arcs, a smooth spline, a path that runs through space, and a region, the flat area a solid is made from.
  3. Working with regions: Regions combine, grow, shrink, round off and repeat, as OpenSCAD's 2-D shapes do, but with arcs kept exact: the profile of a part is finished flat, before it becomes a solid.
  4. Coordinate systems: A geom.UCS is a sheet of paper laid on a face of a part. You draw on it in its own two coordinates, and extrude, pocket and drill along its normal, so nothing is ever rotated into place. This tutorial lays sheets on parts by hand and by clicking on them in the viewer.
  5. Solids from regions: Five ways to turn a flat region into a solid: raise it, turn it, pass a surface through several of it, carry it along a path, and coil it. Each makes the solid where the region's plane puts it.
  6. Primitives, booleans and transforms: Solids built the way OpenSCAD builds them: primitives combined by union, difference and intersection, then moved, copied and coloured. Every curved face stays exact, so a cylinder cut into a part leaves a true cylinder.
  7. Features: holes, pockets, fillets, chamfers and shells: A bearing block made from three primitives and finished as a machinist would finish it: edges rounded and bevelled, a bearing seat bored, holes drilled and tapped, a relief cut underneath. Then a box hollowed into an enclosure.
  8. Sections and projections: A solid cut by a plane gives regions exact enough to build from again, and a solid seen along a direction gives its outline as regions too. Both go straight into new solids and into drawings.
  9. Technical drawings: A draw.Drawing holds a technical drawing as data: geometry, text, hatches and dimensions on named layers, each layer with a colour, a line type and a line weight. The same drawing is plotted, printed to scale, set in LaTeX and written to DXF.
  10. Meshes: A triangle mesh is how a slicer, a scanner or a download hands over a shape. This tutorial makes meshes, colours them, saves and reads them, cuts them back into regions and takes them into booleans.
  11. Assemblies: A product is named parts placed together, a part defined once however often it is used. This tutorial builds a fixture, stacks it, adds a part that exists only as a mesh, and saves the whole for a CAD program and a slicer.
  12. For OpenSCAD users: OpenSCAD's modelling words, nearly all of them, have a counterpart here, in Octave and with exact geometry. This page maps one to the other and rebuilds a classic OpenSCAD model.
  13. Surfaces through a grid: A shape written as rows and columns of points, as meshgrid makes them, is how many OpenSCAD users build what has no primitive: a ripple, a landscape, a lid that swells. This tutorial makes one such surface twice, first as facets with solid.polyhedron, then as an exact surface with solid.surface, and gives it a thickness so it can be printed.
  14. Parts as functions: A part wanted again in other sizes is, in OpenSCAD, a module with parameters. In Octave it is a function: a file of its own, named after the part, that takes the dimensions and returns the solid. Any script then calls it like any other function, and the next tutorial gives it tests.
  15. Testing parts: A part written as code can be checked by code. Octave keeps the tests of a function in the function's own file, in blocks after its code, and test runs them. This package is tested that way, and a part is too: its volume is the one intended, it fits the parts around it, and a size that cannot be made is refused.