Skip to content

hertzforge.core.solids

solids

Solids: the shapes a part is made of, before it is meshed.

A part is described most directly by its shapes. The frame of the Frame-Wing example is a block with four windows and 41 holes taken out of it, and a wing is a block less eighteen holes. So a geometry holds a table of solids beside its nodes, coordinate systems and elements. Each one is a primitive (a block or a cylinder, or a section or a hole made of them, placed by a center and three angles), a boolean of others (union, subtract or intersect), or a pattern of copies of others. Solids are not elements: nothing that solves, animates or exports a geometry reads them, and meshing them (Mesh Solids, extrusion_mesh) is what turns them into elements.

The table holds recipes, the numbers a person typed, so a saved project reopens editable and needs no geometry kernel to load. Evaluating a solid (its volume, its surface for drawing, the boolean itself) is done by OpenCASCADE (shape), through the OCP bindings the STEP importer also uses, a dependency of the package. Whether a point is inside a solid, which is what meshing asks, is worked out from the recipes without the kernel (contains).

Lengths are held as the geometry holds its coordinates (meters once its units are defined), and angles in degrees about the geometry's fixed X, then Y, then Z axes, the rule the add pane turns a solid by (rotate.frame_from_angles).

Classes:

Name Description
Solid

One row of a geometry's solids table.

NotAnExtrusion

The parts cannot be meshed into bricks: a solid is turned off

Functions:

Name Description
add_block

Add a block to geometry's solids, widths across along its own

add_cylinder

Add a cylinder to geometry's solids, radius about its own Z

add_cone

Add a cone to geometry's solids: a frustum height along its own

add_sphere

Add a sphere to geometry's solids, radius about center.

add_plate

Add a plate to geometry's solids: a flat rectangle widths

add_disk

Add a disk to geometry's solids: a flat circle of radius in

is_flat

Whether a solid is flat: a plate or a disk, or a boolean or a

add_section

Add a section to geometry's solids: an I-beam, a channel, a tee,

add_hole

Add a hole to geometry's solids, to subtract from a part.

edit

Change a solid after it is made, in place.

move

Move solids whole, each with every solid it is made of, turned by

combine

Add a boolean of solids already there: their union, the first with

reorder

Put solids in a new order: the parts, or one solid's own.

nothing_left

