solid.Shape
drafting: solid.Shape
A solid in millimetres, modelled through Open CASCADE.
solid.Shape holds the exact boundary of one or more solids: every
face a plane, cylinder, cone, sphere, torus or spline surface, every edge
a line, circle or curve, with nothing approximated by facets. It is what
the functions of the solid namespace create, what the boolean
operators combine, and what its write method saves as STEP for
exchange or STL for printing.
Primitives are made by
solid.box
solid.cylinder
solid.cone
solid.sphere
solid.ellipsoid
solid.torus
solid.wedge
and solids from +geom objects by
solid.extrude
solid.revolve
solid.loft
solid.sweep
solid.helix
A solid is made from a closed triangle mesh by solid.polyhedron,
and from a grid of points by solid.surface, which fits a surface
through the grid and thickens it. hull wraps shapes and points in
their convex hull, and solid.read loads solids from a STEP file.
Finally, shapes can be combined by the three boolean CAD operations, each taking any number of shapes:
| Method | Result |
|---|---|
union | the material of any of them |
subtract | the material of the first that is in none of the others |
intersect | the material common to all of them |
Features are worked on a shape by methods: hole drills plain,
counterbored, countersunk and tapping holes, pocket cuts a region
into it, fillet and chamfer round or bevel edges, and
shell hollows the shape. The edges and faces they act on are
chosen by edges and faces, by the kind of curve or surface,
by direction and by position. section cuts a shape with a plane
into regions, which the solid functions build from again, and
projection gives the outline of a shape seen along a direction as
regions in the same way.
The class is a value class. Every operation returns a new shape
and leaves its operands unchanged, and a copy is independent of the
original. The empty shape adds nothing to a union and empties an
intersection, and a boolean whose result holds no material, such as the
intersection of two solids that do not meet, returns it. A shape is
saved and loaded with save and load like any other value.
See also: solid.box, solid.read, solid.Shape.write, solid.Shape.show
Source Code: solid.Shape
The solid.Shape class contains the following properties:
An N-by-3 matrix of red, green and blue from 0 to 1, a row for
each of the shape’s N solids in the order
solid.Shape.numsolids counts them, a row of NaN for a
solid without a colour, or empty when none has one. Assigning a single
row colours every solid. The viewer shows it, and a STEP file carries
it out and in. A transform keeps it, and each solid a boolean or a
feature makes takes the colour of the first coloured solid it came
from, so parts apart keep their own; the tools of subtract give
none.
The solid.Shape class offers the following public methods:
tessellate |
A triangle mesh of a shape. |
show |
Show a shape in a viewer of its own, redrawing in place. |
write |
Write a solid to a STEP, STL, OBJ, PLY or 3MF file. |
section |
Cut a shape with a plane. |
projection |
Outline of a shape seen along a direction. |
hull |
The convex hull of shapes and points. |
resize |
Scale a shape to a size. |
copy |
Copies of a shape, united. |
rectarray |
Copies of a shape in rows, columns and layers, united. |
polararray |
Copies of a shape round an axis, united. |