Why a boolean leaves nothing (a subtraction whose first solid lies

delete

Delete solids, each with everything it is made of: a plate with

copy

Copy solids, recipe and all, into a geometry: geometry itself,

separate

Take booleans and patterns apart: each one is removed, and its

pattern

A pattern of solids: counts copies along the geometry's X, Y and

used_by

{solid id: the id of the boolean or pattern it is part of}, for

top_level

The solids no boolean uses: the parts as they stand, which are the

solid

The solid with this id; KeyError if there is none.

require_kernel

The OCP bindings, or a ValueError whose message says why they

shape

The solid as an OpenCASCADE shape, in the units the geometry holds

brick_count

About how many bricks a mesh of these parts at size holds:

fitted_brick_count

About how many bricks hexmesh.overlay_mesh makes of these parts

volume

The solid's volume, in the cube of the geometry's length unit (m³

area

A flat solid's area, in the square of the geometry's length

shape_triangles

The corners of the triangles OpenCASCADE tessellates a shape's

contains

Which of points lie inside the solid, worked out from its recipe

distance

The signed distance from each of points to the solid's surface,

distance_gradient

distance and its gradient together: the unit direction out of

extrusion_axis

The axis (0, 1 or 2) the parts are extrusions along.

mesh_size

The element size an extrusion is meshed at by default: half the

smallest_feature

(the smallest radius, the thinnest wall) of the parts, in the

refuse_parts_of_another

Refuse a solid that is part of a boolean or a pattern: the one

grid_cells

How many bricks the grid extrusion_mesh would lay for these

extrusion_bricks

How many bricks extrusion_mesh makes of these parts at size,

extrusion_mesh

The parts as eight-node bricks, ready to join to a geometry

brick_mesh

The parts as eight-node bricks: extrusion_mesh where they are

piece_cuts

The pieces a brick mesh is made in, each with the solids cut

meshed_as

The id of the solid a piece is meshed as, while the block runs:

pieces

The pieces a brick mesh is made in when the parts together are

piece_name

The name a piece's element group takes: the solid's name, or

piece_plan

How brick_mesh would mesh these parts in pieces: for each

turned_sweep

A block, cylinder or section turned off the geometry's axes,

groups_meshed_again

The element groups of geometry that the mesh part of the parts ids goes into,

meshed_elements

The ids of the elements Mesh Solids makes, bricks, tetrahedra

Classes

Solid dataclass

Solid(id: int, name: str, kind: str, center: tuple[float, float, float] = (0.0, 0.0, 0.0), angles: tuple[float, float, float] = (0.0, 0.0, 0.0), widths: tuple[float, float, float] = (0.0, 0.0, 0.0), radius: float = 0.0, length: float = 0.0, operands: tuple[int, ...] = (), corner: float = 0.0, counts: tuple[int, int, int] = (1, 1, 1), dimensions: tuple[float, ...] = ())

One row of a geometry's solids table.

A primitive is placed by its center and turned by angles. A block is widths across along its own axes, and a cylinder is radius about its own Z axis and length along it. A section or a hole is sized by its dimensions (SECTIONS, HOLE_DIMENSIONS), and a section is length along its own Z. A boolean names its operands by id, in order (a subtraction takes the rest from the first), and its own numbers are unused. A pattern names its solids as a boolean does and holds counts copies along its own axes, widths apart, turned by angles; the copies follow the originals, and the pattern is changed as one.

Parameters:

Name Type Description Default
id int

Unique within the geometry.

required
name str

What a person calls it; may be empty.

required
kind str

One of PRIMITIVES, one of OPERATIONS, or PATTERN.

required
center tuple of float

The primitive's middle.

(0.0, 0.0, 0.0)
angles tuple of float

Degrees about the fixed X, then Y, then Z axes.

(0.0, 0.0, 0.0)
widths tuple of float

A block's three widths along its own axes, a plate's two along its own X and Y (and zero along Z); a pattern's spacing along its own.

(0.0, 0.0, 0.0)
radius float

A cylinder's; a cone's radius at its base (its own -Z end) and its height; a sphere's radius; a disk's radius, in its own XY plane.

0.0
length float

A cylinder's; a cone's radius at its base (its own -Z end) and its height; a sphere's radius; a disk's radius, in its own XY plane.

0.0
operands tuple of int

A boolean's solids, by id.

()
corner float

A block's corner radius, to which its four edges along its own Z are rounded, so a window cut with rounded corners leaves the fillets a part has there.

0.0
counts tuple of int

A pattern's copies along its own axes, the original counted.

(1, 1, 1)
dimensions tuple of float

A section's or a hole's, in the order SECTIONS and HOLE_DIMENSIONS name them; a cone's radius at its top.

()

Methods:

Name Description
scaled

The same solid with every length multiplied by factor, which

as_record

The solid as plain numbers, for a file.

from_record

The solid a file's record describes (as_record).

Methods:
scaled
scaled(factor: float) -> Solid

The same solid with every length multiplied by factor, which is what a change of the geometry's length unit does to it.

as_record
as_record() -> dict

The solid as plain numbers, for a file.

from_record classmethod
from_record(record: dict) -> Solid

The solid a file's record describes (as_record).

NotAnExtrusion

Bases: ValueError

The parts cannot be meshed into bricks: a solid is turned off the geometry's axes. Tetrahedra can mesh them (tetmesh).

Functions:

add_block

add_block(geometry: Any, center: ArrayLike, widths: ArrayLike, angles: ArrayLike = (0.0, 0.0, 0.0), name: str = '', corner: float = 0.0) -> int

Add a block to geometry's solids, widths across along its own axes, with its middle at center and turned by angles.

Parameters:

Name Type Description Default
geometry Geometry

Where it goes; changed in place.

required
center array_like

Three numbers each, as the geometry holds its coordinates; every width positive.

required
widths array_like

Three numbers each, as the geometry holds its coordinates; every width positive.

required
angles array_like

Degrees about the fixed X, then Y, then Z axes.

(0, 0, 0)
name str

What to call it.

''
corner float

The radius its four edges along its own Z are rounded to, from zero to half the narrower of its widths along X and Y.

0

Returns:

Type Description
int

The new solid's id.

add_cylinder

add_cylinder(geometry: Any, center: ArrayLike, radius: float, length: float, angles: ArrayLike = (0.0, 0.0, 0.0), name: str = '') -> int

Add a cylinder to geometry's solids, radius about its own Z axis and length along it, with its middle at center and turned by angles. With no angles its axis is the geometry's Z.

Parameters:

Name Type Description Default
geometry Geometry

Where it goes; changed in place.

required
center array_like

Three numbers, as the geometry holds its coordinates.

required
radius float

As the geometry holds its coordinates; both positive.

required
length float

As the geometry holds its coordinates; both positive.

required
angles array_like

Degrees about the fixed X, then Y, then Z axes.

(0, 0, 0)
name str

What to call it.

''

Returns:

Type Description
int

The new solid's id.

add_cone

add_cone(geometry: Any, center: ArrayLike, base_radius: float, top_radius: float, height: float, angles: ArrayLike = (0.0, 0.0, 0.0), name: str = '') -> int

Add a cone to geometry's solids: a frustum height along its own Z, base_radius at its -Z end and top_radius at its +Z end, either of them zero for a point, with its middle at center and turned by angles. With no angles its axis is the geometry's Z.

Parameters:

Name Type Description Default
geometry Geometry

Where it goes; changed in place.

required
center array_like

Three numbers, as the geometry holds its coordinates.

required
base_radius float

Not negative, not both zero, and not equal (that is a cylinder).

required
top_radius float

Not negative, not both zero, and not equal (that is a cylinder).

required
height float

Positive.

required
angles array_like

Degrees about the fixed X, then Y, then Z axes.

(0, 0, 0)
name str

What to call it.

''

Returns:

Type Description
int

The new solid's id.

add_sphere

add_sphere(geometry: Any, center: ArrayLike, radius: float, name: str = '') -> int

Add a sphere to geometry's solids, radius about center.

Parameters:

Name Type Description Default
geometry Geometry

Where it goes; changed in place.

required
center array_like

Three numbers, as the geometry holds its coordinates.

required
radius float

Positive.

required
name str

What to call it.

''

Returns:

Type Description
int

The new solid's id.

add_plate

add_plate(geometry: Any, center: ArrayLike, widths: ArrayLike, angles: ArrayLike = (0.0, 0.0, 0.0), name: str = '') -> int

Add a plate to geometry's solids: a flat rectangle widths across along its own X and Y, in its own XY plane, with its middle at center and turned by angles. With no angles it lies in the geometry's XY plane.

A plate has no thickness of its own. It is meshed into plates (Mesh Solids, Shells), and the thickness is set on their element group. Solids subtracted from it cut it where they cross its plane.

Parameters:

Name Type Description Default
geometry Geometry

Where it goes; changed in place.

required
center array_like

Three numbers, as the geometry holds its coordinates.

required
widths array_like

Two numbers, both positive: along its own X, then Y.

required
angles array_like

Degrees about the fixed X, then Y, then Z axes.

(0, 0, 0)
name str

What to call it.

''

Returns:

Type Description
int

The new solid's id.

add_disk

add_disk(geometry: Any, center: ArrayLike, radius: float, angles: ArrayLike = (0.0, 0.0, 0.0), name: str = '') -> int

Add a disk to geometry's solids: a flat circle of radius in its own XY plane, centered at center and turned by angles. With no angles it lies in the geometry's XY plane.

A disk has no thickness of its own; as a plate's, it is set on the element group it is meshed into (Mesh Solids, Shells).

Parameters:

Name Type Description Default
geometry Geometry

Where it goes; changed in place.

required
center array_like

Three numbers, as the geometry holds its coordinates.

required
radius float

Positive.

required
angles array_like

Degrees about the fixed X, then Y, then Z axes.

(0, 0, 0)
name str

What to call it.

''

Returns:

Type Description
int

The new solid's id.

is_flat

is_flat(geometry: Any, solid_id: int) -> bool

Whether a solid is flat: a plate or a disk, or a boolean or a pattern whose material is one, such as a plate with holes subtracted from it. A flat solid is meshed into plates on its plane, and a union of flat and solid ones is refused when it is made.

Parameters:

Name Type Description Default
geometry Geometry

Whose solid.

required
solid_id int

Which.

required

Returns:

Type Description
bool

add_section

add_section(geometry: Any, shape: str, center: ArrayLike, dimensions: Sequence[float], length: float, angles: ArrayLike = (0.0, 0.0, 0.0), name: str = '') -> int

Add a section to geometry's solids: an I-beam, a channel, a tee, an angle, or a rectangular or round tube, length along its own Z.

A section is one row, sized by its own dimensions, where a union of blocks would be three rows changed one at a time. Its middle (the middle of the box it fills) is at center, and with no angles it runs along the geometry's Z.

Across, along its own axes: an I-beam's or a tee's depth runs along Y and its flange width along X, with a tee's flange at +Y; a channel's flanges run along +X from its web; an angle's long leg runs along +X and its short leg along +Y from the heel; a rectangular tube is width along X and height along Y. The dimensions are checked by the beam section's rules (fem.Section.of_shape), so a shape refused as a beam's section is refused here, and a round tube's wall must also be under half its outer diameter.

Parameters:

Name Type Description Default
geometry Geometry

Where it goes; changed in place.

required
shape str

One of SECTIONS.

required
center array_like

Three numbers, as the geometry holds its coordinates.

required
dimensions sequence of float

In the order SECTIONS[shape] names them, as the geometry holds its coordinates.

required
length float

As the geometry holds its coordinates; positive.

required
angles array_like

Degrees about the fixed X, then Y, then Z axes.

(0, 0, 0)
name str

What to call it.

''

Returns:

Type Description
int

The new solid's id.

add_hole

add_hole(geometry: Any, center: ArrayLike, diameter: float, depth: float | None = None, angles: ArrayLike = (0.0, 0.0, 0.0), name: str = '', counterbore: tuple[float, float] | None = None) -> int

Add a hole to geometry's solids, to subtract from a part.

The hole enters at center, on the face it is drilled from, and runs depth along its own -Z (down the geometry's Z with no angles). With no depth it runs through the part it is cut from, however thick that part is later made. A counterbore is a wider, shallower bore at the entry.

Parameters:

Name Type Description Default
geometry Geometry

Where it goes; changed in place.

required
center array_like

Where it enters, three numbers as the geometry holds its coordinates.

required
diameter float

As the geometry holds its coordinates; positive.

required
depth float

As the geometry holds its coordinates; None or zero for a hole through the part.

None
angles array_like

Degrees about the fixed X, then Y, then Z axes.

(0, 0, 0)
name str

What to call it.

''
counterbore (float, float)

Its diameter, wider than the hole's, and its depth, positive and (for a blind hole) shallower than the hole's.

None

Returns:

Type Description
int

The new solid's id.

edit

edit(geometry: Any, solid_id: int, **changes: Any) -> None

Change a solid after it is made, in place.

What can be changed is a block's center, angles, widths and corner; a cylinder's center, angles, radius and length; a cone's center, angles, radius (at its base), top radius and length (its height); a sphere's center and radius; a plate's center, angles and widths; a disk's center, angles and radius; a section's center, angles, dimensions and length; a hole's center, angles and dimensions; a pattern's counts, spacing and angles; and any solid's name. The rest are kept. The solid keeps its id, so a boolean it is part of takes the change: a hole made larger is a larger hole in the plate it was subtracted from. A mesh already made from it is not changed; running Mesh Solids again meshes the change.

Parameters:

Name Type Description Default
geometry Geometry

Whose solid; changed in place.

required
solid_id int

Which.

required
**changes Any

The numbers to change, as add_block, add_cylinder, add_section and pattern take them (a hole's dimensions in the order of HOLE_DIMENSIONS, a depth of zero for through), and name.

{}

Raises:

Type Description
ValueError

For a number its kind does not have (a boolean's shape is its solids', changed one at a time, and a boolean is moved whole by move), or a value an add would refuse.

KeyError

If there is no solid solid_id.

move

move(geometry: Any, ids: Sequence[int], offset: ArrayLike = (0.0, 0.0, 0.0), turn: ArrayLike = (0.0, 0.0, 0.0)) -> int

Move solids whole, each with every solid it is made of, turned by turn about the middle of their extent and then moved by offset.

A boolean has no position of its own to change, so its solids are moved, each center turned about that middle and each solid turned by the same angles, and the part is the same shape in a new place. A pattern's originals move, and its axes turn with them.

Parameters:

Name Type Description Default
geometry Geometry

Whose solids; changed in place.

required
ids sequence of int

The solids, by id.

required
offset array_like

How far, as the geometry holds its coordinates.

(0, 0, 0)
turn array_like

Degrees about the fixed X, then Y, then Z axes, as a solid's angles are.

(0, 0, 0)

Returns:

Type Description
int

How many primitives moved.

combine

combine(geometry: Any, operation: str, ids: Sequence[int], name: str = '') -> int

Add a boolean of solids already there: their union, the first with the rest subtracted from it, or what they share.

Each solid goes into one boolean only, so a solid already part of another is refused. So is a boolean that would leave nothing: a subtraction whose first solid lies inside the rest, or an intersection of solids that do not meet. The operands become part of the new solid, and the table lists only the solids nothing else uses (top_level).

Parameters:

Name Type Description Default
geometry Geometry

Where it goes; changed in place.

required
operation str

One of OPERATIONS.

required
ids sequence of int

Two solids or more, by id, the first first.

required
name str

What to call it; the first solid's name when not given, so a plate named 'frame' with its holes subtracted is still 'frame', and so is the element group it meshes into.

''

Returns:

Type Description
int

The new solid's id.

reorder

reorder(geometry: Any, ids: Sequence[int], within: int | None = None) -> None

Put solids in a new order: the parts, or one solid's own.

The order is what a boolean made from a pick reads first to last, and a subtraction takes every solid after the first from the first, so which solid comes first decides what is cut. With within, the ids are that boolean's (or pattern's) solids in their new order, and an existing subtraction then cuts the new first solid. Without it, they are the parts (top_level) in their new order; the solids a boolean uses stay where they are.

Parameters:

Name Type Description Default
geometry Geometry

Whose solids; changed in place.

required
ids sequence of int

Every one of the solids being ordered, each once, in the order wanted.

required
within int

The boolean or pattern whose solids these are.

None

Raises:

Type Description
ValueError

When ids is not exactly those solids, within has none, or the new order would leave the boolean empty.

nothing_left

nothing_left(geometry: Any, solid_id: int) -> str | None

Why a boolean leaves nothing (a subtraction whose first solid lies inside the rest, an intersection of solids that do not meet), or None when something is left.

Parameters:

Name Type Description Default
geometry Geometry

The geometry whose solids table holds it.

required
solid_id int

The solid, by id.

required

Returns:

Type Description
str or None

delete

delete(geometry: Any, ids: Sequence[int]) -> int

Delete solids, each with everything it is made of: a plate with holes cut in it is deleted whole, with the cylinders that cut them. A solid that a boolean still uses is refused, by name, unless that boolean is deleted with it; take the boolean apart first (separate).

Parameters:

Name Type Description Default
geometry Geometry

Whose solids; changed in place.

required
ids sequence of int

The solids, by id.

required

Returns:

Type Description
int

How many solids went, those inside included.

copy

copy(geometry: Any, ids: Sequence[int], into: Any = None) -> list[int]

Copy solids, recipe and all, into a geometry: geometry itself, or into. Returns the new top-level ids, in the order of ids.

A boolean or a pattern is copied with every solid it is made of, each under a new id, so the copy is its own: editing a cylinder of the copy leaves the original. A named solid's copy is named ' copy'; the solids inside it keep their names. The two geometries have to hold their coordinates the same way, both with their units defined or neither.

Parameters:

Name Type Description Default
geometry Geometry

Whose solids.

required
ids sequence of int

The solids to copy, by id.

required
into Geometry

Where the copies go; geometry when omitted.

None

Returns:

Type Description
list of int

Raises:

Type Description
ValueError

With no ids, an id the geometry does not hold, or geometries whose units differ.

separate

separate(geometry: Any, ids: Sequence[int]) -> int

Take booleans and patterns apart: each one is removed, and its operands stand as parts again, which undoes a subtraction made by mistake. A primitive has nothing to take apart and is refused, and so is a solid that is still part of another.

Parameters:

Name Type Description Default
geometry Geometry

Whose solids; changed in place.

required
ids sequence of int

The booleans or patterns, by id.

required

Returns:

Type Description
int

How many solids stand again.

pattern

pattern(geometry: Any, ids: Sequence[int], counts: Sequence[int], spacing: Sequence[float]) -> int

A pattern of solids: counts copies along the geometry's X, Y and Z, spacing apart, with the originals as the first of each.

Thirteen holes along a rail are one hole and counts of (13, 1, 1) at the insert pitch. The pattern is one solid, made of the originals as a boolean is, so changing the hole changes every copy, and the pattern's counts and spacing are changed as one (edit). It takes its first solid's name, as a boolean does. A pattern of a pattern is a grid of grids: the row of 13, then two rows across the rails. More than PATTERN_LIMIT (10,000) copies is refused.

Parameters:

Name Type Description Default
geometry Geometry

Whose solids; changed in place.

required
ids sequence of int

The solids to copy, by id: solids nothing else uses.

required
counts sequence of int

How many along X, Y and Z, the original included; each one or more.

required
spacing sequence of float

How far apart along X, Y and Z, as the geometry holds its coordinates; it may be zero only along an axis with one copy.

required

Returns:

Type Description
int

The pattern's id.

used_by

used_by(geometry: Any) -> dict[int, int]

{solid id: the id of the boolean or pattern it is part of}, for every solid that is an operand of another.

top_level

top_level(geometry: Any) -> list[Solid]

The solids no boolean uses: the parts as they stand, which are the ones a person sees, edits and meshes.

solid

solid(geometry: Any, solid_id: int) -> Solid

The solid with this id; KeyError if there is none.

require_kernel

require_kernel() -> ModuleType

The OCP bindings, or a ValueError whose message says why they did not import and how to reinstall them.

shape

shape(geometry: Any, solid_id: int) -> TopoDS_Shape

The solid as an OpenCASCADE shape, in the units the geometry holds its coordinates in.

A block or a cylinder is built and placed, a section or a hole is built from the blocks and cylinders it is made of, and a boolean or a pattern is computed from its operands' shapes. A boolean the kernel cannot compute raises ValueError naming the solid.

Parameters:

Name Type Description Default
geometry Geometry

The geometry whose solids table holds it.

required
solid_id int

The solid, by id.

required

Returns:

Type Description
TopoDS_Shape

brick_count

brick_count(geometry: Any, ids: Sequence[int], size: float) -> int

About how many bricks a mesh of these parts at size holds: their volume over the cube of the size, the volume read by sampling their box on a grid as fine as the size or _SAMPLES points along each axis, whichever is coarser. Kernel-free and quick, for the limit (MESH_LIMIT) and the pane's preview; a part thinner than the samples' spacing can be undercounted, so the meshers count the bricks they keep again.

Parameters:

Name Type Description Default
geometry Geometry

Whose solids.

required
ids sequence of int

The parts, by id.

required
size float

The brick size, as the geometry holds its coordinates.

required

Returns:

Type Description
int

fitted_brick_count

fitted_brick_count(geometry: Any, ids: Sequence[int], size: float) -> int

About how many bricks hexmesh.overlay_mesh makes of these parts at size: the grid's cubes the parts hold (brick_count) and the pillow, a brick on each face where the grid steps from inside to outside, those faces counted on the same samples. Kernel-free.

Parameters:

Name Type Description Default
geometry Geometry

Whose solids.

required
ids sequence of int

The parts, by id.

required
size float

The brick size, as the geometry holds its coordinates.

required

Returns:

Type Description
int

volume

volume(geometry: Any, solid_id: int) -> float

The solid's volume, in the cube of the geometry's length unit (m³ once units are defined).

Parameters:

Name Type Description Default
geometry Geometry

The geometry whose solids table holds it.

required
solid_id int

The solid, by id.

required

Returns:

Type Description
float

area

area(geometry: Any, solid_id: int) -> float

A flat solid's area, in the square of the geometry's length unit (m² once units are defined): what a plate or a disk reads as, having no volume.

Parameters:

Name Type Description Default
geometry Geometry

The geometry whose solids table holds it.

required
solid_id int

The solid, by id.

required

Returns:

Type Description
float

shape_triangles

shape_triangles(item: TopoDS_Shape, deflection: float = DEFLECTION) -> ndarray

The corners of the triangles OpenCASCADE tessellates a shape's faces into, with deflection a fraction of the shape's size. This is what draws a solid, and how the STEP importer reads a part.

Parameters:

Name Type Description Default
item TopoDS_Shape

The shape.

required
deflection float

How far a triangle may stand off the surface, as a fraction of the shape's size.

DEFLECTION

Returns:

Type Description
ndarray

(n, 3, 3): each triangle's three corners; none for a shape with nothing in it, such as a subtraction whose first solid lies inside the rest.

contains

contains(geometry: Any, solid_id: int, points: ArrayLike, ignore: Collection[int] = ()) -> ndarray

Which of points lie inside the solid, worked out from its recipe without the kernel: a block's box and a cylinder's radius and length, combined as its booleans say. A point on a face counts as inside.

Parameters:

Name Type Description Default
geometry Geometry

The geometry whose solids table holds it.

required
solid_id int

The solid, by id.

required
points array_like

(n, 3), as the geometry holds its coordinates.

required
ignore collection of int

Solids read as holding nothing: a cylinder subtracted is not cut, one unioned adds nothing. The mesher reads a part this way without the cylinders that run across its extrusion.

()

Returns:

Type Description
numpy.ndarray of bool

distance

distance(geometry: Any, solid_id: int, points: ArrayLike, ignore: Collection[int] = ()) -> ndarray

The signed distance from each of points to the solid's surface, negative inside, worked out from its recipe: a block's and a cylinder's exact distances, a union the least of its operands', an intersection the greatest, a subtraction the greater of the first's and the negatives of the rest's. Exact for a block and a cylinder; for a boolean, exact outside and at the surface, and a bound inside, which is what a mesher needs: where the surface is and which way is out.

Parameters:

Name Type Description Default
geometry Geometry

The geometry whose solids table holds it.

required
solid_id int

The solid, by id.

required
points array_like

(n, 3), as the geometry holds its coordinates.

required
ignore collection of int

Solids read as holding nothing, as contains reads them.

()

Returns:

Type Description
ndarray

(n,), in the geometry's length unit.

distance_gradient

distance_gradient(geometry: Any, solid_id: int, points: ArrayLike, ignore: Collection[int] = ()) -> tuple[ndarray, ndarray]

distance and its gradient together: the unit direction out of the material at each point, exact where the distance is smooth and one side's value on an edge or a corner. A boolean's gradient is the gradient of the operand that decided its distance, a cut operand's turned inward. Four distance evaluations a point by finite differences were most of a fit's projection cost (hexmesh, 2026-10-19).

Parameters:

Name Type Description Default
geometry Geometry

The geometry whose solids table holds it.

required
solid_id int

The solid, by id.

required
points array_like

(n, 3), as the geometry holds its coordinates.

required
ignore collection of int

Solids read as holding nothing, as contains reads them.

()

Returns:

Type Description
(ndarray, ndarray)

The distances, (n,), and the gradients, (n, 3).

extrusion_axis

extrusion_axis(geometry: Any, ids: Sequence[int]) -> int

The axis (0, 1 or 2) the parts are extrusions along.

Every block must be square to the geometry's axes; a solid turned off them raises NotAnExtrusion naming it. The axis is the one most of the cylinders and rounded corners run along, the largest radius deciding a tie; the rest run across the extrusion and are pulled round from the grid rather than ringed. Blocks alone are an extrusion along any axis, and the axis along which their extent is thinnest is returned.

Parameters:

Name Type Description Default
geometry Geometry

Whose solids.

required
ids sequence of int

The parts, by id.

required

Returns:

Type Description
int

mesh_size

mesh_size(geometry: Any, ids: Sequence[int]) -> float

The element size an extrusion is meshed at by default: half the thinnest feature, so every feature is two bricks across.

The thinnest feature is the shortest span between two flat faces (a cylinder's end along an axis counts as one), or the narrowest cylinder or rounded corner across (smallest_feature). With nothing to measure, the size is 1.0.

Parameters:

Name Type Description Default
geometry Geometry

Whose solids.

required
ids sequence of int

The parts, by id.

required

Returns:

Type Description
float

smallest_feature

smallest_feature(geometry: Any, ids: Sequence[int]) -> tuple[float, float]

(the smallest radius, the thinnest wall) of the parts, in the geometry's length unit: the narrowest cylinder or rounded corner, and the shortest span between two flat faces. Infinite where there is none.

Parameters:

Name Type Description Default
geometry Geometry

Whose solids.

required
ids sequence of int

The parts, by id.

required

Returns:

Type Description
(float, float)

refuse_parts_of_another

refuse_parts_of_another(geometry: Any, ids: Sequence[int]) -> None

Refuse a solid that is part of a boolean or a pattern: the one to mesh is the one it is part of.

grid_cells

grid_cells(geometry: Any, ids: Sequence[int], size: float, piece: bool = False) -> int

How many bricks the grid extrusion_mesh would lay for these parts at size holds, voids included: the count before any ownership is asked, so a pane can decide whether to preview a mesh before paying for it.

Parameters:

Name Type Description Default
geometry Geometry

Whose solids.

required
ids sequence of int

The parts, by id.

required
size float

The element size, as the geometry holds its coordinates.

required

Returns:

Type Description
int

Raises:

Type Description
ValueError

As extrusion_mesh does, for parts or a size it would refuse.

extrusion_bricks

extrusion_bricks(geometry: Any, ids: Sequence[int], size: float, piece: bool = False) -> int

How many bricks extrusion_mesh makes of these parts at size, rings and all, without making them: the section holds between two of the grid's cuts along the extrusion, so the plane is laid once for each such span and its bricks counted for every layer in it. A span a cylinder across the extrusion passes through keeps all its layers, the section changing within it.

Parameters:

Name Type Description Default
geometry Geometry

Whose solids.

required
ids sequence of int

The parts, by id.

required
size float

The element size, as the geometry holds its coordinates.

required
piece bool

A union's operand, as grid_cells takes it.

False

Returns:

Type Description
int

Raises:

Type Description
ValueError

As extrusion_mesh does, for parts or a size it would refuse.

extrusion_mesh

extrusion_mesh(geometry: Any, ids: Sequence[int], size: float, parts_apart: bool = False, progress: Any = None, piece: bool = False, cuts_from: Sequence[int] = ()) -> tuple[Any, dict]

The parts as eight-node bricks, ready to join to a geometry (mesh.join).

Each part gets one element group, named for it (or for its kind and id when it has no name). Parts that touch share their nodes there, or, with parts_apart, each keeps its own on the same grid, so the nodes of one lie on the other's and bolts can be merged there later.

The grid is cut at every flat face of every block along every axis, and each span is divided into the whole number of bricks nearest size, so flat faces fall on grid lines. A brick goes to the part whose recipe holds its center (contains), to the later part where parts overlap (a steel screw added over the insert it is threaded into makes those bricks steel), and to no part in a void. A hole, a boss or an insert is meshed round, not stair-stepped. About each circle with room, a ring mesh with its nodes evenly spaced on the circle replaces the grid. About a circle without room, or a rounded corner's arc, the nodes between its inside and the material beside it are moved radially onto it, except where the move would turn a brick inside out.

The extrusion runs along the axis most of the cylinders and rounded corners run along (extrusion_axis); a cylinder drilled across it is cut from the grid and its nodes pulled round in its own plane, without a ring, and where it meets a hole along the extrusion the bricks between the two walls are skewed. A solid turned off the axes is refused with the solid named, and so are a solid that is part of another, a size that is not positive, and a grid of more than MESH_LIMIT (2,000,000) bricks by its volume (brick_count) or a grid of more than GRID_LIMIT (10,000,000) cells.

Parameters:

Name Type Description Default
geometry Geometry

Whose solids.

required
ids sequence of int

The parts, by id; each a solid nothing else uses. Where two overlap, the later takes the bricks.

required
size float

The element size aimed at, as the geometry holds its coordinates.

required
parts_apart bool

Each part keeps its own nodes where it touches another.

False
progress callable

Told (done, total) as the mesh goes: the grid's ownership, the plane and its rings, the rounding, the bricks (the window's bar reads it; anything it raises stops the mesh).

None
piece bool

The part is a union's operand meshed on its own (brick_mesh), which is otherwise refused as part of another.

False
cuts_from sequence of int

Solids whose flat faces the grid is cut at too, where they fall within the parts: the earlier pieces of a union, so the sweep ends where it meets them.

()

Returns:

Type Description
(Geometry, dict)

The bricks, in the geometry's length unit; and what was made: 'bricks' and 'nodes', the counts; 'axis' (0, 1 or 2); 'rounded', the number of nodes moved onto a circle; 'rings', the number of rings laid, one about each circle with room; and 'shortest', the shortest brick edge.

brick_mesh

brick_mesh(geometry: Any, ids: Sequence[int], size: float, parts_apart: bool = False, progress: Any = None, sizes: Any = None) -> tuple[Any, dict]

The parts as eight-node bricks: extrusion_mesh where they are an extrusion along X, Y or Z, with rings about the holes; where they are not and are a union, its operands one at a time (pieces), each swept where it is an extrusion and fitted where it is not, at its own size, joined where their nodes coincide and tied at the seams where they do not; and hexmesh.overlay_mesh, a grid fitted to the shape, for a lone part that is no extrusion. What Mesh Solids runs for Hexes.

Parameters:

Name Type Description Default
geometry Geometry

Whose solids.

required
ids sequence of int

The parts, by id; each a solid nothing else uses.

required
size float

The element size aimed at, as the geometry holds its coordinates.

required
parts_apart bool

Each part keeps its own nodes where it touches another; the extrusion mesher's option, not the fitted grid's.

False
progress callable

Told (done, total) as the mesh goes.

None
sizes mapping of int to float

A size per piece, by solid id, for a union meshed in pieces; a piece without one takes size.

None

Returns:

Type Description
(Geometry, dict)

The bricks and what was made, as the mesher that ran says it, with 'method': 'extrusion', 'overlay' or 'pieces'. In pieces, 'pieces' lists each piece's readings with its 'name', 'method', 'size' and 'dropped' (its bricks inside the pieces before it), 'seam_shared' counts the nodes the pieces share at their seams, 'ties' the nodes joined there by rigid links and 'seams' the mated surfaces that join them (part.mates).

piece_cuts

piece_cuts(geometry: Any, ids: Sequence[int]) -> list[tuple[int, tuple[int, ...]]]

The pieces a brick mesh is made in, each with the solids cut from it: (piece, cuts).

A lone union gives up its operands, and a union among them gives up its own, all the way down, so a part unioned again with something keeps its pieces (Brandon, 2026-10-20: a table unioned with a sphere was fitted whole, its legs and rod with it). A subtraction whose first operand holds a union is split the same way, each member less what the subtraction takes: (A + B) - C is A - C and B - C. Any other solid, and a subtraction of no union, is one piece; so are parts given together, each its own.

Parameters:

Name Type Description Default
geometry Geometry

Whose solids.

required
ids sequence of int

The parts, by id.

required

Returns:

Type Description
list of (int, tuple of int)

meshed_as

meshed_as(geometry: Any, piece: int, cuts: Sequence[int] = ()) -> Iterator[int]

The id of the solid a piece is meshed as, while the block runs: the piece itself, or the subtraction of cuts from it, made for the while and taken off after, so a reading of the piece (its likely size, whether a fit is likely to fold) is a reading of what is meshed, a hole included.

pieces

pieces(geometry: Any, ids: Sequence[int]) -> list[int]

The pieces a brick mesh is made in when the parts together are not an extrusion (piece_cuts), without what is cut from them.

Parameters:

Name Type Description Default
geometry Geometry

Whose solids.

required
ids sequence of int

The parts, by id.

required

Returns:

Type Description
list of int

piece_name

piece_name(geometry: Any, solid_id: int) -> str

The name a piece's element group takes: the solid's name, or its kind and id.

piece_plan

piece_plan(geometry: Any, ids: Sequence[int], size: float, sizes: Any = None) -> list[dict]

How brick_mesh would mesh these parts in pieces: for each piece its id, 'name', 'method' ('extrusion' for a sweep, 'overlay' for a fit), 'size', 'cells', the grid's cells at that size (voids included), and 'bricks', how many the mesh holds (exactly for an extrusion, extrusion_bricks; about, for a fit, fitted_brick_count), and 'cuts', the solids cut from the piece. The pieces are piece_cuts', as deep as unions go. One entry, for the parts together, where they are one extrusion or no union to take apart; the pane reads it for its preview budget and its sizes per piece.

Parameters:

Name Type Description Default
geometry Geometry

Whose solids.

required
ids sequence of int

The parts, by id.

required
size float

The size for every piece not given its own, as the geometry holds its coordinates.

required
sizes mapping of int to float

A size per piece, by solid id.

None

Returns:

Type Description
list of dict

turned_sweep

turned_sweep(geometry: Any, piece: int, size: float, earlier: Sequence[int] = (), progress: Any = None) -> tuple[Any, dict]

A block, cylinder or section turned off the geometry's axes, swept along its own axis: meshed as an extrusion unturned at the origin (extrusion_mesh), its end where it runs into the pieces before it put on their surface, and turned and placed back.

The end goes on the earlier pieces' surface line by line: each line of nodes along the sweep is cut where it leaves them and its nodes spread evenly between there and its free end, so a rod entering a block at a slant is sheared over its length, its last layer on the block's face. A block or a section is a grid along all three of its own axes, so the sweep runs along whichever of them meets the earlier pieces at one end; a cylinder's rings run along its own Z. The bricks' quality is the worst scaled Jacobian (hexmesh), and a brick folded by the shear refuses the sweep, as does a piece that meets the earlier pieces other than at one end (NotAnExtrusion, saying why): the piece is then fitted.

Parameters:

Name Type Description Default
geometry Geometry

Whose solids.

required
piece int

The piece, by id: one primitive nothing else uses.

required
size float

The brick size, as the geometry holds its coordinates.

required
earlier sequence of int

The pieces meshed before it, which it runs into.

()
progress callable

Told (done, total).

None

Returns:

Type Description
(Geometry, dict)

The bricks, in the geometry's frame, and what extrusion_mesh says, with 'axis' None (its own), 'turned' True, 'cut', how many lines of nodes end on the earlier pieces, 'quality' and 'poor' (worst scaled Jacobian, and how many under 0.3).

groups_meshed_again

groups_meshed_again(geometry: Any, ids: Sequence[int], part: Any) -> list[int]

The element groups of geometry that the mesh part of the parts ids goes into, the one meshed before in them being what it replaces. part's groups are tied here to the solids they were meshed from (Geometry.group_solids), so the answer holds through a rename, and two parts of one name keep their own meshes. A group named for several solids, parts of one name meshed together, holds one element group between them; every mesher names a group piece_name, which is how a group finds its solids.

Parameters:

Name Type Description Default
geometry Geometry

Whose solids and elements.

required
ids sequence of int

The parts meshed, by id.

required
part Geometry

Their mesh, not yet joined; its group_solids is set.

required

Returns:

Type Description
list of int

Raises:

Type Description
ValueError

A group holds the mesh of another solid as well, which this would delete.

meshed_elements

meshed_elements(geometry: Any, groups: Iterable[int]) -> ndarray

The ids of the elements Mesh Solids makes, bricks, tetrahedra and shells, in these element groups: what meshing those parts again replaces (Project.mesh_solids, and the pane's reading before Mesh is pressed).

Parameters:

Name Type Description Default
geometry Geometry

Whose elements.

required
groups iterable of int

The element groups, by id (groups_meshed_again).

required

Returns:

Type Description
numpy.ndarray of int