magnelio.geo#

Standalone geometry is organised by dimension: Curve, Sheet (including planar Profile and curved Surface values), and Solid all derive from Shape. The named affine methods are shared by every category; immutable Transform values provide reusable composition with @. ImportedSheet retains free CAD faces as exact, trimmed zero-thickness geometry; it needs a resolved thickness before meshing. See the CAD exchange guide.

Boolean +, - and & are restricted to Solid values. Group is a material-preserving authoring collection rather than a Shape; its affine transforms distribute over its members.

translated() and rotated() optionally build regular arrays through repeat, include the original with copy=True, and aggregate through group=True or (for Solid only) unite=True. mirrored() provides the same copy and aggregation options without repeat. Default calls and Transform @ geometry retain one placement. The placement guide defines counts, return types and material preservation. For reusable components, nested Groups retain their member structure under placement; each placed Solid owns its own named faces and sets. The guide and Tutorial 14 show retrieval from several copies. Only uniform scaling is supported by Scale and Transform; nonuniform matrices and shear are rejected.

Curve.line, Curve.circle and Curve.ellipse construct exact wires. Profile.polygon, rectangle, circle and from_wires construct bounded planar regions, including holes. Curve.length and Profile.area are read-only measurements; Profile.boundary() returns detached boundary curves. See geometry construction for orientation, validation, and hole correspondence during lofting.

Curve.offset(distance, normal=...) gives directed planar offsets with round outer joins and uncapped open ends. Profile.offset(distance) dilates or erodes the material region, retaining all connected results. A curved Sheet.offset(distance, tolerance=...) moves along its oriented normal and retains the bounded rim. All three return independent results in tuples. The offset guide defines signs, hole behavior, collapse and the default sampled geometry tolerance; Tutorial 14 gives the construction recipe.

Bend(target, origin=..., along=..., across=..., u=..., v=..., max_strain=..., tolerance=...) is a reusable freeform neutral-surface map. Apply it with bend @ solid, bend @ sheet or bend @ group; the last form deforms each member with the same chart and retains separate materials. The bend guide explains source coordinates, nondevelopable strain, rigid interval continuations, sampled error limits and named-face splits. Tutorial 14 shows a layered component.

Wrap takes the same target chart, source frame, strain limit and sampled fit tolerance, then maps the whole source to the target without rigid end continuations. It accepts Solid, Sheet and Group operands. The wrapping guide specifies chart coverage, nondevelopable distortion, seams, openings and layer placement. Tutorial 14 wraps a trace and its substrate around a cylindrical patch.

Owned topology is separate from standalone geometry: TopologyRef, VertexRef, EdgeRef, FaceRef, EdgeSetRef and FaceSetRef hold one Solid owner. The Solid selectors face, edge, vertex, faces and edges accept semantic constraints or registered names; tagged_face, tagged_edge, tagged_vertex, tagged_faces and tagged_edges register immutable names. TopologySelectionError, AmbiguousTopologyError and TopologyEvolutionError distinguish missing, tied and lost selections. The owned topology guide explains measurements, detachment, history failures and project persistence. Selected rectangular FaceRef values can also define eligible waveguide ports and frequency-field recording planes; the EM face guide states the exact geometry and domain-boundary requirements.

Profile operations also accept suitable FaceRef values directly. face.extruded, revolved, swept, thickened and lofted return independent Solid geometry, retaining holes and inheriting the owner’s material. Loft accepts the same planar sections, as well as closed Curve outlines. Solid modifications accept owned selections through edges= / faces= for fillet and chamfer and openings= for shell. See the operation guide for eligibility, sweep roll, owner identity and materialless construction solids.

Path.from_pose(point, tangent, up) and Path.from_face(face_ref, up=...) seed immutable relative routes. Read current, tangent and up; append forward, exact turn_left / turn_right, a spatial turn_to, or straight_to_plane. Absolute steps remain available and update the pose. The routing guide defines left/right, rotation-minimizing transport, plane offsets and underdetermined bends. Path’s up direction guides routing; it does not select a sweep frame.

swept(frame=...) selects corrected Frenet, Frenet, fixed world orientation or fixed binormal transport. Fixed binormal requires binormal=; other modes reject that argument. See the sweep orientation guide for oblique sections, volume rules and curvature degeneracies, and Tutorial 14 for parallel-aperture transitions.

swept(twist_deg=..., draft_deg=..., tolerance=...) adds uniform total roll and a constant signed section-offset angle. Positive draft grows the exterior and shrinks holes. Twist acts about the transported section normal and preserves the selected frame’s section planes. See the twist and draft guide for arc-length laws, fitting accuracy, boundary closure and periodic routes, and Tutorial 14 for worked use.

partition(cutter) or partition(normal=..., position=...) returns independent connected Solid or Sheet regions, inheriting the source material. section with the same cutter grammar returns intersection Curves; an explicit planar filled=True section of a Solid returns Profiles with holes. Empty cuts, tangencies, coincident faces and named-topology splits have explicit rules in the partition and section guide. Tutorial 14 shows a hollow component and an oblique cutter.

Solid.imprinted(cutter) returns a receiver with faces split at the cutter’s intersection curves while preserving its volume and material. insert takes physical Solids with explicit integer priorities and optional material-less void tools, trims losing volumes and returns a material-preserving Group. The imprint and insert guide explains directed face selection, equal-priority conflicts and named topology. Tutorial 14 constructs a housing with a selectable imprinted contact and a dielectric insert.

Dimensional geometry and constructive solid geometry.

Standalone geometry has explicit dimensions: Curve is one-dimensional, Sheet is two-dimensional (with planar Profile and curved Surface categories), and Solid is three-dimensional. All derive from Shape and share immutable translation, rotation, reflection and uniform scaling. Reusable placement is expressed by Transform, Translation, Rotation, Mirror and Scale, composed and applied with @.

Boolean +, - and & and their explicit Union, Difference and Intersection spellings accept solids only. Group is a material-preserving authoring collection, not a shape or a Boolean operand; affine transforms distribute over its members.

Profile factories build planar regions from exact closed curves, including intrinsic holes. Path draws a curve through absolute segments or an immutable relative pose seeded from a point or planar face, while ThinWire is an EM mesh declaration around a curve rather than a standalone CAD dimension.

GeometryModel lives in the core magnelio namespace; every other geometry name is public here.

exception magnelio.geo.AmbiguousTopologyError#

Several subshapes satisfy a singular selection equally well.

add_note()#

Exception.add_note(note) – add a note to the exception

with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception magnelio.geo.GeometryOverlapError#

Raised when shapes in a GeometryModel overlap volumetrically.

add_note()#

Exception.add_note(note) – add a note to the exception

with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception magnelio.geo.TopologyEvolutionError#

Construction cannot prove the successor of a named selection.

add_note()#

Exception.add_note(note) – add a note to the exception

with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception magnelio.geo.TopologySelectionError#

No owned topology satisfies the requested selection.

add_note()#

Exception.add_note(note) – add a note to the exception

with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class magnelio.geo.Bend(target, origin, along, across, u, v, max_strain, tolerance=None)#

Reusable finite bend around an explicit neutral surface.

The source coordinates are measured from origin along orthonormal along and across directions; their right-handed normal is the layer direction. The target sheet’s increasing surface parameters correspond linearly to the declared u and v intervals. A point at normal distance w maps to the target point plus w times its unit normal.

Parameters:
  • target (Sheet) – Single-face neutral surface with a regular rectangular parameter chart. Its start edge must coincide with the source neutral plane.

  • origin (sequence of float) – World origin of the source frame [m].

  • along (str or sequence of float) – Perpendicular world directions of the source chart.

  • across (str or sequence of float) – Perpendicular world directions of the source chart.

  • u (pair of float) – Affected longitudinal interval and transverse chart interval [m]. Geometry before u[0] stays fixed; geometry after u[1] follows the rigid end frame. The target covers the complete transverse span.

  • v (pair of float) – Affected longitudinal interval and transverse chart interval [m]. Geometry before u[0] stays fixed; geometry after u[1] follows the rigid end frame. The target covers the complete transverse span.

  • max_strain (float) – Greatest permitted principal in-plane stretch or compression of the neutral surface, relative to the flat source chart. Required.

  • tolerance (float, optional) – Absolute sampled CAD approximation budget [m]. The default is one millionth of the source/target extent, subject to CAD resolution.

Notes

The normal extension can change volume. It is checked for folds and invalid CAD topology; the tolerance is a sampled error bound rather than a global Hausdorff certificate.

class magnelio.geo.Brick(material=None, name=None, origin=(0.0, 0.0, 0.0), size=(1.0, 1.0, 1.0))#

Axis-aligned rectangular box (cuboid).

Parameters:
  • origin (tuple of float) – (x, y, z) of the minimum-coordinate corner [meters].

  • size (tuple of float) – (dx, dy, dz) — extents in each direction [meters], each positive. To give two opposite corners in any order instead, use from_corners().

  • material (Material or str, optional) – Material filling this volume. Omit it for a construction solid used only as a Boolean operand.

  • name (str, optional) – Optional label.

classmethod from_corners(p1, p2, *, material=None, name=None)#

Build an axis-aligned Brick from two opposite corners.

The corners may be given in any order; each axis is normalised so that the resulting origin holds the minimum coordinate and size is non-negative. The origin/size fields are populated as for a directly constructed Brick, so the two forms are interchangeable downstream.

Parameters:
  • p1 (tuple of float) – Two opposite corners (x, y, z) of the box [meters], in any order.

  • p2 (tuple of float) – Two opposite corners (x, y, z) of the box [meters], in any order.

  • material (Material or str, optional) – Material filling this volume. Omit it for a construction solid used only as a Boolean operand — the two-corner form is the natural spelling for a cutting box.

  • name (str, optional) – Optional label.

Return type:

Brick

Examples

>>> Brick.from_corners((3e-3, 0, 2e-3), (0, 4e-3, 0), material=pec)
Brick(origin=(0.0, 0.0, 0.0), size=(3e-3, 4e-3, 2e-3), ...)
classmethod from_ranges(*, x1=None, x2=None, dx=None, y1=None, y2=None, dy=None, z1=None, z2=None, dz=None, material=None, name=None)#

Build an axis-aligned Brick from one coordinate range per axis.

Each axis is given by exactly two of its three keywords: the two bounds (x1, x2), a bound and an extent (x1, dx or x2, dx). Extents may be negative and bounds may come in either order; the result is normalised exactly as in from_corners(), so both forms produce identical fields and are interchangeable downstream.

This is the spelling to reach for when a box is described by the planes it lies between — a substrate between two metal layers, a cutting slab spanning a whole domain — where naming the two opposite corners would interleave the axes.

Parameters:
  • x1 (float, optional) – Lower bound, upper bound and extent along x [meters]. Supply exactly two of them.

  • x2 (float, optional) – Lower bound, upper bound and extent along x [meters]. Supply exactly two of them.

  • dx (float, optional) – Lower bound, upper bound and extent along x [meters]. Supply exactly two of them.

  • y1 (float, optional) – The same for y.

  • y2 (float, optional) – The same for y.

  • dy (float, optional) – The same for y.

  • z1 (float, optional) – The same for z.

  • z2 (float, optional) – The same for z.

  • dz (float, optional) – The same for z.

  • material (Material or str, optional) – Material filling this volume. Omit it for a construction solid used only as a Boolean operand.

  • name (str, optional) – Optional label.

Return type:

Brick

Raises:

ValueError – If an axis is given fewer or more than two of its keywords.

See also

Brick.from_corners

Build the same box from two opposite corners.

Examples

A substrate of thickness h under a ground plane at z = 0:

Brick.from_ranges(
    x1=0, dx=w, y1=0, dy=length, z2=0, dz=h, material=fr4
)
>>> Brick.from_ranges(x1=0, x2=3e-3, y1=0, dy=4e-3, z1=2e-3, z2=0)
Brick(origin=(0.0, 0.0, 0.0), size=(3e-3, 4e-3, 2e-3), ...)
bounding_box(scale=None)#

Return the axis-aligned bounding box of this shape.

The box is computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters — a rotated brick reports the box of the rotated solid.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

(min_corner, max_corner), each (x, y, z) in meters.

Return type:

tuple

chamfered(*, near=None, face_near=None, edges=None, faces=None, distance)#

Return a Solid with a flat bevel on selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms use semantic selection and refuse ambiguity.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • distance (float or tuple of float) – Positive bevel distance in metres, or an asymmetric pair.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

edge(name=None, *, near=None, curve_type=None)#

Select one owned edge, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

EdgeRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

edges(name=None, *, near=None, curve_type=None)#

Select a deliberate set of owned edges, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered set selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

Read-only view bound to this Solid. With no constraints, selects all members.

Return type:

EdgeSetRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

extruded(vector, *, face_near=None, material=None)#

Extrude a Sheet into an independent Solid, retaining holes.

Parameters:
  • vector (tuple of float) – Non-zero world extrusion vector in metres.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).extruded(vector). A tied pick raises AmbiguousTopologyError. Invalid on standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Materialless sections produce construction solids for Boolean use.

Returns:

Independent prism, without fusion to an input owner.

Return type:

Solid

face(name=None, *, near=None, normal=None, surface_type=None)#

Select one owned face, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

FaceRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

faces(name=None, *, near=None, normal=None, surface_type=None)#

Select a deliberate set of owned faces, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered set selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

Read-only view bound to this Solid. With no constraints, selects all members.

Return type:

FaceSetRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

filleted(*, near=None, face_near=None, edges=None, faces=None, radius)#

Return a Solid with rounded selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms refuse ties.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • radius (float) – Positive fillet radius in metres.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

imprinted(cutter)#

Split this body’s boundary faces along a cutter’s intersection.

The receiver keeps its volume and material. Only its boundary topology changes; the cutter remains an independent shape.

Parameters:

cutter (Solid or Sheet) – Shape whose intersection curves split the receiver’s faces.

Returns:

An independent body with imprinted boundary faces.

Return type:

Solid

Raises:

TopologyEvolutionError – If a singular named selection splits or loses its identity.

lofted(face_near, other=None, other_face_near=None, *, material=None, blend='spline', tension=None)#

Connect this section to another with an independent Solid.

For sheets, use section.lofted(other_section). Suitable FaceRef values provide the same verb. All boundaries contribute, and hole counts must agree. The retained Solid convenience is body.lofted(face_near, other_body, other_face_near); its temporary FaceRefs use semantic selection and refuse tied picks.

Parameters:
  • face_near (Profile or Sheet or FaceRef or tuple) – Planar end section for a Sheet receiver. For the Solid convenience, a world point in metres selecting its start face.

  • other (Solid, optional) – End owner for the Solid point convenience only.

  • other_face_near (tuple of float, optional) – World point selecting the end face for the Solid convenience.

  • material (Material or str, optional) – Override the start section’s material. Without a material the result is a construction solid.

  • blend ({'spline', 'ruled', 'tangent'}, optional) – Smooth or straight interpolation, or a transition leaving both oriented normals. Tangent mode requires faces looking towards each other and retains holes with the same spine conditions.

  • tension (float or tuple of float, optional) – Positive finite tangent reach fractions, only in tangent mode. Defaults to one third at each end.

Returns:

Independent transition matching corresponding boundaries.

Return type:

Solid

mirrored(normal, position=0.0, *, copy=False, unite=False, group=False)#

Return this shape reflected across a plane.

The plane is the set of points p with p · normal == position, so for an axis letter position is simply the coordinate of the plane on that axis.

A reflection is not a rotation: it leaves the two in-plane directions untouched and reverses only the normal one. That is what makes it the correct operation for a structure symmetric about a plane but not about the axis normal to it — most planar circuits (dividers, couplers, filters) and every layer stack that differs from top to bottom.

Unlike translated() and rotated() there is no repeat: mirroring twice across one plane reproduces the original.

Parameters:
  • normal (str or sequence of float) – Plane normal: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored). normal='x' maps x -> 2 * position - x.

  • position (float) – Signed distance of the plane from the coordinate origin along normal [meters] (default 0).

  • copy (bool, optional) – Include the original first; defaults to False.

  • unite (bool, optional) – Return a Union of original and image. Requires copy and Solid geometry.

  • group (bool, optional) – Return a Group of original and image, retaining member materials. Requires copy; mutually exclusive with unite.

Returns:

The image alone by default, otherwise [original, image] or the explicitly requested Union or Group.

Return type:

Shape or list of Shape or Union or Group

Examples

Complete a half-modelled power divider into one solid:

full = half.mirrored("x", copy=True, unite=True)

Mirror a feed line onto the far side of a board:

far = line.mirrored("z", position=h / 2)
partition(cutter=None, *, normal=None, position=None)#

Split this solid or sheet into independent connected regions.

Parameters:
  • cutter (Solid or Sheet, optional) – Geometry whose boundary partitions this shape.

  • normal (str or sequence of float, optional) – World normal of a cutting plane. Requires position and excludes cutter.

  • position (float, optional) – Signed plane offset [m], measured as normal dot point.

Returns:

Independently owned regions in kernel order. A non-cut returns one independent region. Order is not persistent across CAD edits.

Return type:

tuple of Solid or Sheet

revolved(axis, angle_deg=360.0, *, origin=(0.0, 0.0, 0.0), material=None)#

Revolve a planar Sheet into an independent Solid.

Parameters:
  • axis (str or sequence of float) – Revolution axis letter or non-zero world vector.

  • angle_deg (float, optional) – Non-zero right-handed angle, at most a full turn, in degrees.

  • origin (tuple of float, optional) – World point on the revolution axis, in metres.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

Returns:

Solid of revolution retaining all holes. A section crossing the axis can produce invalid or self-intersecting geometry.

Return type:

Solid

rotated(axis, angle_deg, origin=(0.0, 0.0, 0.0), *, repeat=1, copy=False, unite=False, group=False)#

Return this shape rotated about an axis.

Parameters:
  • axis (str or sequence of float) – Rotation axis: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored).

  • angle_deg (float) – Rotation angle [degrees], right-handed about axis. Copy i is rotated by i * angle_deg.

  • origin (tuple of float) – A point on the rotation axis (default: the coordinate origin).

  • repeat (int, optional) – Number of rotated copies at angle_deg through repeat * angle_deg; defaults to 1.

  • copy (bool, optional) – Include the unrotated original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One rotated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

Four posts at 90° spacing around the z axis:

posts = post.rotated("z", 90.0, repeat=3, copy=True, group=True)
scaled(factor, center=(0.0, 0.0, 0.0))#

Return this shape scaled uniformly about a fixed point.

The scaling is uniform in all three directions; there is no per-axis factor, because a non-uniform scaling would turn cylinders into elliptic cylinders and spheres into ellipsoids, which the primitives cannot represent.

Parameters:
  • factor (float) – Uniform scale factor. Note that this is not a way to mirror a shape: a negative factor inverts the shape through center, negating all three axes at once. Use mirrored() for a reflection.

  • center (tuple of float) – Fixed point of the scaling (default: the coordinate origin).

Returns:

The scaled shape; a Group is scaled member by member about the common center.

Return type:

Shape or Group

section(cutter=None, *, normal=None, position=None, filled=False)#

Intersect this solid or sheet with a cutter or world plane.

Parameters:
  • cutter (Solid or Sheet, optional) – Intersecting geometry; excludes a plane declaration.

  • normal (str or sequence of float, optional) – World plane normal; requires position.

  • position (float, optional) – Signed world plane offset [m].

  • filled (bool, optional) – Return planar Profiles with holes instead of boundary Curves. Requires a Solid receiver and an explicit plane.

Returns:

Independent intersection geometry. No intersection returns an empty tuple. A coincident face raises rather than choosing a one-dimensional interpretation.

Return type:

tuple of Curve or Profile

shelled(thickness, *, opening_face_near=None, openings=None)#

Hollow this Solid inward to a constant wall thickness.

Parameters:
  • thickness (float) – Positive wall thickness in metres. The outer footprint is retained.

  • opening_face_near (tuple or list of tuple, optional) – World points selecting temporary face references to leave open. Tied picks raise. Mutually exclusive with openings.

  • openings (FaceRef or FaceSetRef or sequence, optional) – Owned faces to leave open; must belong to this exact receiver. Omit both selection modes for a sealed internal void.

Returns:

Hollow body with inherited material.

Return type:

Solid

Raises:
  • TypeError – For a non-Solid receiver; grow a sheet with thickened() instead.

  • RuntimeError – If the offset cannot form a valid closed body.

swept(spine, *, face_near=None, material=None, frame='corrected_frenet', binormal=None, twist_deg=0.0, draft_deg=0.0, tolerance=None)#

Sweep a planar Sheet along a Curve into an independent Solid.

The actual boundary is translated to the spine start and aligned by the shortest normal-to-tangent rotation, retaining in-plane roll. An already aligned section stays in its actual orientation. For an opposite normal, the section plane’s X axis defines the half-turn. The pipe follows corrected Frenet transport unless another frame is selected explicitly.

Parameters:
  • spine (Curve) – World sweep path.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).swept(spine). Tied picks raise. Invalid for standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

  • frame ({'corrected_frenet', 'frenet', 'fixed', 'fixed_binormal'}, optional) – Transport of the initially aligned section. The default retains corrected Frenet transport. Frenet follows curvature and torsion; fixed keeps sections parallel in world space. Fixed binormal preserves their angular relation to the supplied world direction.

  • binormal (str or tuple of float, optional) – Required only for fixed binormal transport. Must not be parallel to the spine tangent. Path’s up direction does not set this value.

  • twist_deg (float, optional) – Total additional right-hand roll about the transported section normal [degrees], distributed uniformly over spine arc length.

  • draft_deg (float, optional) – Constant section-offset angle [degrees], strictly between -90 and 90. Offset equals travelled arc length times its tangent. Positive values expand the exterior and shrink holes. For perpendicular straight sections this is the wall angle to the sweep direction.

  • tolerance (float, optional) – Sampled section-fitting tolerance [m] for nonzero twist or draft. Defaults to one millionth of the initial profile diagonal.

Returns:

Independent pipe retaining the section’s holes.

Return type:

Solid

tagged_edge(name, *, near=None, curve_type=None)#

Register an immutable named edge selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_edges(name, *, near=None, curve_type=None)#

Register an immutable named set of edges.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_face(name, *, near=None, normal=None, surface_type=None)#

Register an immutable named face selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_faces(name, *, near=None, normal=None, surface_type=None)#

Register an immutable named set of faces.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_vertex(name, *, near=None)#

Register an immutable named vertex selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

thickened(thickness, *, direction='forward', material=None)#

Grow this sheet into a solid of constant thickness.

A Sheet, including a planar Profile or curved Surface, can be thickened. A planar sheet becomes a slab whose footprint is exactly the sheet, which makes this the direct way from a drawn outline to a metallisation of a given thickness, without spelling out the extrusion vector. A curved sheet is offset along its own normal into a shell of constant thickness. An unsuitable thickness, curvature or sampled surface can prevent the CAD kernel from building a valid offset.

Parameters:
  • thickness (float) – Slab thickness [meters], positive.

  • direction ({"forward", "backward", "symmetric"}) – Which side of the sheet to grow on. "symmetric" puts half the thickness on each side, leaving the sheet as the slab’s mid-plane (planar sheets only). "forward" and "backward" are opposite sides of it; forward follows the oriented sheet normal. For a FaceRef, forward follows its outward normal.

  • material (Material or str, optional) – Material of the slab. Defaults to the sheet’s material. A materialless sheet produces a construction solid for Boolean use.

Returns:

The solid slab.

Return type:

Solid

Raises:
  • TypeError – If this is a solid — use shelled() instead.

  • ValueError – If the thickness or direction is invalid, or symmetric thickening is requested for a curved sheet.

Examples

A copper patch from a drawn outline:

patch = Profile.from_wires(outline).thickened(thickness=35e-6, material=copper)
translated(vector, *, repeat=1, copy=False, unite=False, group=False)#

Return this shape moved by vector.

Parameters:
  • vector (tuple of float) – (dx, dy, dz) translation [meters].

  • repeat (int, optional) – Number of translated copies, starting at one vector displacement. Copy i is moved by i * vector; defaults to 1.

  • copy (bool, optional) – Include the untransformed original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One translated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

A row of eight vias, including the original, fused into one body:

fence = via.translated((2e-3, 0, 0), repeat=7, copy=True, unite=True)
vertex(name=None, *, near=None)#

Select one owned vertex, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

VertexRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

volume(scale=None)#

Return the volume enclosed by this shape.

Computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters: a Boolean difference reports what is left, and a chamfered block reports what the chamfer took away. That makes it the direct way to check a construction — a filling factor, a metal volume, the agreement between two ways of building the same part.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

Volume in cubic meters. A planar sheet (Profile) has no thickness and reports zero.

Return type:

float

Examples

The fraction of a housing that is metal:

fill = shell.volume() / block.volume()
class magnelio.geo.Cone(material=None, name=None, origin=(0.0, 0.0, 0.0), bottom_radius=1.0, top_radius=0.0, height=1.0, axis='z')#

Right circular cone (or truncated cone if top_radius > 0).

Parameters:
  • origin (tuple of float) – (x, y, z) center of the bottom face [meters].

  • bottom_radius (float) – Bottom radius [meters].

  • top_radius (float) – Top radius [meters]. Use 0 for a full cone; the two radii may not both be 0.

  • height (float) – Height [meters]. A negative height extrudes along -axis from the origin.

  • axis (str or tuple of float) – Axis direction: 'x'/'y'/'z' or any 3-vector.

  • material (Material or str, optional) – Material filling this volume. Omit it for a construction solid used only as a Boolean operand.

  • name (str, optional) – Optional label.

bounding_box(scale=None)#

Return the axis-aligned bounding box of this shape.

The box is computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters — a rotated brick reports the box of the rotated solid.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

(min_corner, max_corner), each (x, y, z) in meters.

Return type:

tuple

chamfered(*, near=None, face_near=None, edges=None, faces=None, distance)#

Return a Solid with a flat bevel on selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms use semantic selection and refuse ambiguity.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • distance (float or tuple of float) – Positive bevel distance in metres, or an asymmetric pair.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

edge(name=None, *, near=None, curve_type=None)#

Select one owned edge, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

EdgeRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

edges(name=None, *, near=None, curve_type=None)#

Select a deliberate set of owned edges, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered set selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

Read-only view bound to this Solid. With no constraints, selects all members.

Return type:

EdgeSetRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

extruded(vector, *, face_near=None, material=None)#

Extrude a Sheet into an independent Solid, retaining holes.

Parameters:
  • vector (tuple of float) – Non-zero world extrusion vector in metres.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).extruded(vector). A tied pick raises AmbiguousTopologyError. Invalid on standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Materialless sections produce construction solids for Boolean use.

Returns:

Independent prism, without fusion to an input owner.

Return type:

Solid

face(name=None, *, near=None, normal=None, surface_type=None)#

Select one owned face, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

FaceRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

faces(name=None, *, near=None, normal=None, surface_type=None)#

Select a deliberate set of owned faces, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered set selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

Read-only view bound to this Solid. With no constraints, selects all members.

Return type:

FaceSetRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

filleted(*, near=None, face_near=None, edges=None, faces=None, radius)#

Return a Solid with rounded selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms refuse ties.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • radius (float) – Positive fillet radius in metres.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

imprinted(cutter)#

Split this body’s boundary faces along a cutter’s intersection.

The receiver keeps its volume and material. Only its boundary topology changes; the cutter remains an independent shape.

Parameters:

cutter (Solid or Sheet) – Shape whose intersection curves split the receiver’s faces.

Returns:

An independent body with imprinted boundary faces.

Return type:

Solid

Raises:

TopologyEvolutionError – If a singular named selection splits or loses its identity.

lofted(face_near, other=None, other_face_near=None, *, material=None, blend='spline', tension=None)#

Connect this section to another with an independent Solid.

For sheets, use section.lofted(other_section). Suitable FaceRef values provide the same verb. All boundaries contribute, and hole counts must agree. The retained Solid convenience is body.lofted(face_near, other_body, other_face_near); its temporary FaceRefs use semantic selection and refuse tied picks.

Parameters:
  • face_near (Profile or Sheet or FaceRef or tuple) – Planar end section for a Sheet receiver. For the Solid convenience, a world point in metres selecting its start face.

  • other (Solid, optional) – End owner for the Solid point convenience only.

  • other_face_near (tuple of float, optional) – World point selecting the end face for the Solid convenience.

  • material (Material or str, optional) – Override the start section’s material. Without a material the result is a construction solid.

  • blend ({'spline', 'ruled', 'tangent'}, optional) – Smooth or straight interpolation, or a transition leaving both oriented normals. Tangent mode requires faces looking towards each other and retains holes with the same spine conditions.

  • tension (float or tuple of float, optional) – Positive finite tangent reach fractions, only in tangent mode. Defaults to one third at each end.

Returns:

Independent transition matching corresponding boundaries.

Return type:

Solid

mirrored(normal, position=0.0, *, copy=False, unite=False, group=False)#

Return this shape reflected across a plane.

The plane is the set of points p with p · normal == position, so for an axis letter position is simply the coordinate of the plane on that axis.

A reflection is not a rotation: it leaves the two in-plane directions untouched and reverses only the normal one. That is what makes it the correct operation for a structure symmetric about a plane but not about the axis normal to it — most planar circuits (dividers, couplers, filters) and every layer stack that differs from top to bottom.

Unlike translated() and rotated() there is no repeat: mirroring twice across one plane reproduces the original.

Parameters:
  • normal (str or sequence of float) – Plane normal: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored). normal='x' maps x -> 2 * position - x.

  • position (float) – Signed distance of the plane from the coordinate origin along normal [meters] (default 0).

  • copy (bool, optional) – Include the original first; defaults to False.

  • unite (bool, optional) – Return a Union of original and image. Requires copy and Solid geometry.

  • group (bool, optional) – Return a Group of original and image, retaining member materials. Requires copy; mutually exclusive with unite.

Returns:

The image alone by default, otherwise [original, image] or the explicitly requested Union or Group.

Return type:

Shape or list of Shape or Union or Group

Examples

Complete a half-modelled power divider into one solid:

full = half.mirrored("x", copy=True, unite=True)

Mirror a feed line onto the far side of a board:

far = line.mirrored("z", position=h / 2)
partition(cutter=None, *, normal=None, position=None)#

Split this solid or sheet into independent connected regions.

Parameters:
  • cutter (Solid or Sheet, optional) – Geometry whose boundary partitions this shape.

  • normal (str or sequence of float, optional) – World normal of a cutting plane. Requires position and excludes cutter.

  • position (float, optional) – Signed plane offset [m], measured as normal dot point.

Returns:

Independently owned regions in kernel order. A non-cut returns one independent region. Order is not persistent across CAD edits.

Return type:

tuple of Solid or Sheet

revolved(axis, angle_deg=360.0, *, origin=(0.0, 0.0, 0.0), material=None)#

Revolve a planar Sheet into an independent Solid.

Parameters:
  • axis (str or sequence of float) – Revolution axis letter or non-zero world vector.

  • angle_deg (float, optional) – Non-zero right-handed angle, at most a full turn, in degrees.

  • origin (tuple of float, optional) – World point on the revolution axis, in metres.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

Returns:

Solid of revolution retaining all holes. A section crossing the axis can produce invalid or self-intersecting geometry.

Return type:

Solid

rotated(axis, angle_deg, origin=(0.0, 0.0, 0.0), *, repeat=1, copy=False, unite=False, group=False)#

Return this shape rotated about an axis.

Parameters:
  • axis (str or sequence of float) – Rotation axis: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored).

  • angle_deg (float) – Rotation angle [degrees], right-handed about axis. Copy i is rotated by i * angle_deg.

  • origin (tuple of float) – A point on the rotation axis (default: the coordinate origin).

  • repeat (int, optional) – Number of rotated copies at angle_deg through repeat * angle_deg; defaults to 1.

  • copy (bool, optional) – Include the unrotated original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One rotated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

Four posts at 90° spacing around the z axis:

posts = post.rotated("z", 90.0, repeat=3, copy=True, group=True)
scaled(factor, center=(0.0, 0.0, 0.0))#

Return this shape scaled uniformly about a fixed point.

The scaling is uniform in all three directions; there is no per-axis factor, because a non-uniform scaling would turn cylinders into elliptic cylinders and spheres into ellipsoids, which the primitives cannot represent.

Parameters:
  • factor (float) – Uniform scale factor. Note that this is not a way to mirror a shape: a negative factor inverts the shape through center, negating all three axes at once. Use mirrored() for a reflection.

  • center (tuple of float) – Fixed point of the scaling (default: the coordinate origin).

Returns:

The scaled shape; a Group is scaled member by member about the common center.

Return type:

Shape or Group

section(cutter=None, *, normal=None, position=None, filled=False)#

Intersect this solid or sheet with a cutter or world plane.

Parameters:
  • cutter (Solid or Sheet, optional) – Intersecting geometry; excludes a plane declaration.

  • normal (str or sequence of float, optional) – World plane normal; requires position.

  • position (float, optional) – Signed world plane offset [m].

  • filled (bool, optional) – Return planar Profiles with holes instead of boundary Curves. Requires a Solid receiver and an explicit plane.

Returns:

Independent intersection geometry. No intersection returns an empty tuple. A coincident face raises rather than choosing a one-dimensional interpretation.

Return type:

tuple of Curve or Profile

shelled(thickness, *, opening_face_near=None, openings=None)#

Hollow this Solid inward to a constant wall thickness.

Parameters:
  • thickness (float) – Positive wall thickness in metres. The outer footprint is retained.

  • opening_face_near (tuple or list of tuple, optional) – World points selecting temporary face references to leave open. Tied picks raise. Mutually exclusive with openings.

  • openings (FaceRef or FaceSetRef or sequence, optional) – Owned faces to leave open; must belong to this exact receiver. Omit both selection modes for a sealed internal void.

Returns:

Hollow body with inherited material.

Return type:

Solid

Raises:
  • TypeError – For a non-Solid receiver; grow a sheet with thickened() instead.

  • RuntimeError – If the offset cannot form a valid closed body.

swept(spine, *, face_near=None, material=None, frame='corrected_frenet', binormal=None, twist_deg=0.0, draft_deg=0.0, tolerance=None)#

Sweep a planar Sheet along a Curve into an independent Solid.

The actual boundary is translated to the spine start and aligned by the shortest normal-to-tangent rotation, retaining in-plane roll. An already aligned section stays in its actual orientation. For an opposite normal, the section plane’s X axis defines the half-turn. The pipe follows corrected Frenet transport unless another frame is selected explicitly.

Parameters:
  • spine (Curve) – World sweep path.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).swept(spine). Tied picks raise. Invalid for standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

  • frame ({'corrected_frenet', 'frenet', 'fixed', 'fixed_binormal'}, optional) – Transport of the initially aligned section. The default retains corrected Frenet transport. Frenet follows curvature and torsion; fixed keeps sections parallel in world space. Fixed binormal preserves their angular relation to the supplied world direction.

  • binormal (str or tuple of float, optional) – Required only for fixed binormal transport. Must not be parallel to the spine tangent. Path’s up direction does not set this value.

  • twist_deg (float, optional) – Total additional right-hand roll about the transported section normal [degrees], distributed uniformly over spine arc length.

  • draft_deg (float, optional) – Constant section-offset angle [degrees], strictly between -90 and 90. Offset equals travelled arc length times its tangent. Positive values expand the exterior and shrink holes. For perpendicular straight sections this is the wall angle to the sweep direction.

  • tolerance (float, optional) – Sampled section-fitting tolerance [m] for nonzero twist or draft. Defaults to one millionth of the initial profile diagonal.

Returns:

Independent pipe retaining the section’s holes.

Return type:

Solid

tagged_edge(name, *, near=None, curve_type=None)#

Register an immutable named edge selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_edges(name, *, near=None, curve_type=None)#

Register an immutable named set of edges.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_face(name, *, near=None, normal=None, surface_type=None)#

Register an immutable named face selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_faces(name, *, near=None, normal=None, surface_type=None)#

Register an immutable named set of faces.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_vertex(name, *, near=None)#

Register an immutable named vertex selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

thickened(thickness, *, direction='forward', material=None)#

Grow this sheet into a solid of constant thickness.

A Sheet, including a planar Profile or curved Surface, can be thickened. A planar sheet becomes a slab whose footprint is exactly the sheet, which makes this the direct way from a drawn outline to a metallisation of a given thickness, without spelling out the extrusion vector. A curved sheet is offset along its own normal into a shell of constant thickness. An unsuitable thickness, curvature or sampled surface can prevent the CAD kernel from building a valid offset.

Parameters:
  • thickness (float) – Slab thickness [meters], positive.

  • direction ({"forward", "backward", "symmetric"}) – Which side of the sheet to grow on. "symmetric" puts half the thickness on each side, leaving the sheet as the slab’s mid-plane (planar sheets only). "forward" and "backward" are opposite sides of it; forward follows the oriented sheet normal. For a FaceRef, forward follows its outward normal.

  • material (Material or str, optional) – Material of the slab. Defaults to the sheet’s material. A materialless sheet produces a construction solid for Boolean use.

Returns:

The solid slab.

Return type:

Solid

Raises:
  • TypeError – If this is a solid — use shelled() instead.

  • ValueError – If the thickness or direction is invalid, or symmetric thickening is requested for a curved sheet.

Examples

A copper patch from a drawn outline:

patch = Profile.from_wires(outline).thickened(thickness=35e-6, material=copper)
translated(vector, *, repeat=1, copy=False, unite=False, group=False)#

Return this shape moved by vector.

Parameters:
  • vector (tuple of float) – (dx, dy, dz) translation [meters].

  • repeat (int, optional) – Number of translated copies, starting at one vector displacement. Copy i is moved by i * vector; defaults to 1.

  • copy (bool, optional) – Include the untransformed original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One translated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

A row of eight vias, including the original, fused into one body:

fence = via.translated((2e-3, 0, 0), repeat=7, copy=True, unite=True)
vertex(name=None, *, near=None)#

Select one owned vertex, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

VertexRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

volume(scale=None)#

Return the volume enclosed by this shape.

Computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters: a Boolean difference reports what is left, and a chamfered block reports what the chamfer took away. That makes it the direct way to check a construction — a filling factor, a metal volume, the agreement between two ways of building the same part.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

Volume in cubic meters. A planar sheet (Profile) has no thickness and reports zero.

Return type:

float

Examples

The fraction of a housing that is metal:

fill = shell.volume() / block.volume()
class magnelio.geo.Curve(_build, name=None, _bounds=None, _ends=None, _segments=<factory>)#

An abstract 3D locus backed by an OCC wire (no material).

Do not construct directly — use one of the classmethods (polyline(), arc(), spline(), helix()). Each stores a builder callable that lazily produces the TopoDS_Wire on first use, cached like every other geometry object.

A Curve exposes _occ_shape() (the wire) and bounding_box(), but no material — a 1D locus is never a physical object on its own.

Parameters:
  • _build (object)

  • name (str | None)

  • _bounds (tuple | None)

  • _ends (tuple | None)

  • _segments (tuple)

classmethod arc(start, through, end, *, name=None)#

A circular arc through three 3D points.

Parameters:
  • start (tuple of float) – The arc passes through all three points in order [meters]. The three points must not be collinear.

  • through (tuple of float) – The arc passes through all three points in order [meters]. The three points must not be collinear.

  • end (tuple of float) – The arc passes through all three points in order [meters]. The three points must not be collinear.

  • name (str, optional) – Optional label.

Return type:

Curve

classmethod circle(center, radius, *, normal='z', name=None)#

Return an exact closed circle in an explicitly oriented plane.

Parameters:
  • center (tuple of float) – World center [meters].

  • radius (float) – Positive radius [meters].

  • normal (str or sequence of float, optional) – Non-zero plane normal; defaults to "z".

  • name (str, optional) – Optional label.

Returns:

One closed analytic circular wire.

Return type:

Curve

classmethod ellipse(center, semi_axes, *, major_axis, normal='z', name=None)#

Return an exact closed ellipse with explicit in-plane orientation.

Parameters:
  • center (tuple of float) – World center [meters].

  • semi_axes (tuple of float) – Positive (a, b) lengths [meters]; either may be larger.

  • major_axis (str or sequence of float) – Direction of a, projected into the plane of normal.

  • normal (str or sequence of float, optional) – Plane normal; defaults to "z".

  • name (str, optional) – Optional label.

Returns:

One closed analytic elliptical wire.

Return type:

Curve

classmethod ellipse_arc(start, end, *, center, semi_axes, major_axis, normal, name=None)#

An elliptical arc from start to end, counter-clockwise about normal.

Parameters:
  • start (tuple of float) – Arc endpoints [meters]; both must lie on the ellipse.

  • end (tuple of float) – Arc endpoints [meters]; both must lie on the ellipse.

  • center (tuple of float) – Centre of the ellipse [meters].

  • semi_axes (tuple of float) – (a, b) [meters]: a along major_axis, b along normal x major_axis. Either may be the larger one.

  • major_axis (str or sequence of float) – Direction of the first semi-axis — 'x', 'y', 'z' or any non-zero 3-vector (its component along normal is discarded).

  • normal (str or sequence of float) – Normal of the ellipse’s plane; the arc turns counter-clockwise about it, seen from the tip of the axis.

  • name (str, optional) – Optional label.

Raises:

ValueError – If an endpoint is off the ellipse, if major_axis is parallel to normal, or if a semi-axis is not positive.

Return type:

Curve

classmethod helix(*, radius, pitch, turns, origin=(0.0, 0.0, 0.0), axis='z', right_handed=True, name=None)#

An exact helix on a cylinder.

Parameters:
  • radius (float) – Helix radius [meters].

  • pitch (float) – Axial rise per full turn [meters].

  • turns (float) – Number of turns (may be fractional).

  • origin (tuple of float) – Base point on the axis [meters], as for Cylinder.

  • axis (str) – Axis direction: 'x', 'y', or 'z' (default).

  • right_handed (bool) – If True (default) the helix ascends counter-clockwise about the axis; if False it is left-handed.

  • name (str, optional) – Optional label.

Return type:

Curve

classmethod line(start, end, *, name=None)#

Return an exact straight segment between two distinct world points.

Parameters:
  • start (tuple of float) – Three-dimensional endpoints [meters].

  • end (tuple of float) – Three-dimensional endpoints [meters].

  • name (str, optional) – Optional label.

Returns:

The open line segment.

Return type:

Curve

classmethod polyline(points, *, name=None)#

A polyline (open, straight segments) through 3D points.

Parameters:
  • points (sequence of (float, float, float)) – At least 2 vertices [meters].

  • name (str, optional) – Optional label.

Return type:

Curve

classmethod spline(points, *, name=None)#

A smooth B-spline interpolating 3D points.

Parameters:
  • points (sequence of (float, float, float)) – At least 2 interpolation points [meters].

  • name (str, optional) – Optional label.

Return type:

Curve

bounding_box(scale=None)#

Return (min_corner, max_corner) in meters via OCC BRep bounding box.

Parameters:

scale (float | None)

Return type:

tuple[tuple[float, float, float], tuple[float, float, float]]

chamfered(*, near=None, face_near=None, edges=None, faces=None, distance)#

Return a Solid with a flat bevel on selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms use semantic selection and refuse ambiguity.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • distance (float or tuple of float) – Positive bevel distance in metres, or an asymmetric pair.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

extruded(vector, *, face_near=None, material=None)#

Extrude a Sheet into an independent Solid, retaining holes.

Parameters:
  • vector (tuple of float) – Non-zero world extrusion vector in metres.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).extruded(vector). A tied pick raises AmbiguousTopologyError. Invalid on standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Materialless sections produce construction solids for Boolean use.

Returns:

Independent prism, without fusion to an input owner.

Return type:

Solid

filleted(*, near=None, face_near=None, edges=None, faces=None, radius)#

Return a Solid with rounded selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms refuse ties.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • radius (float) – Positive fillet radius in metres.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

joined(*curves, name=None)#

Return one curve chaining this curve and curves end to start.

Chaining is what turns the individual segment types into arbitrary profiles: an arc, a straight run and another arc become one boundary, and a boundary that closes on itself becomes a sheet through from_wires(). That sheet can then be extruded or revolved into a solid.

Segments must be given in order, each starting where the previous one ended. They need not agree to the last bit — anything within one part per million of the chain’s overall size counts as the same point — but a real gap is an error rather than something to bridge silently.

Parameters:
  • *curves (Curve) – The segments to append, in order.

  • name (str, optional) – Optional label.

Returns:

The chained curve. It is open or closed depending on whether the last segment ends where the first one starts; an open chain is a perfectly good sweep path.

Return type:

Curve

Raises:
  • TypeError – If an argument is not a Curve.

  • ValueError – If consecutive segments do not meet.

Examples

A D-shaped profile — a straight back and a semicircular front:

back = Curve.polyline([(0, -5e-3, 0), (0, 5e-3, 0)])
front = Curve.arc((0, 5e-3, 0), (5e-3, 0, 0), (0, -5e-3, 0))
profile = back.joined(front)
rod = Profile.from_wires(profile).extruded(vector=(0, 0, 20e-3), material=copper)
lofted(face_near, other=None, other_face_near=None, *, material=None, blend='spline', tension=None)#

Connect this section to another with an independent Solid.

For sheets, use section.lofted(other_section). Suitable FaceRef values provide the same verb. All boundaries contribute, and hole counts must agree. The retained Solid convenience is body.lofted(face_near, other_body, other_face_near); its temporary FaceRefs use semantic selection and refuse tied picks.

Parameters:
  • face_near (Profile or Sheet or FaceRef or tuple) – Planar end section for a Sheet receiver. For the Solid convenience, a world point in metres selecting its start face.

  • other (Solid, optional) – End owner for the Solid point convenience only.

  • other_face_near (tuple of float, optional) – World point selecting the end face for the Solid convenience.

  • material (Material or str, optional) – Override the start section’s material. Without a material the result is a construction solid.

  • blend ({'spline', 'ruled', 'tangent'}, optional) – Smooth or straight interpolation, or a transition leaving both oriented normals. Tangent mode requires faces looking towards each other and retains holes with the same spine conditions.

  • tension (float or tuple of float, optional) – Positive finite tangent reach fractions, only in tangent mode. Defaults to one third at each end.

Returns:

Independent transition matching corresponding boundaries.

Return type:

Solid

mirrored(normal, position=0.0, *, copy=False, unite=False, group=False)#

Return this shape reflected across a plane.

The plane is the set of points p with p · normal == position, so for an axis letter position is simply the coordinate of the plane on that axis.

A reflection is not a rotation: it leaves the two in-plane directions untouched and reverses only the normal one. That is what makes it the correct operation for a structure symmetric about a plane but not about the axis normal to it — most planar circuits (dividers, couplers, filters) and every layer stack that differs from top to bottom.

Unlike translated() and rotated() there is no repeat: mirroring twice across one plane reproduces the original.

Parameters:
  • normal (str or sequence of float) – Plane normal: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored). normal='x' maps x -> 2 * position - x.

  • position (float) – Signed distance of the plane from the coordinate origin along normal [meters] (default 0).

  • copy (bool, optional) – Include the original first; defaults to False.

  • unite (bool, optional) – Return a Union of original and image. Requires copy and Solid geometry.

  • group (bool, optional) – Return a Group of original and image, retaining member materials. Requires copy; mutually exclusive with unite.

Returns:

The image alone by default, otherwise [original, image] or the explicitly requested Union or Group.

Return type:

Shape or list of Shape or Union or Group

Examples

Complete a half-modelled power divider into one solid:

full = half.mirrored("x", copy=True, unite=True)

Mirror a feed line onto the far side of a board:

far = line.mirrored("z", position=h / 2)
offset(distance, *, normal)#

Return the planar curves a signed distance from this curve.

Positive distance lies to the left of traversal when viewed along normal; negative distance lies to the right. Corners on the outer side are joined by circular arcs. Open ends remain uncapped. The explicit normal fixes the oriented plane even for a straight line.

Parameters:
  • distance (float) – Signed lateral distance [meters].

  • normal (str or sequence of float) – Oriented normal of the curve plane.

Returns:

Independent offset components; empty if the curve collapses.

Return type:

tuple of Curve

Raises:

ValueError – If the curve is not planar or the offset folds or crosses itself.

partition(cutter=None, *, normal=None, position=None)#

Split this solid or sheet into independent connected regions.

Parameters:
  • cutter (Solid or Sheet, optional) – Geometry whose boundary partitions this shape.

  • normal (str or sequence of float, optional) – World normal of a cutting plane. Requires position and excludes cutter.

  • position (float, optional) – Signed plane offset [m], measured as normal dot point.

Returns:

Independently owned regions in kernel order. A non-cut returns one independent region. Order is not persistent across CAD edits.

Return type:

tuple of Solid or Sheet

projected_onto(target, *, direction=None, perspective_source=None, closest=False, clip=False, all_hits=False, tolerance=None)#

Project this curve onto a bounded sheet or selected face.

Specify exactly one projection policy: a world direction for parallel forward rays, a perspective_source point for rays through this curve, or closest=True for nearest-point projection. The actual boundary and holes of target are respected.

Parameters:
  • target (Sheet or FaceRef) – Bounded target in its world placement.

  • direction (str or sequence of float, optional) – Forward world direction for parallel rays.

  • perspective_source (sequence of float, optional) – World point from which rays pass through this curve.

  • closest (bool, optional) – Use nearest points on the bounded target instead of rays.

  • clip (bool, optional) – For rays, keep only the covered pieces. Without it, partial coverage raises. Not used for closest-point projection.

  • all_hits (bool, optional) – For ray projection, retain every forward branch. Otherwise the first hit along each ray is selected.

  • tolerance (float, optional) – Requested nearest-trace fitting tolerance in metres. Applies only with closest=True. Defaults to one millionth of the source curve’s bounding-box diagonal, subject to CAD kernel precision.

Returns:

Independent projected curve pieces. A wholly missed target raises unless ray clipping is enabled, which returns an empty tuple.

Return type:

tuple of Curve

revolved(axis, angle_deg=360.0, *, origin=(0.0, 0.0, 0.0), material=None)#

Revolve a planar Sheet into an independent Solid.

Parameters:
  • axis (str or sequence of float) – Revolution axis letter or non-zero world vector.

  • angle_deg (float, optional) – Non-zero right-handed angle, at most a full turn, in degrees.

  • origin (tuple of float, optional) – World point on the revolution axis, in metres.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

Returns:

Solid of revolution retaining all holes. A section crossing the axis can produce invalid or self-intersecting geometry.

Return type:

Solid

rotated(axis, angle_deg, origin=(0.0, 0.0, 0.0), *, repeat=1, copy=False, unite=False, group=False)#

Return this shape rotated about an axis.

Parameters:
  • axis (str or sequence of float) – Rotation axis: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored).

  • angle_deg (float) – Rotation angle [degrees], right-handed about axis. Copy i is rotated by i * angle_deg.

  • origin (tuple of float) – A point on the rotation axis (default: the coordinate origin).

  • repeat (int, optional) – Number of rotated copies at angle_deg through repeat * angle_deg; defaults to 1.

  • copy (bool, optional) – Include the unrotated original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One rotated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

Four posts at 90° spacing around the z axis:

posts = post.rotated("z", 90.0, repeat=3, copy=True, group=True)
scaled(factor, center=(0.0, 0.0, 0.0))#

Return this shape scaled uniformly about a fixed point.

The scaling is uniform in all three directions; there is no per-axis factor, because a non-uniform scaling would turn cylinders into elliptic cylinders and spheres into ellipsoids, which the primitives cannot represent.

Parameters:
  • factor (float) – Uniform scale factor. Note that this is not a way to mirror a shape: a negative factor inverts the shape through center, negating all three axes at once. Use mirrored() for a reflection.

  • center (tuple of float) – Fixed point of the scaling (default: the coordinate origin).

Returns:

The scaled shape; a Group is scaled member by member about the common center.

Return type:

Shape or Group

section(cutter=None, *, normal=None, position=None, filled=False)#

Intersect this solid or sheet with a cutter or world plane.

Parameters:
  • cutter (Solid or Sheet, optional) – Intersecting geometry; excludes a plane declaration.

  • normal (str or sequence of float, optional) – World plane normal; requires position.

  • position (float, optional) – Signed world plane offset [m].

  • filled (bool, optional) – Return planar Profiles with holes instead of boundary Curves. Requires a Solid receiver and an explicit plane.

Returns:

Independent intersection geometry. No intersection returns an empty tuple. A coincident face raises rather than choosing a one-dimensional interpretation.

Return type:

tuple of Curve or Profile

shelled(thickness, *, opening_face_near=None, openings=None)#

Hollow this Solid inward to a constant wall thickness.

Parameters:
  • thickness (float) – Positive wall thickness in metres. The outer footprint is retained.

  • opening_face_near (tuple or list of tuple, optional) – World points selecting temporary face references to leave open. Tied picks raise. Mutually exclusive with openings.

  • openings (FaceRef or FaceSetRef or sequence, optional) – Owned faces to leave open; must belong to this exact receiver. Omit both selection modes for a sealed internal void.

Returns:

Hollow body with inherited material.

Return type:

Solid

Raises:
  • TypeError – For a non-Solid receiver; grow a sheet with thickened() instead.

  • RuntimeError – If the offset cannot form a valid closed body.

swept(spine, *, face_near=None, material=None, frame='corrected_frenet', binormal=None, twist_deg=0.0, draft_deg=0.0, tolerance=None)#

Sweep a planar Sheet along a Curve into an independent Solid.

The actual boundary is translated to the spine start and aligned by the shortest normal-to-tangent rotation, retaining in-plane roll. An already aligned section stays in its actual orientation. For an opposite normal, the section plane’s X axis defines the half-turn. The pipe follows corrected Frenet transport unless another frame is selected explicitly.

Parameters:
  • spine (Curve) – World sweep path.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).swept(spine). Tied picks raise. Invalid for standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

  • frame ({'corrected_frenet', 'frenet', 'fixed', 'fixed_binormal'}, optional) – Transport of the initially aligned section. The default retains corrected Frenet transport. Frenet follows curvature and torsion; fixed keeps sections parallel in world space. Fixed binormal preserves their angular relation to the supplied world direction.

  • binormal (str or tuple of float, optional) – Required only for fixed binormal transport. Must not be parallel to the spine tangent. Path’s up direction does not set this value.

  • twist_deg (float, optional) – Total additional right-hand roll about the transported section normal [degrees], distributed uniformly over spine arc length.

  • draft_deg (float, optional) – Constant section-offset angle [degrees], strictly between -90 and 90. Offset equals travelled arc length times its tangent. Positive values expand the exterior and shrink holes. For perpendicular straight sections this is the wall angle to the sweep direction.

  • tolerance (float, optional) – Sampled section-fitting tolerance [m] for nonzero twist or draft. Defaults to one millionth of the initial profile diagonal.

Returns:

Independent pipe retaining the section’s holes.

Return type:

Solid

thickened(thickness, *, direction='forward', material=None)#

Grow this sheet into a solid of constant thickness.

A Sheet, including a planar Profile or curved Surface, can be thickened. A planar sheet becomes a slab whose footprint is exactly the sheet, which makes this the direct way from a drawn outline to a metallisation of a given thickness, without spelling out the extrusion vector. A curved sheet is offset along its own normal into a shell of constant thickness. An unsuitable thickness, curvature or sampled surface can prevent the CAD kernel from building a valid offset.

Parameters:
  • thickness (float) – Slab thickness [meters], positive.

  • direction ({"forward", "backward", "symmetric"}) – Which side of the sheet to grow on. "symmetric" puts half the thickness on each side, leaving the sheet as the slab’s mid-plane (planar sheets only). "forward" and "backward" are opposite sides of it; forward follows the oriented sheet normal. For a FaceRef, forward follows its outward normal.

  • material (Material or str, optional) – Material of the slab. Defaults to the sheet’s material. A materialless sheet produces a construction solid for Boolean use.

Returns:

The solid slab.

Return type:

Solid

Raises:
  • TypeError – If this is a solid — use shelled() instead.

  • ValueError – If the thickness or direction is invalid, or symmetric thickening is requested for a curved sheet.

Examples

A copper patch from a drawn outline:

patch = Profile.from_wires(outline).thickened(thickness=35e-6, material=copper)
traced(*, width, thickness, caps='round', normal=None, material=None, name=None)#

Return the conductor track running along this curve.

The curve is the track’s centreline: it is widened by half the width to each side within its own plane, then given a metallisation thickness perpendicular to it. That is the direct route from a routed path to the copper on a board, without assembling the track from separate straight and bent pieces.

Corners of a polyline centreline come out rounded on the outside — a consequence of offsetting a path, and closer to a fabricated track than a mitred corner would be.

Parameters:
  • width (float) – Track width [meters].

  • thickness (float) – Metallisation thickness [meters]. Negative grows the track on the other side of the centreline’s plane.

  • caps ({"round", "flat"}) – How an open track ends: "round" (default) closes it with a half-disc, "flat" cuts it off square, which is what a track meeting a port plane needs. Ignored for a closed curve, which has no ends.

  • normal (str or sequence of float, optional) – Normal of the plane the track lies in. Only needed when the curve does not determine one — a straight centreline lies in infinitely many planes.

  • material (Material, optional) – Material of the track. None (default) makes it a construction body.

  • name (str, optional) – Optional label.

Returns:

The track solid.

Return type:

Shape

Raises:

ValueError – If the curve is not planar, if the plane is undetermined and no normal was given, or if the width is too large for the path’s bends and clearances.

Examples

A 35 um copper feed line ending square at both ports:

line = route.traced(
    width=0.6e-3, thickness=35e-6, caps="flat",
    normal="z", material=copper,
)
translated(vector, *, repeat=1, copy=False, unite=False, group=False)#

Return this shape moved by vector.

Parameters:
  • vector (tuple of float) – (dx, dy, dz) translation [meters].

  • repeat (int, optional) – Number of translated copies, starting at one vector displacement. Copy i is moved by i * vector; defaults to 1.

  • copy (bool, optional) – Include the untransformed original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One translated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

A row of eight vias, including the original, fused into one body:

fence = via.translated((2e-3, 0, 0), repeat=7, copy=True, unite=True)
volume(scale=None)#

Return the volume enclosed by this shape.

Computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters: a Boolean difference reports what is left, and a chamfered block reports what the chamfer took away. That makes it the direct way to check a construction — a filling factor, a metal volume, the agreement between two ways of building the same part.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

Volume in cubic meters. A planar sheet (Profile) has no thickness and reports zero.

Return type:

float

Examples

The fraction of a housing that is metal:

fill = shell.volume() / block.volume()
property is_closed: bool#

Whether this curve’s end meets its start, forming a loop.

A closed curve is the input from_wires() needs. Curves whose endpoints are not known analytically — a helix — report False; for those the check happens in the CAD kernel instead.

property length: float#

Exact CAD wire length [meters].

class magnelio.geo.Cylinder(material=None, name=None, origin=(0.0, 0.0, 0.0), radius=1.0, height=1.0, axis='z', inner_radius=0.0, angle_deg=None)#

Right circular cylinder, optionally hollow and optionally a segment.

Left alone, inner_radius and angle_deg give a plain solid cylinder. Setting inner_radius bores it out into a tube, setting angle_deg cuts a wedge out of the full turn, and setting both gives the curved slab that a segmented electrode or a septum of a circular structure is made of.

Angles are measured about axis in the same right-handed sense as rotated(). Zero lies on the first coordinate direction perpendicular to axis — +x for an 'z' axis, +y for an 'x' axis.

Parameters:
  • origin (tuple of float) – (x, y, z) center of the bottom face [meters].

  • radius (float) – Outer radius [meters].

  • height (float) – Height [meters]. A negative height extrudes along -axis from the origin.

  • axis (str or tuple of float) – Axis direction: 'x'/'y'/'z' or any 3-vector (default 'z').

  • inner_radius (float) – Radius of the axial bore [meters]; 0 (default) for a solid cylinder, otherwise less than radius.

  • angle_deg (float or tuple of float, optional) – Angular extent [degrees]: a single value for a segment starting at zero, or (start, end) for one anywhere. None (default) is the full turn.

  • material (Material or str, optional) – Material filling this volume. Omit it for a construction solid used only as a Boolean operand.

  • name (str, optional) – Optional label.

Examples

A 20 degree segment of a hollow cylinder — a curved electrode:

electrode = Cylinder(
    radius=12e-3, inner_radius=10e-3, height=30e-3,
    angle_deg=(0, 20), material=pec,
)
bounding_box(scale=None)#

Return the axis-aligned bounding box of this shape.

The box is computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters — a rotated brick reports the box of the rotated solid.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

(min_corner, max_corner), each (x, y, z) in meters.

Return type:

tuple

chamfered(*, near=None, face_near=None, edges=None, faces=None, distance)#

Return a Solid with a flat bevel on selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms use semantic selection and refuse ambiguity.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • distance (float or tuple of float) – Positive bevel distance in metres, or an asymmetric pair.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

edge(name=None, *, near=None, curve_type=None)#

Select one owned edge, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

EdgeRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

edges(name=None, *, near=None, curve_type=None)#

Select a deliberate set of owned edges, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered set selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

Read-only view bound to this Solid. With no constraints, selects all members.

Return type:

EdgeSetRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

extruded(vector, *, face_near=None, material=None)#

Extrude a Sheet into an independent Solid, retaining holes.

Parameters:
  • vector (tuple of float) – Non-zero world extrusion vector in metres.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).extruded(vector). A tied pick raises AmbiguousTopologyError. Invalid on standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Materialless sections produce construction solids for Boolean use.

Returns:

Independent prism, without fusion to an input owner.

Return type:

Solid

face(name=None, *, near=None, normal=None, surface_type=None)#

Select one owned face, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

FaceRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

faces(name=None, *, near=None, normal=None, surface_type=None)#

Select a deliberate set of owned faces, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered set selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

Read-only view bound to this Solid. With no constraints, selects all members.

Return type:

FaceSetRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

filleted(*, near=None, face_near=None, edges=None, faces=None, radius)#

Return a Solid with rounded selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms refuse ties.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • radius (float) – Positive fillet radius in metres.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

imprinted(cutter)#

Split this body’s boundary faces along a cutter’s intersection.

The receiver keeps its volume and material. Only its boundary topology changes; the cutter remains an independent shape.

Parameters:

cutter (Solid or Sheet) – Shape whose intersection curves split the receiver’s faces.

Returns:

An independent body with imprinted boundary faces.

Return type:

Solid

Raises:

TopologyEvolutionError – If a singular named selection splits or loses its identity.

lofted(face_near, other=None, other_face_near=None, *, material=None, blend='spline', tension=None)#

Connect this section to another with an independent Solid.

For sheets, use section.lofted(other_section). Suitable FaceRef values provide the same verb. All boundaries contribute, and hole counts must agree. The retained Solid convenience is body.lofted(face_near, other_body, other_face_near); its temporary FaceRefs use semantic selection and refuse tied picks.

Parameters:
  • face_near (Profile or Sheet or FaceRef or tuple) – Planar end section for a Sheet receiver. For the Solid convenience, a world point in metres selecting its start face.

  • other (Solid, optional) – End owner for the Solid point convenience only.

  • other_face_near (tuple of float, optional) – World point selecting the end face for the Solid convenience.

  • material (Material or str, optional) – Override the start section’s material. Without a material the result is a construction solid.

  • blend ({'spline', 'ruled', 'tangent'}, optional) – Smooth or straight interpolation, or a transition leaving both oriented normals. Tangent mode requires faces looking towards each other and retains holes with the same spine conditions.

  • tension (float or tuple of float, optional) – Positive finite tangent reach fractions, only in tangent mode. Defaults to one third at each end.

Returns:

Independent transition matching corresponding boundaries.

Return type:

Solid

mirrored(normal, position=0.0, *, copy=False, unite=False, group=False)#

Return this shape reflected across a plane.

The plane is the set of points p with p · normal == position, so for an axis letter position is simply the coordinate of the plane on that axis.

A reflection is not a rotation: it leaves the two in-plane directions untouched and reverses only the normal one. That is what makes it the correct operation for a structure symmetric about a plane but not about the axis normal to it — most planar circuits (dividers, couplers, filters) and every layer stack that differs from top to bottom.

Unlike translated() and rotated() there is no repeat: mirroring twice across one plane reproduces the original.

Parameters:
  • normal (str or sequence of float) – Plane normal: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored). normal='x' maps x -> 2 * position - x.

  • position (float) – Signed distance of the plane from the coordinate origin along normal [meters] (default 0).

  • copy (bool, optional) – Include the original first; defaults to False.

  • unite (bool, optional) – Return a Union of original and image. Requires copy and Solid geometry.

  • group (bool, optional) – Return a Group of original and image, retaining member materials. Requires copy; mutually exclusive with unite.

Returns:

The image alone by default, otherwise [original, image] or the explicitly requested Union or Group.

Return type:

Shape or list of Shape or Union or Group

Examples

Complete a half-modelled power divider into one solid:

full = half.mirrored("x", copy=True, unite=True)

Mirror a feed line onto the far side of a board:

far = line.mirrored("z", position=h / 2)
partition(cutter=None, *, normal=None, position=None)#

Split this solid or sheet into independent connected regions.

Parameters:
  • cutter (Solid or Sheet, optional) – Geometry whose boundary partitions this shape.

  • normal (str or sequence of float, optional) – World normal of a cutting plane. Requires position and excludes cutter.

  • position (float, optional) – Signed plane offset [m], measured as normal dot point.

Returns:

Independently owned regions in kernel order. A non-cut returns one independent region. Order is not persistent across CAD edits.

Return type:

tuple of Solid or Sheet

revolved(axis, angle_deg=360.0, *, origin=(0.0, 0.0, 0.0), material=None)#

Revolve a planar Sheet into an independent Solid.

Parameters:
  • axis (str or sequence of float) – Revolution axis letter or non-zero world vector.

  • angle_deg (float, optional) – Non-zero right-handed angle, at most a full turn, in degrees.

  • origin (tuple of float, optional) – World point on the revolution axis, in metres.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

Returns:

Solid of revolution retaining all holes. A section crossing the axis can produce invalid or self-intersecting geometry.

Return type:

Solid

rotated(axis, angle_deg, origin=(0.0, 0.0, 0.0), *, repeat=1, copy=False, unite=False, group=False)#

Return this shape rotated about an axis.

Parameters:
  • axis (str or sequence of float) – Rotation axis: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored).

  • angle_deg (float) – Rotation angle [degrees], right-handed about axis. Copy i is rotated by i * angle_deg.

  • origin (tuple of float) – A point on the rotation axis (default: the coordinate origin).

  • repeat (int, optional) – Number of rotated copies at angle_deg through repeat * angle_deg; defaults to 1.

  • copy (bool, optional) – Include the unrotated original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One rotated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

Four posts at 90° spacing around the z axis:

posts = post.rotated("z", 90.0, repeat=3, copy=True, group=True)
scaled(factor, center=(0.0, 0.0, 0.0))#

Return this shape scaled uniformly about a fixed point.

The scaling is uniform in all three directions; there is no per-axis factor, because a non-uniform scaling would turn cylinders into elliptic cylinders and spheres into ellipsoids, which the primitives cannot represent.

Parameters:
  • factor (float) – Uniform scale factor. Note that this is not a way to mirror a shape: a negative factor inverts the shape through center, negating all three axes at once. Use mirrored() for a reflection.

  • center (tuple of float) – Fixed point of the scaling (default: the coordinate origin).

Returns:

The scaled shape; a Group is scaled member by member about the common center.

Return type:

Shape or Group

section(cutter=None, *, normal=None, position=None, filled=False)#

Intersect this solid or sheet with a cutter or world plane.

Parameters:
  • cutter (Solid or Sheet, optional) – Intersecting geometry; excludes a plane declaration.

  • normal (str or sequence of float, optional) – World plane normal; requires position.

  • position (float, optional) – Signed world plane offset [m].

  • filled (bool, optional) – Return planar Profiles with holes instead of boundary Curves. Requires a Solid receiver and an explicit plane.

Returns:

Independent intersection geometry. No intersection returns an empty tuple. A coincident face raises rather than choosing a one-dimensional interpretation.

Return type:

tuple of Curve or Profile

shelled(thickness, *, opening_face_near=None, openings=None)#

Hollow this Solid inward to a constant wall thickness.

Parameters:
  • thickness (float) – Positive wall thickness in metres. The outer footprint is retained.

  • opening_face_near (tuple or list of tuple, optional) – World points selecting temporary face references to leave open. Tied picks raise. Mutually exclusive with openings.

  • openings (FaceRef or FaceSetRef or sequence, optional) – Owned faces to leave open; must belong to this exact receiver. Omit both selection modes for a sealed internal void.

Returns:

Hollow body with inherited material.

Return type:

Solid

Raises:
  • TypeError – For a non-Solid receiver; grow a sheet with thickened() instead.

  • RuntimeError – If the offset cannot form a valid closed body.

swept(spine, *, face_near=None, material=None, frame='corrected_frenet', binormal=None, twist_deg=0.0, draft_deg=0.0, tolerance=None)#

Sweep a planar Sheet along a Curve into an independent Solid.

The actual boundary is translated to the spine start and aligned by the shortest normal-to-tangent rotation, retaining in-plane roll. An already aligned section stays in its actual orientation. For an opposite normal, the section plane’s X axis defines the half-turn. The pipe follows corrected Frenet transport unless another frame is selected explicitly.

Parameters:
  • spine (Curve) – World sweep path.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).swept(spine). Tied picks raise. Invalid for standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

  • frame ({'corrected_frenet', 'frenet', 'fixed', 'fixed_binormal'}, optional) – Transport of the initially aligned section. The default retains corrected Frenet transport. Frenet follows curvature and torsion; fixed keeps sections parallel in world space. Fixed binormal preserves their angular relation to the supplied world direction.

  • binormal (str or tuple of float, optional) – Required only for fixed binormal transport. Must not be parallel to the spine tangent. Path’s up direction does not set this value.

  • twist_deg (float, optional) – Total additional right-hand roll about the transported section normal [degrees], distributed uniformly over spine arc length.

  • draft_deg (float, optional) – Constant section-offset angle [degrees], strictly between -90 and 90. Offset equals travelled arc length times its tangent. Positive values expand the exterior and shrink holes. For perpendicular straight sections this is the wall angle to the sweep direction.

  • tolerance (float, optional) – Sampled section-fitting tolerance [m] for nonzero twist or draft. Defaults to one millionth of the initial profile diagonal.

Returns:

Independent pipe retaining the section’s holes.

Return type:

Solid

tagged_edge(name, *, near=None, curve_type=None)#

Register an immutable named edge selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_edges(name, *, near=None, curve_type=None)#

Register an immutable named set of edges.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_face(name, *, near=None, normal=None, surface_type=None)#

Register an immutable named face selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_faces(name, *, near=None, normal=None, surface_type=None)#

Register an immutable named set of faces.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_vertex(name, *, near=None)#

Register an immutable named vertex selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

thickened(thickness, *, direction='forward', material=None)#

Grow this sheet into a solid of constant thickness.

A Sheet, including a planar Profile or curved Surface, can be thickened. A planar sheet becomes a slab whose footprint is exactly the sheet, which makes this the direct way from a drawn outline to a metallisation of a given thickness, without spelling out the extrusion vector. A curved sheet is offset along its own normal into a shell of constant thickness. An unsuitable thickness, curvature or sampled surface can prevent the CAD kernel from building a valid offset.

Parameters:
  • thickness (float) – Slab thickness [meters], positive.

  • direction ({"forward", "backward", "symmetric"}) – Which side of the sheet to grow on. "symmetric" puts half the thickness on each side, leaving the sheet as the slab’s mid-plane (planar sheets only). "forward" and "backward" are opposite sides of it; forward follows the oriented sheet normal. For a FaceRef, forward follows its outward normal.

  • material (Material or str, optional) – Material of the slab. Defaults to the sheet’s material. A materialless sheet produces a construction solid for Boolean use.

Returns:

The solid slab.

Return type:

Solid

Raises:
  • TypeError – If this is a solid — use shelled() instead.

  • ValueError – If the thickness or direction is invalid, or symmetric thickening is requested for a curved sheet.

Examples

A copper patch from a drawn outline:

patch = Profile.from_wires(outline).thickened(thickness=35e-6, material=copper)
translated(vector, *, repeat=1, copy=False, unite=False, group=False)#

Return this shape moved by vector.

Parameters:
  • vector (tuple of float) – (dx, dy, dz) translation [meters].

  • repeat (int, optional) – Number of translated copies, starting at one vector displacement. Copy i is moved by i * vector; defaults to 1.

  • copy (bool, optional) – Include the untransformed original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One translated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

A row of eight vias, including the original, fused into one body:

fence = via.translated((2e-3, 0, 0), repeat=7, copy=True, unite=True)
vertex(name=None, *, near=None)#

Select one owned vertex, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

VertexRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

volume(scale=None)#

Return the volume enclosed by this shape.

Computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters: a Boolean difference reports what is left, and a chamfered block reports what the chamfer took away. That makes it the direct way to check a construction — a filling factor, a metal volume, the agreement between two ways of building the same part.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

Volume in cubic meters. A planar sheet (Profile) has no thickness and reports zero.

Return type:

float

Examples

The fraction of a housing that is metal:

fill = shell.volume() / block.volume()
class magnelio.geo.Difference(base, *tools, material=None, name=None)#

Boolean difference: base minus one or more tools.

Parameters:
  • base (shape) – Shape to subtract from.

  • *tools (shape) – One or more shapes to subtract. When multiple tools are given they are fused first and then cut from the base in a single Boolean operation.

  • material (Material or None) – Material for the resulting volume. Defaults to base’s material.

  • name (str or None) – Optional label.

bounding_box(scale=None)#

Return the axis-aligned bounding box of this shape.

The box is computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters — a rotated brick reports the box of the rotated solid.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

(min_corner, max_corner), each (x, y, z) in meters.

Return type:

tuple

chamfered(*, near=None, face_near=None, edges=None, faces=None, distance)#

Return a Solid with a flat bevel on selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms use semantic selection and refuse ambiguity.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • distance (float or tuple of float) – Positive bevel distance in metres, or an asymmetric pair.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

edge(name=None, *, near=None, curve_type=None)#

Select one owned edge, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

EdgeRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

edges(name=None, *, near=None, curve_type=None)#

Select a deliberate set of owned edges, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered set selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

Read-only view bound to this Solid. With no constraints, selects all members.

Return type:

EdgeSetRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

extruded(vector, *, face_near=None, material=None)#

Extrude a Sheet into an independent Solid, retaining holes.

Parameters:
  • vector (tuple of float) – Non-zero world extrusion vector in metres.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).extruded(vector). A tied pick raises AmbiguousTopologyError. Invalid on standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Materialless sections produce construction solids for Boolean use.

Returns:

Independent prism, without fusion to an input owner.

Return type:

Solid

face(name=None, *, near=None, normal=None, surface_type=None)#

Select one owned face, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

FaceRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

faces(name=None, *, near=None, normal=None, surface_type=None)#

Select a deliberate set of owned faces, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered set selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

Read-only view bound to this Solid. With no constraints, selects all members.

Return type:

FaceSetRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

filleted(*, near=None, face_near=None, edges=None, faces=None, radius)#

Return a Solid with rounded selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms refuse ties.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • radius (float) – Positive fillet radius in metres.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

imprinted(cutter)#

Split this body’s boundary faces along a cutter’s intersection.

The receiver keeps its volume and material. Only its boundary topology changes; the cutter remains an independent shape.

Parameters:

cutter (Solid or Sheet) – Shape whose intersection curves split the receiver’s faces.

Returns:

An independent body with imprinted boundary faces.

Return type:

Solid

Raises:

TopologyEvolutionError – If a singular named selection splits or loses its identity.

lofted(face_near, other=None, other_face_near=None, *, material=None, blend='spline', tension=None)#

Connect this section to another with an independent Solid.

For sheets, use section.lofted(other_section). Suitable FaceRef values provide the same verb. All boundaries contribute, and hole counts must agree. The retained Solid convenience is body.lofted(face_near, other_body, other_face_near); its temporary FaceRefs use semantic selection and refuse tied picks.

Parameters:
  • face_near (Profile or Sheet or FaceRef or tuple) – Planar end section for a Sheet receiver. For the Solid convenience, a world point in metres selecting its start face.

  • other (Solid, optional) – End owner for the Solid point convenience only.

  • other_face_near (tuple of float, optional) – World point selecting the end face for the Solid convenience.

  • material (Material or str, optional) – Override the start section’s material. Without a material the result is a construction solid.

  • blend ({'spline', 'ruled', 'tangent'}, optional) – Smooth or straight interpolation, or a transition leaving both oriented normals. Tangent mode requires faces looking towards each other and retains holes with the same spine conditions.

  • tension (float or tuple of float, optional) – Positive finite tangent reach fractions, only in tangent mode. Defaults to one third at each end.

Returns:

Independent transition matching corresponding boundaries.

Return type:

Solid

mirrored(normal, position=0.0, *, copy=False, unite=False, group=False)#

Return this shape reflected across a plane.

The plane is the set of points p with p · normal == position, so for an axis letter position is simply the coordinate of the plane on that axis.

A reflection is not a rotation: it leaves the two in-plane directions untouched and reverses only the normal one. That is what makes it the correct operation for a structure symmetric about a plane but not about the axis normal to it — most planar circuits (dividers, couplers, filters) and every layer stack that differs from top to bottom.

Unlike translated() and rotated() there is no repeat: mirroring twice across one plane reproduces the original.

Parameters:
  • normal (str or sequence of float) – Plane normal: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored). normal='x' maps x -> 2 * position - x.

  • position (float) – Signed distance of the plane from the coordinate origin along normal [meters] (default 0).

  • copy (bool, optional) – Include the original first; defaults to False.

  • unite (bool, optional) – Return a Union of original and image. Requires copy and Solid geometry.

  • group (bool, optional) – Return a Group of original and image, retaining member materials. Requires copy; mutually exclusive with unite.

Returns:

The image alone by default, otherwise [original, image] or the explicitly requested Union or Group.

Return type:

Shape or list of Shape or Union or Group

Examples

Complete a half-modelled power divider into one solid:

full = half.mirrored("x", copy=True, unite=True)

Mirror a feed line onto the far side of a board:

far = line.mirrored("z", position=h / 2)
partition(cutter=None, *, normal=None, position=None)#

Split this solid or sheet into independent connected regions.

Parameters:
  • cutter (Solid or Sheet, optional) – Geometry whose boundary partitions this shape.

  • normal (str or sequence of float, optional) – World normal of a cutting plane. Requires position and excludes cutter.

  • position (float, optional) – Signed plane offset [m], measured as normal dot point.

Returns:

Independently owned regions in kernel order. A non-cut returns one independent region. Order is not persistent across CAD edits.

Return type:

tuple of Solid or Sheet

revolved(axis, angle_deg=360.0, *, origin=(0.0, 0.0, 0.0), material=None)#

Revolve a planar Sheet into an independent Solid.

Parameters:
  • axis (str or sequence of float) – Revolution axis letter or non-zero world vector.

  • angle_deg (float, optional) – Non-zero right-handed angle, at most a full turn, in degrees.

  • origin (tuple of float, optional) – World point on the revolution axis, in metres.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

Returns:

Solid of revolution retaining all holes. A section crossing the axis can produce invalid or self-intersecting geometry.

Return type:

Solid

rotated(axis, angle_deg, origin=(0.0, 0.0, 0.0), *, repeat=1, copy=False, unite=False, group=False)#

Return this shape rotated about an axis.

Parameters:
  • axis (str or sequence of float) – Rotation axis: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored).

  • angle_deg (float) – Rotation angle [degrees], right-handed about axis. Copy i is rotated by i * angle_deg.

  • origin (tuple of float) – A point on the rotation axis (default: the coordinate origin).

  • repeat (int, optional) – Number of rotated copies at angle_deg through repeat * angle_deg; defaults to 1.

  • copy (bool, optional) – Include the unrotated original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One rotated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

Four posts at 90° spacing around the z axis:

posts = post.rotated("z", 90.0, repeat=3, copy=True, group=True)
scaled(factor, center=(0.0, 0.0, 0.0))#

Return this shape scaled uniformly about a fixed point.

The scaling is uniform in all three directions; there is no per-axis factor, because a non-uniform scaling would turn cylinders into elliptic cylinders and spheres into ellipsoids, which the primitives cannot represent.

Parameters:
  • factor (float) – Uniform scale factor. Note that this is not a way to mirror a shape: a negative factor inverts the shape through center, negating all three axes at once. Use mirrored() for a reflection.

  • center (tuple of float) – Fixed point of the scaling (default: the coordinate origin).

Returns:

The scaled shape; a Group is scaled member by member about the common center.

Return type:

Shape or Group

section(cutter=None, *, normal=None, position=None, filled=False)#

Intersect this solid or sheet with a cutter or world plane.

Parameters:
  • cutter (Solid or Sheet, optional) – Intersecting geometry; excludes a plane declaration.

  • normal (str or sequence of float, optional) – World plane normal; requires position.

  • position (float, optional) – Signed world plane offset [m].

  • filled (bool, optional) – Return planar Profiles with holes instead of boundary Curves. Requires a Solid receiver and an explicit plane.

Returns:

Independent intersection geometry. No intersection returns an empty tuple. A coincident face raises rather than choosing a one-dimensional interpretation.

Return type:

tuple of Curve or Profile

shelled(thickness, *, opening_face_near=None, openings=None)#

Hollow this Solid inward to a constant wall thickness.

Parameters:
  • thickness (float) – Positive wall thickness in metres. The outer footprint is retained.

  • opening_face_near (tuple or list of tuple, optional) – World points selecting temporary face references to leave open. Tied picks raise. Mutually exclusive with openings.

  • openings (FaceRef or FaceSetRef or sequence, optional) – Owned faces to leave open; must belong to this exact receiver. Omit both selection modes for a sealed internal void.

Returns:

Hollow body with inherited material.

Return type:

Solid

Raises:
  • TypeError – For a non-Solid receiver; grow a sheet with thickened() instead.

  • RuntimeError – If the offset cannot form a valid closed body.

swept(spine, *, face_near=None, material=None, frame='corrected_frenet', binormal=None, twist_deg=0.0, draft_deg=0.0, tolerance=None)#

Sweep a planar Sheet along a Curve into an independent Solid.

The actual boundary is translated to the spine start and aligned by the shortest normal-to-tangent rotation, retaining in-plane roll. An already aligned section stays in its actual orientation. For an opposite normal, the section plane’s X axis defines the half-turn. The pipe follows corrected Frenet transport unless another frame is selected explicitly.

Parameters:
  • spine (Curve) – World sweep path.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).swept(spine). Tied picks raise. Invalid for standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

  • frame ({'corrected_frenet', 'frenet', 'fixed', 'fixed_binormal'}, optional) – Transport of the initially aligned section. The default retains corrected Frenet transport. Frenet follows curvature and torsion; fixed keeps sections parallel in world space. Fixed binormal preserves their angular relation to the supplied world direction.

  • binormal (str or tuple of float, optional) – Required only for fixed binormal transport. Must not be parallel to the spine tangent. Path’s up direction does not set this value.

  • twist_deg (float, optional) – Total additional right-hand roll about the transported section normal [degrees], distributed uniformly over spine arc length.

  • draft_deg (float, optional) – Constant section-offset angle [degrees], strictly between -90 and 90. Offset equals travelled arc length times its tangent. Positive values expand the exterior and shrink holes. For perpendicular straight sections this is the wall angle to the sweep direction.

  • tolerance (float, optional) – Sampled section-fitting tolerance [m] for nonzero twist or draft. Defaults to one millionth of the initial profile diagonal.

Returns:

Independent pipe retaining the section’s holes.

Return type:

Solid

tagged_edge(name, *, near=None, curve_type=None)#

Register an immutable named edge selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_edges(name, *, near=None, curve_type=None)#

Register an immutable named set of edges.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_face(name, *, near=None, normal=None, surface_type=None)#

Register an immutable named face selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_faces(name, *, near=None, normal=None, surface_type=None)#

Register an immutable named set of faces.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_vertex(name, *, near=None)#

Register an immutable named vertex selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

thickened(thickness, *, direction='forward', material=None)#

Grow this sheet into a solid of constant thickness.

A Sheet, including a planar Profile or curved Surface, can be thickened. A planar sheet becomes a slab whose footprint is exactly the sheet, which makes this the direct way from a drawn outline to a metallisation of a given thickness, without spelling out the extrusion vector. A curved sheet is offset along its own normal into a shell of constant thickness. An unsuitable thickness, curvature or sampled surface can prevent the CAD kernel from building a valid offset.

Parameters:
  • thickness (float) – Slab thickness [meters], positive.

  • direction ({"forward", "backward", "symmetric"}) – Which side of the sheet to grow on. "symmetric" puts half the thickness on each side, leaving the sheet as the slab’s mid-plane (planar sheets only). "forward" and "backward" are opposite sides of it; forward follows the oriented sheet normal. For a FaceRef, forward follows its outward normal.

  • material (Material or str, optional) – Material of the slab. Defaults to the sheet’s material. A materialless sheet produces a construction solid for Boolean use.

Returns:

The solid slab.

Return type:

Solid

Raises:
  • TypeError – If this is a solid — use shelled() instead.

  • ValueError – If the thickness or direction is invalid, or symmetric thickening is requested for a curved sheet.

Examples

A copper patch from a drawn outline:

patch = Profile.from_wires(outline).thickened(thickness=35e-6, material=copper)
translated(vector, *, repeat=1, copy=False, unite=False, group=False)#

Return this shape moved by vector.

Parameters:
  • vector (tuple of float) – (dx, dy, dz) translation [meters].

  • repeat (int, optional) – Number of translated copies, starting at one vector displacement. Copy i is moved by i * vector; defaults to 1.

  • copy (bool, optional) – Include the untransformed original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One translated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

A row of eight vias, including the original, fused into one body:

fence = via.translated((2e-3, 0, 0), repeat=7, copy=True, unite=True)
vertex(name=None, *, near=None)#

Select one owned vertex, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

VertexRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

volume(scale=None)#

Return the volume enclosed by this shape.

Computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters: a Boolean difference reports what is left, and a chamfered block reports what the chamfer took away. That makes it the direct way to check a construction — a filling factor, a metal volume, the agreement between two ways of building the same part.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

Volume in cubic meters. A planar sheet (Profile) has no thickness and reports zero.

Return type:

float

Examples

The fraction of a housing that is metal:

fill = shell.volume() / block.volume()
class magnelio.geo.EdgeRef(owner, _shape, _scale, _origin=None)#

Owned edge; detach explicitly with as_curve().

Parameters:
  • owner (object)

  • _shape (object)

  • _scale (float)

  • _origin (object)

as_curve()#

Return an independent Curve with the edge’s exact world geometry.

Returns:

Standalone curve with no owner or registered selections.

Return type:

Curve

bounding_box()#

Return world-coordinate minimum and maximum corners in metres.

property end#

End point following the edge orientation.

Type:

tuple of float

property length#

Exact edge length in metres.

Type:

float

property start#

Start point following the edge orientation.

Type:

tuple of float

property vertices#

Unique vertices connected to this edge.

Type:

tuple of VertexRef

class magnelio.geo.EdgeSetRef(owner, _shape, _scale, _origin=None)#

Deliberate, iterable collection of edges sharing one Solid owner.

Parameters:
  • owner (object)

  • _shape (object)

  • _scale (float)

  • _origin (object)

bounding_box()#

Return a world bounding box enclosing every member, in metres.

class magnelio.geo.FaceRef(owner, _shape, _scale, _origin=None)#

Owned face; detach explicitly with detached().

Parameters:
  • owner (object)

  • _shape (object)

  • _scale (float)

  • _origin (object)

bounding_box()#

Return world-coordinate minimum and maximum corners in metres.

detached()#

Return an independent sheet retaining placement, holes and material.

Returns:

Profile for planar faces, Surface for curved faces. Registered topology names remain on the owner and are not detached.

Return type:

Profile or Surface

extruded(vector, *, material=None)#

Return a standalone Solid extruded from this face, retaining holes.

Parameters:
  • vector (tuple of float) – World extrusion vector in metres, non-zero.

  • material (Material or str, optional) – Override the owner’s material; otherwise it is inherited.

Returns:

Independent continuation. Owner registrations remain on the owner.

Return type:

Solid

lofted(other, *, material=None, blend='spline', tension=None)#

Return a Solid connecting this planar face to another section.

Parameters:
  • other (Profile or Sheet or FaceRef) – Planar end section. Hole counts must agree; boundary order fixes correspondence. Tangent blending uses the oriented face normals.

  • material (Material or str, optional) – Override the start owner’s material.

  • blend ({'spline', 'ruled', 'tangent'}, optional) – Surface interpolation or a transition leaving both face normals.

  • tension (float or tuple of float, optional) – Positive tangent reach fractions, only for tangent blending.

Returns:

Independent transition retaining all holes.

Return type:

Solid

normal_at(point)#

Return the outward unit normal at a point on this face.

Parameters:

point (tuple of float) – World coordinates on the trimmed face, in metres.

Returns:

Oriented unit normal. Singular surface points raise ValueError.

Return type:

tuple of float

revolved(axis, angle_deg=360.0, *, origin=(0.0, 0.0, 0.0), material=None)#

Return a Solid of revolution from this planar face.

Parameters:
  • axis (str or tuple of float) – Revolution axis letter or non-zero vector.

  • angle_deg (float, optional) – Non-zero angle of at most a full turn, in degrees.

  • origin (tuple of float, optional) – World point on the revolution axis, in metres.

  • material (Material or str, optional) – Override the owner’s material.

Returns:

Independent solid retaining the face’s holes.

Return type:

Solid

swept(spine, *, material=None, frame='corrected_frenet', binormal=None, twist_deg=0.0, draft_deg=0.0, tolerance=None)#

Return a Solid by sweeping this planar face along a Curve.

Parameters:
  • spine (Curve) – World sweep path. The centroid moves to its start and the outward normal aligns with its tangent by the shortest rotation. In-plane roll is retained; an already aligned face stays in its actual pose.

  • material (Material or str, optional) – Override the owner’s material.

  • frame ({'corrected_frenet', 'frenet', 'fixed', 'fixed_binormal'}, optional) – Transport of the initially aligned section. Fixed keeps sections parallel in world space; fixed binormal preserves their angular relation to a supplied world direction.

  • binormal (str or tuple of float, optional) – Required only for fixed binormal transport; it must not be parallel to the spine tangent.

  • twist_deg (float, optional) – Total additional right-hand roll about the transported section normal [degrees], uniform over arc length.

  • draft_deg (float, optional) – Constant section-offset angle [degrees]. Positive values grow the exterior and shrink holes; absolute values must be below 90.

  • tolerance (float, optional) – Sampled fitting tolerance [m], default one millionth of the profile diagonal.

Returns:

Independent continuation with every hole retained.

Return type:

Solid

thickened(thickness, *, direction='forward', material=None)#

Return a Solid offset from this face.

Parameters:
  • thickness (float) – Positive thickness in metres.

  • direction ({'forward', 'backward', 'symmetric'}, optional) – Forward follows the outward normal. Symmetric requires planarity.

  • material (Material or str, optional) – Override the owner’s material.

Returns:

Independent slab or curved offset.

Return type:

Solid

property area#

Face area excluding holes, in square metres.

Type:

float

property centroid#

Area-weighted world centroid in metres.

Type:

tuple of float

property edges#

Unique boundary edges, including inner boundaries.

Type:

EdgeSetRef

property is_planar#

Whether the surface is geometrically planar at CAD tolerance.

Type:

bool

property normal#

Constant outward normal of a planar face.

Type:

tuple of float

property vertices#

Unique vertices on all boundaries.

Type:

tuple of VertexRef

class magnelio.geo.FaceSetRef(owner, _shape, _scale, _origin=None)#

Deliberate, iterable collection of faces sharing one Solid owner.

Parameters:
  • owner (object)

  • _shape (object)

  • _scale (float)

  • _origin (object)

bounding_box()#

Return a world bounding box enclosing every member, in metres.

class magnelio.geo.Group(*shapes, name=None)#

A logical bundle of shapes that preserves each member’s material.

Unlike Union — which fuses its operands into a single solid carrying one material — a Group is a heterogeneous container: every member keeps its own material and its own OCC solid. It exists so a multi-material assembly (e.g. an SMA connector: PEC pin + PTFE dielectric + PEC shell) can be positioned and added to a model as one unit, without collapsing the materials.

A Group therefore has no single material or _occ_shape — it is a compound node exposing members() and bounding_box(). Consequences:

  • Transforms distribute over members. translated() on a Group returns a new Group whose members are each translated; likewise rotated(), scaled() and mirrored().

  • Nesting is allowed (a Group of Groups); members() flattens recursively.

  • Flattened at add(), so the mesher, material filling and overlap layers never see a Group.

  • CSG Boolean ops reject a Group (Union, Intersection, Difference), since it has no single material or solid.

Parameters:
  • *shapes (shape or Group) – Leaf shapes and/or nested Groups to bundle.

  • name (str, optional) – Optional label.

bounding_box()#

Axis-aligned bounding box enclosing every member [meters].

members()#

Yield the leaf shapes, recursively flattening nested Groups.

Any transform applied to the Group has already been baked into each member (transforms distribute on application), so the yielded leaves are ready to hand to the mesher.

mirrored(normal, position=0.0, *, copy=False, unite=False, group=False)#

Return a Group with every member mirrored across one plane.

Parameters:
  • normal (str or tuple of float) – Plane-normal axis name or direction vector.

  • position (float) – Signed plane position along the unit normal [meters].

  • copy (bool, optional) – Include the original assembly first.

  • unite (bool, optional) – Unsupported for Group: Boolean fusion requires individual Solid operands. Use group to retain the assembly materials.

  • group (bool, optional) – Bundle original and image into a Group. Requires copy.

Returns:

One mirrored assembly by default, otherwise a two-element list or an explicitly requested enclosing Group. Member structure and materials persist.

Return type:

Group or list of Group

rotated(axis, angle_deg, origin=(0.0, 0.0, 0.0), *, repeat=1, copy=False, unite=False, group=False)#

Return a Group with every member rotated about one axis.

Parameters:
  • axis (str or tuple of float) – Axis name or direction vector.

  • angle_deg (float) – Right-handed angle [degrees].

  • origin (tuple of float) – Point on the rotation axis [meters].

  • repeat (int, optional) – Number of rotated assemblies at successive angle increments.

  • copy (bool, optional) – Include the original assembly first.

  • unite (bool, optional) – Unsupported for Group: Boolean fusion requires individual Solid operands. Use group to retain the assembly materials.

  • group (bool, optional) – Bundle the assemblies into a Group instead of returning a list.

Returns:

One placed assembly by default, otherwise a list or an explicitly requested enclosing Group. Member structure and materials persist.

Return type:

Group or list of Group

scaled(factor, center=(0.0, 0.0, 0.0))#

Return a Group with every member uniformly scaled.

Parameters:
  • factor (float) – Non-zero uniform scale factor.

  • center (tuple of float) – Fixed point of the scale [meters].

Returns:

New Group with its structure and member materials preserved.

Return type:

Group

translated(vector, *, repeat=1, copy=False, unite=False, group=False)#

Return a Group with every member translated by vector.

Parameters:
  • vector (tuple of float) – (dx, dy, dz) translation [meters].

  • repeat (int, optional) – Number of translated assemblies at successive vector displacements.

  • copy (bool, optional) – Include the original assembly first.

  • unite (bool, optional) – Unsupported for Group: Boolean fusion requires individual Solid operands. Use group to retain the assembly materials.

  • group (bool, optional) – Bundle the assemblies into a Group instead of returning a list.

Returns:

One placed assembly by default, otherwise a list or an explicitly requested enclosing Group. Member structure and materials persist.

Return type:

Group or list of Group

volume(scale=None)#

Total volume of every member [cubic meters].

A Group is a bundle of separate solids, so the volumes simply add; members are not fused first, and a Group whose members overlapped would count the overlap twice — which a GeometryModel does not allow in the first place.

Parameters:

scale (float | None)

Return type:

float

class magnelio.geo.ImportedSheet(shape, material=None, name=None, color=None)#

A free CAD face imported as zero-thickness geometry.

The exact trimmed boundary is retained. Assigning a material does not make the sheet meshable; give it physical thickness with thickened() before adding it to a model.

Parameters:
  • shape (TopoDS_Shape) – A free face in meter coordinates. Shell faces are separate sheets.

  • material (Material or str, optional) – Material inherited by a subsequently thickened solid.

  • name (str, optional) – Imported part name.

  • color (tuple of float, optional) – STEP display RGB in the range 0–1.

bounding_box(scale=None)#

Axis-aligned bounding box (min_corner, max_corner) [meters].

Parameters:

scale (float | None)

chamfered(*, near=None, face_near=None, edges=None, faces=None, distance)#

Return a Solid with a flat bevel on selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms use semantic selection and refuse ambiguity.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • distance (float or tuple of float) – Positive bevel distance in metres, or an asymmetric pair.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

extruded(vector, *, face_near=None, material=None)#

Extrude a Sheet into an independent Solid, retaining holes.

Parameters:
  • vector (tuple of float) – Non-zero world extrusion vector in metres.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).extruded(vector). A tied pick raises AmbiguousTopologyError. Invalid on standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Materialless sections produce construction solids for Boolean use.

Returns:

Independent prism, without fusion to an input owner.

Return type:

Solid

filleted(*, near=None, face_near=None, edges=None, faces=None, radius)#

Return a Solid with rounded selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms refuse ties.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • radius (float) – Positive fillet radius in metres.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

lofted(other, *, material=None, blend='spline', tension=None)#

Connect this planar sheet to another section with a Solid.

Parameters:
  • other (Profile or Sheet or FaceRef) – Planar end section in its actual world placement. All sections need the same number of holes, matched in boundary order.

  • material (Material or str, optional) – Override this sheet’s material; otherwise it is inherited. Materialless sections produce construction solids for Boolean use.

  • blend ({'spline', 'ruled', 'tangent'}, optional) – Interpolation mode. Tangent transitions leave both oriented normals.

  • tension (float or tuple of float, optional) – Positive tangent reach fractions, only for tangent blending.

Returns:

Independent transition retaining all corresponding boundaries.

Return type:

Solid

mirrored(normal, position=0.0, *, copy=False, unite=False, group=False)#

Return this shape reflected across a plane.

The plane is the set of points p with p · normal == position, so for an axis letter position is simply the coordinate of the plane on that axis.

A reflection is not a rotation: it leaves the two in-plane directions untouched and reverses only the normal one. That is what makes it the correct operation for a structure symmetric about a plane but not about the axis normal to it — most planar circuits (dividers, couplers, filters) and every layer stack that differs from top to bottom.

Unlike translated() and rotated() there is no repeat: mirroring twice across one plane reproduces the original.

Parameters:
  • normal (str or sequence of float) – Plane normal: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored). normal='x' maps x -> 2 * position - x.

  • position (float) – Signed distance of the plane from the coordinate origin along normal [meters] (default 0).

  • copy (bool, optional) – Include the original first; defaults to False.

  • unite (bool, optional) – Return a Union of original and image. Requires copy and Solid geometry.

  • group (bool, optional) – Return a Group of original and image, retaining member materials. Requires copy; mutually exclusive with unite.

Returns:

The image alone by default, otherwise [original, image] or the explicitly requested Union or Group.

Return type:

Shape or list of Shape or Union or Group

Examples

Complete a half-modelled power divider into one solid:

full = half.mirrored("x", copy=True, unite=True)

Mirror a feed line onto the far side of a board:

far = line.mirrored("z", position=h / 2)
offset(distance, *, tolerance=None)#

Return a curved sheet shifted along its oriented normal.

Positive distance follows the sheet normal; negative distance goes to the opposite side. The actual trimmed boundary moves with the sheet. This operation does not give a sheet physical thickness.

Parameters:
  • distance (float) – Signed normal distance [meters].

  • tolerance (float, optional) – Maximum sampled geometric deviation [meters]. Defaults to one millionth of the sheet extent, subject to the CAD resolution.

Returns:

Independent offset sheet in a tuple.

Return type:

tuple of Surface

Raises:

ValueError – If the normal offset folds, becomes singular, or exceeds the geometric tolerance.

partition(cutter=None, *, normal=None, position=None)#

Split this solid or sheet into independent connected regions.

Parameters:
  • cutter (Solid or Sheet, optional) – Geometry whose boundary partitions this shape.

  • normal (str or sequence of float, optional) – World normal of a cutting plane. Requires position and excludes cutter.

  • position (float, optional) – Signed plane offset [m], measured as normal dot point.

Returns:

Independently owned regions in kernel order. A non-cut returns one independent region. Order is not persistent across CAD edits.

Return type:

tuple of Solid or Sheet

revolved(axis, angle_deg=360.0, *, origin=(0.0, 0.0, 0.0), material=None)#

Revolve a planar Sheet into an independent Solid.

Parameters:
  • axis (str or sequence of float) – Revolution axis letter or non-zero world vector.

  • angle_deg (float, optional) – Non-zero right-handed angle, at most a full turn, in degrees.

  • origin (tuple of float, optional) – World point on the revolution axis, in metres.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

Returns:

Solid of revolution retaining all holes. A section crossing the axis can produce invalid or self-intersecting geometry.

Return type:

Solid

rotated(axis, angle_deg, origin=(0.0, 0.0, 0.0), *, repeat=1, copy=False, unite=False, group=False)#

Return this shape rotated about an axis.

Parameters:
  • axis (str or sequence of float) – Rotation axis: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored).

  • angle_deg (float) – Rotation angle [degrees], right-handed about axis. Copy i is rotated by i * angle_deg.

  • origin (tuple of float) – A point on the rotation axis (default: the coordinate origin).

  • repeat (int, optional) – Number of rotated copies at angle_deg through repeat * angle_deg; defaults to 1.

  • copy (bool, optional) – Include the unrotated original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One rotated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

Four posts at 90° spacing around the z axis:

posts = post.rotated("z", 90.0, repeat=3, copy=True, group=True)
scaled(factor, center=(0.0, 0.0, 0.0))#

Return this shape scaled uniformly about a fixed point.

The scaling is uniform in all three directions; there is no per-axis factor, because a non-uniform scaling would turn cylinders into elliptic cylinders and spheres into ellipsoids, which the primitives cannot represent.

Parameters:
  • factor (float) – Uniform scale factor. Note that this is not a way to mirror a shape: a negative factor inverts the shape through center, negating all three axes at once. Use mirrored() for a reflection.

  • center (tuple of float) – Fixed point of the scaling (default: the coordinate origin).

Returns:

The scaled shape; a Group is scaled member by member about the common center.

Return type:

Shape or Group

section(cutter=None, *, normal=None, position=None, filled=False)#

Intersect this solid or sheet with a cutter or world plane.

Parameters:
  • cutter (Solid or Sheet, optional) – Intersecting geometry; excludes a plane declaration.

  • normal (str or sequence of float, optional) – World plane normal; requires position.

  • position (float, optional) – Signed world plane offset [m].

  • filled (bool, optional) – Return planar Profiles with holes instead of boundary Curves. Requires a Solid receiver and an explicit plane.

Returns:

Independent intersection geometry. No intersection returns an empty tuple. A coincident face raises rather than choosing a one-dimensional interpretation.

Return type:

tuple of Curve or Profile

shelled(thickness, *, opening_face_near=None, openings=None)#

Hollow this Solid inward to a constant wall thickness.

Parameters:
  • thickness (float) – Positive wall thickness in metres. The outer footprint is retained.

  • opening_face_near (tuple or list of tuple, optional) – World points selecting temporary face references to leave open. Tied picks raise. Mutually exclusive with openings.

  • openings (FaceRef or FaceSetRef or sequence, optional) – Owned faces to leave open; must belong to this exact receiver. Omit both selection modes for a sealed internal void.

Returns:

Hollow body with inherited material.

Return type:

Solid

Raises:
  • TypeError – For a non-Solid receiver; grow a sheet with thickened() instead.

  • RuntimeError – If the offset cannot form a valid closed body.

swept(spine, *, face_near=None, material=None, frame='corrected_frenet', binormal=None, twist_deg=0.0, draft_deg=0.0, tolerance=None)#

Sweep a planar Sheet along a Curve into an independent Solid.

The actual boundary is translated to the spine start and aligned by the shortest normal-to-tangent rotation, retaining in-plane roll. An already aligned section stays in its actual orientation. For an opposite normal, the section plane’s X axis defines the half-turn. The pipe follows corrected Frenet transport unless another frame is selected explicitly.

Parameters:
  • spine (Curve) – World sweep path.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).swept(spine). Tied picks raise. Invalid for standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

  • frame ({'corrected_frenet', 'frenet', 'fixed', 'fixed_binormal'}, optional) – Transport of the initially aligned section. The default retains corrected Frenet transport. Frenet follows curvature and torsion; fixed keeps sections parallel in world space. Fixed binormal preserves their angular relation to the supplied world direction.

  • binormal (str or tuple of float, optional) – Required only for fixed binormal transport. Must not be parallel to the spine tangent. Path’s up direction does not set this value.

  • twist_deg (float, optional) – Total additional right-hand roll about the transported section normal [degrees], distributed uniformly over spine arc length.

  • draft_deg (float, optional) – Constant section-offset angle [degrees], strictly between -90 and 90. Offset equals travelled arc length times its tangent. Positive values expand the exterior and shrink holes. For perpendicular straight sections this is the wall angle to the sweep direction.

  • tolerance (float, optional) – Sampled section-fitting tolerance [m] for nonzero twist or draft. Defaults to one millionth of the initial profile diagonal.

Returns:

Independent pipe retaining the section’s holes.

Return type:

Solid

thickened(thickness, *, direction='forward', material=None)#

Grow this sheet into a solid of constant thickness.

A Sheet, including a planar Profile or curved Surface, can be thickened. A planar sheet becomes a slab whose footprint is exactly the sheet, which makes this the direct way from a drawn outline to a metallisation of a given thickness, without spelling out the extrusion vector. A curved sheet is offset along its own normal into a shell of constant thickness. An unsuitable thickness, curvature or sampled surface can prevent the CAD kernel from building a valid offset.

Parameters:
  • thickness (float) – Slab thickness [meters], positive.

  • direction ({"forward", "backward", "symmetric"}) – Which side of the sheet to grow on. "symmetric" puts half the thickness on each side, leaving the sheet as the slab’s mid-plane (planar sheets only). "forward" and "backward" are opposite sides of it; forward follows the oriented sheet normal. For a FaceRef, forward follows its outward normal.

  • material (Material or str, optional) – Material of the slab. Defaults to the sheet’s material. A materialless sheet produces a construction solid for Boolean use.

Returns:

The solid slab.

Return type:

Solid

Raises:
  • TypeError – If this is a solid — use shelled() instead.

  • ValueError – If the thickness or direction is invalid, or symmetric thickening is requested for a curved sheet.

Examples

A copper patch from a drawn outline:

patch = Profile.from_wires(outline).thickened(thickness=35e-6, material=copper)
translated(vector, *, repeat=1, copy=False, unite=False, group=False)#

Return this shape moved by vector.

Parameters:
  • vector (tuple of float) – (dx, dy, dz) translation [meters].

  • repeat (int, optional) – Number of translated copies, starting at one vector displacement. Copy i is moved by i * vector; defaults to 1.

  • copy (bool, optional) – Include the untransformed original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One translated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

A row of eight vias, including the original, fused into one body:

fence = via.translated((2e-3, 0, 0), repeat=7, copy=True, unite=True)
volume(scale=None)#

Return the volume enclosed by this shape.

Computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters: a Boolean difference reports what is left, and a chamfered block reports what the chamfer took away. That makes it the direct way to check a construction — a filling factor, a metal volume, the agreement between two ways of building the same part.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

Volume in cubic meters. A planar sheet (Profile) has no thickness and reports zero.

Return type:

float

Examples

The fraction of a housing that is metal:

fill = shell.volume() / block.volume()
class magnelio.geo.ImportedSolid(shape, material=None, name=None, color=None)#

A solid whose geometry came from a CAD file or a project store.

Instances are produced by import_step(), import_brep() and by reading back a project’s stored geometry; there is no reason to build one by hand.

An imported solid is a Shape like any other — Boolean operators, the chainable verbs, volume() and bounding_box() all work on it, and it can be added to a GeometryModel once it carries a material. What it is not is the original CSG construction: boundary representation is a finished solid, so the parameters it was drawn from (a radius, an extrusion length) are gone and cannot be edited.

Parameters:
  • material (Material | None)

  • name (str | None)

  • color (tuple[float, float, float] | None)

material#

Material of the solid. None marks a construction body — a solid that was imported but not assigned a material; it can act as a Boolean operand but is rejected by add().

Type:

Material or None

name#

Name the solid carried in its source file. This is the key material assignments are made against, so it survives a re-export of the same CAD model.

Type:

str or None

color#

Display colour (r, g, b) in 0–1 from the source file, or None. Purely cosmetic: plots and the ParaView export use it when the material prescribes no colour of its own; it never affects the physics.

Type:

tuple of float or None

bounding_box(scale=None)#

Axis-aligned bounding box (min_corner, max_corner) [meters].

Parameters:

scale (float | None)

chamfered(*, near=None, face_near=None, edges=None, faces=None, distance)#

Return a Solid with a flat bevel on selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms use semantic selection and refuse ambiguity.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • distance (float or tuple of float) – Positive bevel distance in metres, or an asymmetric pair.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

edge(name=None, *, near=None, curve_type=None)#

Select one owned edge, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

EdgeRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

edges(name=None, *, near=None, curve_type=None)#

Select a deliberate set of owned edges, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered set selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

Read-only view bound to this Solid. With no constraints, selects all members.

Return type:

EdgeSetRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

extruded(vector, *, face_near=None, material=None)#

Extrude a Sheet into an independent Solid, retaining holes.

Parameters:
  • vector (tuple of float) – Non-zero world extrusion vector in metres.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).extruded(vector). A tied pick raises AmbiguousTopologyError. Invalid on standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Materialless sections produce construction solids for Boolean use.

Returns:

Independent prism, without fusion to an input owner.

Return type:

Solid

face(name=None, *, near=None, normal=None, surface_type=None)#

Select one owned face, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

FaceRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

faces(name=None, *, near=None, normal=None, surface_type=None)#

Select a deliberate set of owned faces, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered set selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

Read-only view bound to this Solid. With no constraints, selects all members.

Return type:

FaceSetRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

filleted(*, near=None, face_near=None, edges=None, faces=None, radius)#

Return a Solid with rounded selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms refuse ties.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • radius (float) – Positive fillet radius in metres.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

imprinted(cutter)#

Split this body’s boundary faces along a cutter’s intersection.

The receiver keeps its volume and material. Only its boundary topology changes; the cutter remains an independent shape.

Parameters:

cutter (Solid or Sheet) – Shape whose intersection curves split the receiver’s faces.

Returns:

An independent body with imprinted boundary faces.

Return type:

Solid

Raises:

TopologyEvolutionError – If a singular named selection splits or loses its identity.

lofted(face_near, other=None, other_face_near=None, *, material=None, blend='spline', tension=None)#

Connect this section to another with an independent Solid.

For sheets, use section.lofted(other_section). Suitable FaceRef values provide the same verb. All boundaries contribute, and hole counts must agree. The retained Solid convenience is body.lofted(face_near, other_body, other_face_near); its temporary FaceRefs use semantic selection and refuse tied picks.

Parameters:
  • face_near (Profile or Sheet or FaceRef or tuple) – Planar end section for a Sheet receiver. For the Solid convenience, a world point in metres selecting its start face.

  • other (Solid, optional) – End owner for the Solid point convenience only.

  • other_face_near (tuple of float, optional) – World point selecting the end face for the Solid convenience.

  • material (Material or str, optional) – Override the start section’s material. Without a material the result is a construction solid.

  • blend ({'spline', 'ruled', 'tangent'}, optional) – Smooth or straight interpolation, or a transition leaving both oriented normals. Tangent mode requires faces looking towards each other and retains holes with the same spine conditions.

  • tension (float or tuple of float, optional) – Positive finite tangent reach fractions, only in tangent mode. Defaults to one third at each end.

Returns:

Independent transition matching corresponding boundaries.

Return type:

Solid

mirrored(normal, position=0.0, *, copy=False, unite=False, group=False)#

Return this shape reflected across a plane.

The plane is the set of points p with p · normal == position, so for an axis letter position is simply the coordinate of the plane on that axis.

A reflection is not a rotation: it leaves the two in-plane directions untouched and reverses only the normal one. That is what makes it the correct operation for a structure symmetric about a plane but not about the axis normal to it — most planar circuits (dividers, couplers, filters) and every layer stack that differs from top to bottom.

Unlike translated() and rotated() there is no repeat: mirroring twice across one plane reproduces the original.

Parameters:
  • normal (str or sequence of float) – Plane normal: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored). normal='x' maps x -> 2 * position - x.

  • position (float) – Signed distance of the plane from the coordinate origin along normal [meters] (default 0).

  • copy (bool, optional) – Include the original first; defaults to False.

  • unite (bool, optional) – Return a Union of original and image. Requires copy and Solid geometry.

  • group (bool, optional) – Return a Group of original and image, retaining member materials. Requires copy; mutually exclusive with unite.

Returns:

The image alone by default, otherwise [original, image] or the explicitly requested Union or Group.

Return type:

Shape or list of Shape or Union or Group

Examples

Complete a half-modelled power divider into one solid:

full = half.mirrored("x", copy=True, unite=True)

Mirror a feed line onto the far side of a board:

far = line.mirrored("z", position=h / 2)
partition(cutter=None, *, normal=None, position=None)#

Split this solid or sheet into independent connected regions.

Parameters:
  • cutter (Solid or Sheet, optional) – Geometry whose boundary partitions this shape.

  • normal (str or sequence of float, optional) – World normal of a cutting plane. Requires position and excludes cutter.

  • position (float, optional) – Signed plane offset [m], measured as normal dot point.

Returns:

Independently owned regions in kernel order. A non-cut returns one independent region. Order is not persistent across CAD edits.

Return type:

tuple of Solid or Sheet

revolved(axis, angle_deg=360.0, *, origin=(0.0, 0.0, 0.0), material=None)#

Revolve a planar Sheet into an independent Solid.

Parameters:
  • axis (str or sequence of float) – Revolution axis letter or non-zero world vector.

  • angle_deg (float, optional) – Non-zero right-handed angle, at most a full turn, in degrees.

  • origin (tuple of float, optional) – World point on the revolution axis, in metres.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

Returns:

Solid of revolution retaining all holes. A section crossing the axis can produce invalid or self-intersecting geometry.

Return type:

Solid

rotated(axis, angle_deg, origin=(0.0, 0.0, 0.0), *, repeat=1, copy=False, unite=False, group=False)#

Return this shape rotated about an axis.

Parameters:
  • axis (str or sequence of float) – Rotation axis: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored).

  • angle_deg (float) – Rotation angle [degrees], right-handed about axis. Copy i is rotated by i * angle_deg.

  • origin (tuple of float) – A point on the rotation axis (default: the coordinate origin).

  • repeat (int, optional) – Number of rotated copies at angle_deg through repeat * angle_deg; defaults to 1.

  • copy (bool, optional) – Include the unrotated original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One rotated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

Four posts at 90° spacing around the z axis:

posts = post.rotated("z", 90.0, repeat=3, copy=True, group=True)
scaled(factor, center=(0.0, 0.0, 0.0))#

Return this shape scaled uniformly about a fixed point.

The scaling is uniform in all three directions; there is no per-axis factor, because a non-uniform scaling would turn cylinders into elliptic cylinders and spheres into ellipsoids, which the primitives cannot represent.

Parameters:
  • factor (float) – Uniform scale factor. Note that this is not a way to mirror a shape: a negative factor inverts the shape through center, negating all three axes at once. Use mirrored() for a reflection.

  • center (tuple of float) – Fixed point of the scaling (default: the coordinate origin).

Returns:

The scaled shape; a Group is scaled member by member about the common center.

Return type:

Shape or Group

section(cutter=None, *, normal=None, position=None, filled=False)#

Intersect this solid or sheet with a cutter or world plane.

Parameters:
  • cutter (Solid or Sheet, optional) – Intersecting geometry; excludes a plane declaration.

  • normal (str or sequence of float, optional) – World plane normal; requires position.

  • position (float, optional) – Signed world plane offset [m].

  • filled (bool, optional) – Return planar Profiles with holes instead of boundary Curves. Requires a Solid receiver and an explicit plane.

Returns:

Independent intersection geometry. No intersection returns an empty tuple. A coincident face raises rather than choosing a one-dimensional interpretation.

Return type:

tuple of Curve or Profile

shelled(thickness, *, opening_face_near=None, openings=None)#

Hollow this Solid inward to a constant wall thickness.

Parameters:
  • thickness (float) – Positive wall thickness in metres. The outer footprint is retained.

  • opening_face_near (tuple or list of tuple, optional) – World points selecting temporary face references to leave open. Tied picks raise. Mutually exclusive with openings.

  • openings (FaceRef or FaceSetRef or sequence, optional) – Owned faces to leave open; must belong to this exact receiver. Omit both selection modes for a sealed internal void.

Returns:

Hollow body with inherited material.

Return type:

Solid

Raises:
  • TypeError – For a non-Solid receiver; grow a sheet with thickened() instead.

  • RuntimeError – If the offset cannot form a valid closed body.

swept(spine, *, face_near=None, material=None, frame='corrected_frenet', binormal=None, twist_deg=0.0, draft_deg=0.0, tolerance=None)#

Sweep a planar Sheet along a Curve into an independent Solid.

The actual boundary is translated to the spine start and aligned by the shortest normal-to-tangent rotation, retaining in-plane roll. An already aligned section stays in its actual orientation. For an opposite normal, the section plane’s X axis defines the half-turn. The pipe follows corrected Frenet transport unless another frame is selected explicitly.

Parameters:
  • spine (Curve) – World sweep path.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).swept(spine). Tied picks raise. Invalid for standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

  • frame ({'corrected_frenet', 'frenet', 'fixed', 'fixed_binormal'}, optional) – Transport of the initially aligned section. The default retains corrected Frenet transport. Frenet follows curvature and torsion; fixed keeps sections parallel in world space. Fixed binormal preserves their angular relation to the supplied world direction.

  • binormal (str or tuple of float, optional) – Required only for fixed binormal transport. Must not be parallel to the spine tangent. Path’s up direction does not set this value.

  • twist_deg (float, optional) – Total additional right-hand roll about the transported section normal [degrees], distributed uniformly over spine arc length.

  • draft_deg (float, optional) – Constant section-offset angle [degrees], strictly between -90 and 90. Offset equals travelled arc length times its tangent. Positive values expand the exterior and shrink holes. For perpendicular straight sections this is the wall angle to the sweep direction.

  • tolerance (float, optional) – Sampled section-fitting tolerance [m] for nonzero twist or draft. Defaults to one millionth of the initial profile diagonal.

Returns:

Independent pipe retaining the section’s holes.

Return type:

Solid

tagged_edge(name, *, near=None, curve_type=None)#

Register an immutable named edge selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_edges(name, *, near=None, curve_type=None)#

Register an immutable named set of edges.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_face(name, *, near=None, normal=None, surface_type=None)#

Register an immutable named face selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_faces(name, *, near=None, normal=None, surface_type=None)#

Register an immutable named set of faces.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_vertex(name, *, near=None)#

Register an immutable named vertex selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

thickened(thickness, *, direction='forward', material=None)#

Grow this sheet into a solid of constant thickness.

A Sheet, including a planar Profile or curved Surface, can be thickened. A planar sheet becomes a slab whose footprint is exactly the sheet, which makes this the direct way from a drawn outline to a metallisation of a given thickness, without spelling out the extrusion vector. A curved sheet is offset along its own normal into a shell of constant thickness. An unsuitable thickness, curvature or sampled surface can prevent the CAD kernel from building a valid offset.

Parameters:
  • thickness (float) – Slab thickness [meters], positive.

  • direction ({"forward", "backward", "symmetric"}) – Which side of the sheet to grow on. "symmetric" puts half the thickness on each side, leaving the sheet as the slab’s mid-plane (planar sheets only). "forward" and "backward" are opposite sides of it; forward follows the oriented sheet normal. For a FaceRef, forward follows its outward normal.

  • material (Material or str, optional) – Material of the slab. Defaults to the sheet’s material. A materialless sheet produces a construction solid for Boolean use.

Returns:

The solid slab.

Return type:

Solid

Raises:
  • TypeError – If this is a solid — use shelled() instead.

  • ValueError – If the thickness or direction is invalid, or symmetric thickening is requested for a curved sheet.

Examples

A copper patch from a drawn outline:

patch = Profile.from_wires(outline).thickened(thickness=35e-6, material=copper)
translated(vector, *, repeat=1, copy=False, unite=False, group=False)#

Return this shape moved by vector.

Parameters:
  • vector (tuple of float) – (dx, dy, dz) translation [meters].

  • repeat (int, optional) – Number of translated copies, starting at one vector displacement. Copy i is moved by i * vector; defaults to 1.

  • copy (bool, optional) – Include the untransformed original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One translated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

A row of eight vias, including the original, fused into one body:

fence = via.translated((2e-3, 0, 0), repeat=7, copy=True, unite=True)
vertex(name=None, *, near=None)#

Select one owned vertex, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

VertexRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

volume(scale=None)#

Return the volume enclosed by this shape.

Computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters: a Boolean difference reports what is left, and a chamfered block reports what the chamfer took away. That makes it the direct way to check a construction — a filling factor, a metal volume, the agreement between two ways of building the same part.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

Volume in cubic meters. A planar sheet (Profile) has no thickness and reports zero.

Return type:

float

Examples

The fraction of a housing that is metal:

fill = shell.volume() / block.volume()
class magnelio.geo.Intersection(shape_a, shape_b, material=None, name=None)#

Boolean intersection of two shapes.

Parameters:
  • shape_a (object) – Base shape.

  • shape_b (object) – Tool shape.

  • material (Material | None) – Material for the resulting volume. Defaults to shape_a’s material.

  • name (str | None) – Optional label.

bounding_box(scale=None)#

Return the axis-aligned bounding box of this shape.

The box is computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters — a rotated brick reports the box of the rotated solid.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

(min_corner, max_corner), each (x, y, z) in meters.

Return type:

tuple

chamfered(*, near=None, face_near=None, edges=None, faces=None, distance)#

Return a Solid with a flat bevel on selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms use semantic selection and refuse ambiguity.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • distance (float or tuple of float) – Positive bevel distance in metres, or an asymmetric pair.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

edge(name=None, *, near=None, curve_type=None)#

Select one owned edge, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

EdgeRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

edges(name=None, *, near=None, curve_type=None)#

Select a deliberate set of owned edges, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered set selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

Read-only view bound to this Solid. With no constraints, selects all members.

Return type:

EdgeSetRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

extruded(vector, *, face_near=None, material=None)#

Extrude a Sheet into an independent Solid, retaining holes.

Parameters:
  • vector (tuple of float) – Non-zero world extrusion vector in metres.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).extruded(vector). A tied pick raises AmbiguousTopologyError. Invalid on standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Materialless sections produce construction solids for Boolean use.

Returns:

Independent prism, without fusion to an input owner.

Return type:

Solid

face(name=None, *, near=None, normal=None, surface_type=None)#

Select one owned face, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

FaceRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

faces(name=None, *, near=None, normal=None, surface_type=None)#

Select a deliberate set of owned faces, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered set selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

Read-only view bound to this Solid. With no constraints, selects all members.

Return type:

FaceSetRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

filleted(*, near=None, face_near=None, edges=None, faces=None, radius)#

Return a Solid with rounded selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms refuse ties.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • radius (float) – Positive fillet radius in metres.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

imprinted(cutter)#

Split this body’s boundary faces along a cutter’s intersection.

The receiver keeps its volume and material. Only its boundary topology changes; the cutter remains an independent shape.

Parameters:

cutter (Solid or Sheet) – Shape whose intersection curves split the receiver’s faces.

Returns:

An independent body with imprinted boundary faces.

Return type:

Solid

Raises:

TopologyEvolutionError – If a singular named selection splits or loses its identity.

lofted(face_near, other=None, other_face_near=None, *, material=None, blend='spline', tension=None)#

Connect this section to another with an independent Solid.

For sheets, use section.lofted(other_section). Suitable FaceRef values provide the same verb. All boundaries contribute, and hole counts must agree. The retained Solid convenience is body.lofted(face_near, other_body, other_face_near); its temporary FaceRefs use semantic selection and refuse tied picks.

Parameters:
  • face_near (Profile or Sheet or FaceRef or tuple) – Planar end section for a Sheet receiver. For the Solid convenience, a world point in metres selecting its start face.

  • other (Solid, optional) – End owner for the Solid point convenience only.

  • other_face_near (tuple of float, optional) – World point selecting the end face for the Solid convenience.

  • material (Material or str, optional) – Override the start section’s material. Without a material the result is a construction solid.

  • blend ({'spline', 'ruled', 'tangent'}, optional) – Smooth or straight interpolation, or a transition leaving both oriented normals. Tangent mode requires faces looking towards each other and retains holes with the same spine conditions.

  • tension (float or tuple of float, optional) – Positive finite tangent reach fractions, only in tangent mode. Defaults to one third at each end.

Returns:

Independent transition matching corresponding boundaries.

Return type:

Solid

mirrored(normal, position=0.0, *, copy=False, unite=False, group=False)#

Return this shape reflected across a plane.

The plane is the set of points p with p · normal == position, so for an axis letter position is simply the coordinate of the plane on that axis.

A reflection is not a rotation: it leaves the two in-plane directions untouched and reverses only the normal one. That is what makes it the correct operation for a structure symmetric about a plane but not about the axis normal to it — most planar circuits (dividers, couplers, filters) and every layer stack that differs from top to bottom.

Unlike translated() and rotated() there is no repeat: mirroring twice across one plane reproduces the original.

Parameters:
  • normal (str or sequence of float) – Plane normal: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored). normal='x' maps x -> 2 * position - x.

  • position (float) – Signed distance of the plane from the coordinate origin along normal [meters] (default 0).

  • copy (bool, optional) – Include the original first; defaults to False.

  • unite (bool, optional) – Return a Union of original and image. Requires copy and Solid geometry.

  • group (bool, optional) – Return a Group of original and image, retaining member materials. Requires copy; mutually exclusive with unite.

Returns:

The image alone by default, otherwise [original, image] or the explicitly requested Union or Group.

Return type:

Shape or list of Shape or Union or Group

Examples

Complete a half-modelled power divider into one solid:

full = half.mirrored("x", copy=True, unite=True)

Mirror a feed line onto the far side of a board:

far = line.mirrored("z", position=h / 2)
partition(cutter=None, *, normal=None, position=None)#

Split this solid or sheet into independent connected regions.

Parameters:
  • cutter (Solid or Sheet, optional) – Geometry whose boundary partitions this shape.

  • normal (str or sequence of float, optional) – World normal of a cutting plane. Requires position and excludes cutter.

  • position (float, optional) – Signed plane offset [m], measured as normal dot point.

Returns:

Independently owned regions in kernel order. A non-cut returns one independent region. Order is not persistent across CAD edits.

Return type:

tuple of Solid or Sheet

revolved(axis, angle_deg=360.0, *, origin=(0.0, 0.0, 0.0), material=None)#

Revolve a planar Sheet into an independent Solid.

Parameters:
  • axis (str or sequence of float) – Revolution axis letter or non-zero world vector.

  • angle_deg (float, optional) – Non-zero right-handed angle, at most a full turn, in degrees.

  • origin (tuple of float, optional) – World point on the revolution axis, in metres.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

Returns:

Solid of revolution retaining all holes. A section crossing the axis can produce invalid or self-intersecting geometry.

Return type:

Solid

rotated(axis, angle_deg, origin=(0.0, 0.0, 0.0), *, repeat=1, copy=False, unite=False, group=False)#

Return this shape rotated about an axis.

Parameters:
  • axis (str or sequence of float) – Rotation axis: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored).

  • angle_deg (float) – Rotation angle [degrees], right-handed about axis. Copy i is rotated by i * angle_deg.

  • origin (tuple of float) – A point on the rotation axis (default: the coordinate origin).

  • repeat (int, optional) – Number of rotated copies at angle_deg through repeat * angle_deg; defaults to 1.

  • copy (bool, optional) – Include the unrotated original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One rotated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

Four posts at 90° spacing around the z axis:

posts = post.rotated("z", 90.0, repeat=3, copy=True, group=True)
scaled(factor, center=(0.0, 0.0, 0.0))#

Return this shape scaled uniformly about a fixed point.

The scaling is uniform in all three directions; there is no per-axis factor, because a non-uniform scaling would turn cylinders into elliptic cylinders and spheres into ellipsoids, which the primitives cannot represent.

Parameters:
  • factor (float) – Uniform scale factor. Note that this is not a way to mirror a shape: a negative factor inverts the shape through center, negating all three axes at once. Use mirrored() for a reflection.

  • center (tuple of float) – Fixed point of the scaling (default: the coordinate origin).

Returns:

The scaled shape; a Group is scaled member by member about the common center.

Return type:

Shape or Group

section(cutter=None, *, normal=None, position=None, filled=False)#

Intersect this solid or sheet with a cutter or world plane.

Parameters:
  • cutter (Solid or Sheet, optional) – Intersecting geometry; excludes a plane declaration.

  • normal (str or sequence of float, optional) – World plane normal; requires position.

  • position (float, optional) – Signed world plane offset [m].

  • filled (bool, optional) – Return planar Profiles with holes instead of boundary Curves. Requires a Solid receiver and an explicit plane.

Returns:

Independent intersection geometry. No intersection returns an empty tuple. A coincident face raises rather than choosing a one-dimensional interpretation.

Return type:

tuple of Curve or Profile

shelled(thickness, *, opening_face_near=None, openings=None)#

Hollow this Solid inward to a constant wall thickness.

Parameters:
  • thickness (float) – Positive wall thickness in metres. The outer footprint is retained.

  • opening_face_near (tuple or list of tuple, optional) – World points selecting temporary face references to leave open. Tied picks raise. Mutually exclusive with openings.

  • openings (FaceRef or FaceSetRef or sequence, optional) – Owned faces to leave open; must belong to this exact receiver. Omit both selection modes for a sealed internal void.

Returns:

Hollow body with inherited material.

Return type:

Solid

Raises:
  • TypeError – For a non-Solid receiver; grow a sheet with thickened() instead.

  • RuntimeError – If the offset cannot form a valid closed body.

swept(spine, *, face_near=None, material=None, frame='corrected_frenet', binormal=None, twist_deg=0.0, draft_deg=0.0, tolerance=None)#

Sweep a planar Sheet along a Curve into an independent Solid.

The actual boundary is translated to the spine start and aligned by the shortest normal-to-tangent rotation, retaining in-plane roll. An already aligned section stays in its actual orientation. For an opposite normal, the section plane’s X axis defines the half-turn. The pipe follows corrected Frenet transport unless another frame is selected explicitly.

Parameters:
  • spine (Curve) – World sweep path.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).swept(spine). Tied picks raise. Invalid for standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

  • frame ({'corrected_frenet', 'frenet', 'fixed', 'fixed_binormal'}, optional) – Transport of the initially aligned section. The default retains corrected Frenet transport. Frenet follows curvature and torsion; fixed keeps sections parallel in world space. Fixed binormal preserves their angular relation to the supplied world direction.

  • binormal (str or tuple of float, optional) – Required only for fixed binormal transport. Must not be parallel to the spine tangent. Path’s up direction does not set this value.

  • twist_deg (float, optional) – Total additional right-hand roll about the transported section normal [degrees], distributed uniformly over spine arc length.

  • draft_deg (float, optional) – Constant section-offset angle [degrees], strictly between -90 and 90. Offset equals travelled arc length times its tangent. Positive values expand the exterior and shrink holes. For perpendicular straight sections this is the wall angle to the sweep direction.

  • tolerance (float, optional) – Sampled section-fitting tolerance [m] for nonzero twist or draft. Defaults to one millionth of the initial profile diagonal.

Returns:

Independent pipe retaining the section’s holes.

Return type:

Solid

tagged_edge(name, *, near=None, curve_type=None)#

Register an immutable named edge selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_edges(name, *, near=None, curve_type=None)#

Register an immutable named set of edges.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_face(name, *, near=None, normal=None, surface_type=None)#

Register an immutable named face selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_faces(name, *, near=None, normal=None, surface_type=None)#

Register an immutable named set of faces.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_vertex(name, *, near=None)#

Register an immutable named vertex selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

thickened(thickness, *, direction='forward', material=None)#

Grow this sheet into a solid of constant thickness.

A Sheet, including a planar Profile or curved Surface, can be thickened. A planar sheet becomes a slab whose footprint is exactly the sheet, which makes this the direct way from a drawn outline to a metallisation of a given thickness, without spelling out the extrusion vector. A curved sheet is offset along its own normal into a shell of constant thickness. An unsuitable thickness, curvature or sampled surface can prevent the CAD kernel from building a valid offset.

Parameters:
  • thickness (float) – Slab thickness [meters], positive.

  • direction ({"forward", "backward", "symmetric"}) – Which side of the sheet to grow on. "symmetric" puts half the thickness on each side, leaving the sheet as the slab’s mid-plane (planar sheets only). "forward" and "backward" are opposite sides of it; forward follows the oriented sheet normal. For a FaceRef, forward follows its outward normal.

  • material (Material or str, optional) – Material of the slab. Defaults to the sheet’s material. A materialless sheet produces a construction solid for Boolean use.

Returns:

The solid slab.

Return type:

Solid

Raises:
  • TypeError – If this is a solid — use shelled() instead.

  • ValueError – If the thickness or direction is invalid, or symmetric thickening is requested for a curved sheet.

Examples

A copper patch from a drawn outline:

patch = Profile.from_wires(outline).thickened(thickness=35e-6, material=copper)
translated(vector, *, repeat=1, copy=False, unite=False, group=False)#

Return this shape moved by vector.

Parameters:
  • vector (tuple of float) – (dx, dy, dz) translation [meters].

  • repeat (int, optional) – Number of translated copies, starting at one vector displacement. Copy i is moved by i * vector; defaults to 1.

  • copy (bool, optional) – Include the untransformed original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One translated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

A row of eight vias, including the original, fused into one body:

fence = via.translated((2e-3, 0, 0), repeat=7, copy=True, unite=True)
vertex(name=None, *, near=None)#

Select one owned vertex, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

VertexRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

volume(scale=None)#

Return the volume enclosed by this shape.

Computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters: a Boolean difference reports what is left, and a chamfered block reports what the chamfer took away. That makes it the direct way to check a construction — a filling factor, a metal volume, the agreement between two ways of building the same part.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

Volume in cubic meters. A planar sheet (Profile) has no thickness and reports zero.

Return type:

float

Examples

The fraction of a housing that is metal:

fill = shell.volume() / block.volume()
class magnelio.geo.Loft(*sections, blend='spline', material=None, name=None)#

A solid interpolating an ordered series of cross-sections.

The way to build a transition no primitive covers: a horn flaring from a waveguide mouth to a wider aperture, a taper from a round cross-section to a square one, a matching section that steps through several intermediate outlines. Where lofted() bridges one face of a solid to a face of another, Loft takes the profiles themselves and as many of them as the shape needs.

Parameters:
  • *sections (Profile or Sheet or FaceRef or Curve) – At least two planar cross-sections, in the order the solid passes through them. Profiles contribute their outer boundary and all holes, matched in boundary order. Every section needs the same hole count. The sections should wind the same way — a reversed one produces a twisted, self-intersecting solid rather than an error.

  • blend ({'spline', 'ruled'}) – How consecutive sections are joined. 'spline' (default) passes one smooth surface through all of them; 'ruled' joins them with straight surfaces, so the solid is a stack of frusta.

  • material (Material, optional) – Material of the lofted solid. Defaults to the first section’s material; without one the result is a construction solid.

  • name (str, optional) – Optional label.

Raises:
  • TypeError – If a section is a solid (select a FaceRef first) or a Group.

  • ValueError – If fewer than two sections are given, a Curve section is not closed, or blend is not one of the two modes above.

Examples

A horn flaring from a square throat to a wider square mouth:

throat = geo.Profile.rectangle((0, 0, 0), (10e-3, 10e-3))
mouth = geo.Profile.rectangle((0, 0, 60e-3), (30e-3, 30e-3))
horn = geo.Loft(throat, mouth, blend="ruled", material=pec)
bounding_box(scale=None)#

Return the axis-aligned bounding box of this shape.

The box is computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters — a rotated brick reports the box of the rotated solid.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

(min_corner, max_corner), each (x, y, z) in meters.

Return type:

tuple

chamfered(*, near=None, face_near=None, edges=None, faces=None, distance)#

Return a Solid with a flat bevel on selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms use semantic selection and refuse ambiguity.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • distance (float or tuple of float) – Positive bevel distance in metres, or an asymmetric pair.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

edge(name=None, *, near=None, curve_type=None)#

Select one owned edge, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

EdgeRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

edges(name=None, *, near=None, curve_type=None)#

Select a deliberate set of owned edges, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered set selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

Read-only view bound to this Solid. With no constraints, selects all members.

Return type:

EdgeSetRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

extruded(vector, *, face_near=None, material=None)#

Extrude a Sheet into an independent Solid, retaining holes.

Parameters:
  • vector (tuple of float) – Non-zero world extrusion vector in metres.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).extruded(vector). A tied pick raises AmbiguousTopologyError. Invalid on standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Materialless sections produce construction solids for Boolean use.

Returns:

Independent prism, without fusion to an input owner.

Return type:

Solid

face(name=None, *, near=None, normal=None, surface_type=None)#

Select one owned face, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

FaceRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

faces(name=None, *, near=None, normal=None, surface_type=None)#

Select a deliberate set of owned faces, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered set selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

Read-only view bound to this Solid. With no constraints, selects all members.

Return type:

FaceSetRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

filleted(*, near=None, face_near=None, edges=None, faces=None, radius)#

Return a Solid with rounded selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms refuse ties.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • radius (float) – Positive fillet radius in metres.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

imprinted(cutter)#

Split this body’s boundary faces along a cutter’s intersection.

The receiver keeps its volume and material. Only its boundary topology changes; the cutter remains an independent shape.

Parameters:

cutter (Solid or Sheet) – Shape whose intersection curves split the receiver’s faces.

Returns:

An independent body with imprinted boundary faces.

Return type:

Solid

Raises:

TopologyEvolutionError – If a singular named selection splits or loses its identity.

lofted(face_near, other=None, other_face_near=None, *, material=None, blend='spline', tension=None)#

Connect this section to another with an independent Solid.

For sheets, use section.lofted(other_section). Suitable FaceRef values provide the same verb. All boundaries contribute, and hole counts must agree. The retained Solid convenience is body.lofted(face_near, other_body, other_face_near); its temporary FaceRefs use semantic selection and refuse tied picks.

Parameters:
  • face_near (Profile or Sheet or FaceRef or tuple) – Planar end section for a Sheet receiver. For the Solid convenience, a world point in metres selecting its start face.

  • other (Solid, optional) – End owner for the Solid point convenience only.

  • other_face_near (tuple of float, optional) – World point selecting the end face for the Solid convenience.

  • material (Material or str, optional) – Override the start section’s material. Without a material the result is a construction solid.

  • blend ({'spline', 'ruled', 'tangent'}, optional) – Smooth or straight interpolation, or a transition leaving both oriented normals. Tangent mode requires faces looking towards each other and retains holes with the same spine conditions.

  • tension (float or tuple of float, optional) – Positive finite tangent reach fractions, only in tangent mode. Defaults to one third at each end.

Returns:

Independent transition matching corresponding boundaries.

Return type:

Solid

mirrored(normal, position=0.0, *, copy=False, unite=False, group=False)#

Return this shape reflected across a plane.

The plane is the set of points p with p · normal == position, so for an axis letter position is simply the coordinate of the plane on that axis.

A reflection is not a rotation: it leaves the two in-plane directions untouched and reverses only the normal one. That is what makes it the correct operation for a structure symmetric about a plane but not about the axis normal to it — most planar circuits (dividers, couplers, filters) and every layer stack that differs from top to bottom.

Unlike translated() and rotated() there is no repeat: mirroring twice across one plane reproduces the original.

Parameters:
  • normal (str or sequence of float) – Plane normal: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored). normal='x' maps x -> 2 * position - x.

  • position (float) – Signed distance of the plane from the coordinate origin along normal [meters] (default 0).

  • copy (bool, optional) – Include the original first; defaults to False.

  • unite (bool, optional) – Return a Union of original and image. Requires copy and Solid geometry.

  • group (bool, optional) – Return a Group of original and image, retaining member materials. Requires copy; mutually exclusive with unite.

Returns:

The image alone by default, otherwise [original, image] or the explicitly requested Union or Group.

Return type:

Shape or list of Shape or Union or Group

Examples

Complete a half-modelled power divider into one solid:

full = half.mirrored("x", copy=True, unite=True)

Mirror a feed line onto the far side of a board:

far = line.mirrored("z", position=h / 2)
partition(cutter=None, *, normal=None, position=None)#

Split this solid or sheet into independent connected regions.

Parameters:
  • cutter (Solid or Sheet, optional) – Geometry whose boundary partitions this shape.

  • normal (str or sequence of float, optional) – World normal of a cutting plane. Requires position and excludes cutter.

  • position (float, optional) – Signed plane offset [m], measured as normal dot point.

Returns:

Independently owned regions in kernel order. A non-cut returns one independent region. Order is not persistent across CAD edits.

Return type:

tuple of Solid or Sheet

revolved(axis, angle_deg=360.0, *, origin=(0.0, 0.0, 0.0), material=None)#

Revolve a planar Sheet into an independent Solid.

Parameters:
  • axis (str or sequence of float) – Revolution axis letter or non-zero world vector.

  • angle_deg (float, optional) – Non-zero right-handed angle, at most a full turn, in degrees.

  • origin (tuple of float, optional) – World point on the revolution axis, in metres.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

Returns:

Solid of revolution retaining all holes. A section crossing the axis can produce invalid or self-intersecting geometry.

Return type:

Solid

rotated(axis, angle_deg, origin=(0.0, 0.0, 0.0), *, repeat=1, copy=False, unite=False, group=False)#

Return this shape rotated about an axis.

Parameters:
  • axis (str or sequence of float) – Rotation axis: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored).

  • angle_deg (float) – Rotation angle [degrees], right-handed about axis. Copy i is rotated by i * angle_deg.

  • origin (tuple of float) – A point on the rotation axis (default: the coordinate origin).

  • repeat (int, optional) – Number of rotated copies at angle_deg through repeat * angle_deg; defaults to 1.

  • copy (bool, optional) – Include the unrotated original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One rotated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

Four posts at 90° spacing around the z axis:

posts = post.rotated("z", 90.0, repeat=3, copy=True, group=True)
scaled(factor, center=(0.0, 0.0, 0.0))#

Return this shape scaled uniformly about a fixed point.

The scaling is uniform in all three directions; there is no per-axis factor, because a non-uniform scaling would turn cylinders into elliptic cylinders and spheres into ellipsoids, which the primitives cannot represent.

Parameters:
  • factor (float) – Uniform scale factor. Note that this is not a way to mirror a shape: a negative factor inverts the shape through center, negating all three axes at once. Use mirrored() for a reflection.

  • center (tuple of float) – Fixed point of the scaling (default: the coordinate origin).

Returns:

The scaled shape; a Group is scaled member by member about the common center.

Return type:

Shape or Group

section(cutter=None, *, normal=None, position=None, filled=False)#

Intersect this solid or sheet with a cutter or world plane.

Parameters:
  • cutter (Solid or Sheet, optional) – Intersecting geometry; excludes a plane declaration.

  • normal (str or sequence of float, optional) – World plane normal; requires position.

  • position (float, optional) – Signed world plane offset [m].

  • filled (bool, optional) – Return planar Profiles with holes instead of boundary Curves. Requires a Solid receiver and an explicit plane.

Returns:

Independent intersection geometry. No intersection returns an empty tuple. A coincident face raises rather than choosing a one-dimensional interpretation.

Return type:

tuple of Curve or Profile

shelled(thickness, *, opening_face_near=None, openings=None)#

Hollow this Solid inward to a constant wall thickness.

Parameters:
  • thickness (float) – Positive wall thickness in metres. The outer footprint is retained.

  • opening_face_near (tuple or list of tuple, optional) – World points selecting temporary face references to leave open. Tied picks raise. Mutually exclusive with openings.

  • openings (FaceRef or FaceSetRef or sequence, optional) – Owned faces to leave open; must belong to this exact receiver. Omit both selection modes for a sealed internal void.

Returns:

Hollow body with inherited material.

Return type:

Solid

Raises:
  • TypeError – For a non-Solid receiver; grow a sheet with thickened() instead.

  • RuntimeError – If the offset cannot form a valid closed body.

swept(spine, *, face_near=None, material=None, frame='corrected_frenet', binormal=None, twist_deg=0.0, draft_deg=0.0, tolerance=None)#

Sweep a planar Sheet along a Curve into an independent Solid.

The actual boundary is translated to the spine start and aligned by the shortest normal-to-tangent rotation, retaining in-plane roll. An already aligned section stays in its actual orientation. For an opposite normal, the section plane’s X axis defines the half-turn. The pipe follows corrected Frenet transport unless another frame is selected explicitly.

Parameters:
  • spine (Curve) – World sweep path.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).swept(spine). Tied picks raise. Invalid for standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

  • frame ({'corrected_frenet', 'frenet', 'fixed', 'fixed_binormal'}, optional) – Transport of the initially aligned section. The default retains corrected Frenet transport. Frenet follows curvature and torsion; fixed keeps sections parallel in world space. Fixed binormal preserves their angular relation to the supplied world direction.

  • binormal (str or tuple of float, optional) – Required only for fixed binormal transport. Must not be parallel to the spine tangent. Path’s up direction does not set this value.

  • twist_deg (float, optional) – Total additional right-hand roll about the transported section normal [degrees], distributed uniformly over spine arc length.

  • draft_deg (float, optional) – Constant section-offset angle [degrees], strictly between -90 and 90. Offset equals travelled arc length times its tangent. Positive values expand the exterior and shrink holes. For perpendicular straight sections this is the wall angle to the sweep direction.

  • tolerance (float, optional) – Sampled section-fitting tolerance [m] for nonzero twist or draft. Defaults to one millionth of the initial profile diagonal.

Returns:

Independent pipe retaining the section’s holes.

Return type:

Solid

tagged_edge(name, *, near=None, curve_type=None)#

Register an immutable named edge selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_edges(name, *, near=None, curve_type=None)#

Register an immutable named set of edges.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_face(name, *, near=None, normal=None, surface_type=None)#

Register an immutable named face selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_faces(name, *, near=None, normal=None, surface_type=None)#

Register an immutable named set of faces.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_vertex(name, *, near=None)#

Register an immutable named vertex selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

thickened(thickness, *, direction='forward', material=None)#

Grow this sheet into a solid of constant thickness.

A Sheet, including a planar Profile or curved Surface, can be thickened. A planar sheet becomes a slab whose footprint is exactly the sheet, which makes this the direct way from a drawn outline to a metallisation of a given thickness, without spelling out the extrusion vector. A curved sheet is offset along its own normal into a shell of constant thickness. An unsuitable thickness, curvature or sampled surface can prevent the CAD kernel from building a valid offset.

Parameters:
  • thickness (float) – Slab thickness [meters], positive.

  • direction ({"forward", "backward", "symmetric"}) – Which side of the sheet to grow on. "symmetric" puts half the thickness on each side, leaving the sheet as the slab’s mid-plane (planar sheets only). "forward" and "backward" are opposite sides of it; forward follows the oriented sheet normal. For a FaceRef, forward follows its outward normal.

  • material (Material or str, optional) – Material of the slab. Defaults to the sheet’s material. A materialless sheet produces a construction solid for Boolean use.

Returns:

The solid slab.

Return type:

Solid

Raises:
  • TypeError – If this is a solid — use shelled() instead.

  • ValueError – If the thickness or direction is invalid, or symmetric thickening is requested for a curved sheet.

Examples

A copper patch from a drawn outline:

patch = Profile.from_wires(outline).thickened(thickness=35e-6, material=copper)
translated(vector, *, repeat=1, copy=False, unite=False, group=False)#

Return this shape moved by vector.

Parameters:
  • vector (tuple of float) – (dx, dy, dz) translation [meters].

  • repeat (int, optional) – Number of translated copies, starting at one vector displacement. Copy i is moved by i * vector; defaults to 1.

  • copy (bool, optional) – Include the untransformed original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One translated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

A row of eight vias, including the original, fused into one body:

fence = via.translated((2e-3, 0, 0), repeat=7, copy=True, unite=True)
vertex(name=None, *, near=None)#

Select one owned vertex, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

VertexRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

volume(scale=None)#

Return the volume enclosed by this shape.

Computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters: a Boolean difference reports what is left, and a chamfered block reports what the chamfer took away. That makes it the direct way to check a construction — a filling factor, a metal volume, the agreement between two ways of building the same part.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

Volume in cubic meters. A planar sheet (Profile) has no thickness and reports zero.

Return type:

float

Examples

The fraction of a housing that is metal:

fill = shell.volume() / block.volume()
class magnelio.geo.Mirror(normal, position=0.0)#

Reflection across the plane point . normal == position.

Parameters:
  • normal (str or tuple of float) – "x", "y", "z" or the plane’s normal vector.

  • position (float) – Signed plane position along the unit normal [meters].

classmethod identity()#

Return the identity transform.

Return type:

Transform

point(point)#

Return point transformed by this affine value.

Return type:

tuple[float, float, float]

class magnelio.geo.Path(start, _segments=<factory>)#

A pen that draws a chained Curve.

Start at a point, then append one segment per call; each segment begins where the previous one ended, so only its end (and whatever shapes it) has to be given. Finish with curve() for an open path or closed() for a loop accepted by from_wires().

from_pose() and from_face() seed a tangent and perpendicular up direction for relative routing. Up is transported without twist along curved segments; it defines left as up x tangent. The pose guides routing and does not select a pipe-sweep orientation mode.

A Path is immutable. Every segment call returns a new Path and leaves the receiver alone, so a common prefix can be branched into several outlines.

Parameters:
  • start (tuple of float) – The 3D point (x, y, z) the pen starts from [meters].

  • _segments (tuple)

Examples

A slot outline with two rounded ends:

outline = (
    Path((0.0, -1e-3, 0.0))
    .line_to((6e-3, -1e-3, 0.0))
    .arc_to((6e-3, 1e-3, 0.0), center=(6e-3, 0.0, 0.0))
    .line_to((0.0, 1e-3, 0.0))
    .arc_to((0.0, -1e-3, 0.0), center=(0.0, 0.0, 0.0))
    .closed()
)
slot = Profile.from_wires(outline).extruded(vector=(0, 0, t), material=copper)
classmethod from_face(face_ref, *, up)#

Start at a planar owned face’s centroid along its outward normal.

Parameters:
  • face_ref (FaceRef) – Selected planar face, retaining its world placement.

  • up (str or sequence of float) – Roll reference, projected into the face plane.

Returns:

Empty route pointing out of the face.

Return type:

Path

Raises:
  • TypeError – If the input is not a FaceRef.

  • ValueError – If the face is curved or up is parallel to its normal.

classmethod from_pose(point, tangent, up)#

Start a route from a world point and explicit directions.

Parameters:
  • point (sequence of float) – Start point in meters.

  • tangent (str or sequence of float) – Nonzero forward direction, or an axis letter.

  • up (str or sequence of float) – Nonzero roll reference, projected perpendicular to tangent. Parallel directions are rejected.

Returns:

An empty immutable path with an orthonormal pose.

Return type:

Path

arc_to(end, *, via=None, center=None, normal=None, major=False)#

Append a circular arc ending at end.

Give exactly one of via or center — two ways of pinning down which arc is meant:

  • via — a point the arc passes through. Always unambiguous, and the form to reach for when the center is not what you know.

  • center — the center of the circle, which must be equidistant from the current point and end. This is the form for a slice of a round part, where the axis is the given quantity.

Two arcs join any pair of points on a circle, and in 3D a pair of diametrically opposite points does not even fix the plane. With center, add normal to settle both at once: the arc then runs counter-clockwise about normal, so swapping the two endpoints gives the complementary arc. Without normal the shorter arc is drawn (or the longer one with major), and diametrically opposite ends are rejected.

Parameters:
  • end (tuple of float) – End point (x, y, z) [meters].

  • via (tuple of float, optional) – A point on the arc, between start and end.

  • center (tuple of float, optional) – Centre of the arc’s circle.

  • normal (str or sequence of float, optional) – With center: the axis the arc turns about — 'x', 'y', 'z', or any non-zero 3-vector. The arc runs counter-clockwise about it, seen from the tip of the axis. Both endpoints must lie in the plane through center perpendicular to it.

  • major (bool) – With center and no normal: take the long way round (default False).

Returns:

A new Path ending at end.

Return type:

Path

Raises:

ValueError – If neither or both of via and center are given, if center is not equidistant from both endpoints, if the endpoints do not lie in the plane normal describes, or if they are diametrically opposite and no normal was given to say which arc is meant.

Examples

The rounded end of a slot, turning about z:

path.arc_to((0.0, -1e-3, 0.0), center=(0.0, 0.0, 0.0), normal="z")
closed(*, name=None)#

Return the drawn path as a closed Curve.

A straight segment back to the start point is appended unless the path already ends there, so the result is always a loop and can be made into a sheet with from_wires().

Parameters:

name (str, optional) – Optional label.

Returns:

The closed curve.

Return type:

Curve

curve(*, name=None)#

Return the drawn path as a Curve.

The path is taken as drawn: open unless the last segment happens to end where the first one started. Use closed() to make a loop.

Parameters:

name (str, optional) – Optional label.

Return type:

Curve

ellipse_to(end, *, center, semi_axes, major_axis, normal)#

Append an elliptical arc ending at end.

The ellipse is given by its center, its two semi-axes and the direction of the first one; the current point and end must both lie on it. Of the two arcs joining them, the one drawn runs counter-clockwise about normal — the same convention as arc_to() with center= and normal=, so reversing the direction of normal gives the complementary arc.

Parameters:
  • end (tuple of float) – End point (x, y, z) [meters], on the ellipse.

  • center (tuple of float) – Centre of the ellipse [meters].

  • semi_axes (tuple of float) – (a, b) [meters]: a along major_axis, b along normal x major_axis. Either may be the larger one — the names only say which direction each length belongs to.

  • major_axis (str or sequence of float) – Direction of the a semi-axis: 'x', 'y', 'z', or any non-zero 3-vector (its component along normal is ignored).

  • normal (str or sequence of float) – Normal of the ellipse’s plane and the sense of the arc.

Returns:

A new Path ending at end.

Return type:

Path

Raises:

ValueError – If an endpoint is off the ellipse or its plane, if a semi-axis is not positive, or if major_axis is parallel to normal.

Examples

The iris of an accelerator cell, drawn in the x-z plane (x is the radius, z the axis): a quarter turn from the z-ward end of the ellipse down to the iris radius (normal -y picks the short way round):

path.ellipse_to(
    (0.035, 0.0, 0.012),
    center=(0.054, 0.0, 0.012),
    semi_axes=(0.012, 0.019),
    major_axis="z",
    normal=(0.0, -1.0, 0.0),
)
forward(distance)#

Append a straight run along the current tangent.

Parameters:

distance (float) – Positive length in meters.

Returns:

Route with unchanged tangent and up.

Return type:

Path

line_to(point)#

Append a straight segment ending at point.

Parameters:

point (tuple of float) – End point (x, y, z) [meters].

Returns:

A new Path ending at point.

Return type:

Path

spline_to(*points)#

Append a smooth spline through points, ending at the last one.

Parameters:

*points (tuple of float) – One or more 3D points [meters]; the spline interpolates all of them in order.

Returns:

A new Path ending at the last point.

Return type:

Path

straight_to_plane(normal, position)#

Continue forward to the world plane normal dot point = position.

Parameters:
  • normal (str or sequence of float) – Plane normal, normalized before applying position.

  • position (float) – Signed plane offset from the world origin in meters.

Returns:

Route ending on the plane; an already reached plane adds no edge.

Return type:

Path

Raises:

ValueError – If the ray is parallel to the plane or the intersection is behind it.

turn_left(*, radius, angle_deg)#

Append an exact circular turn towards up x tangent.

Parameters:
  • radius (float) – Positive bend radius in meters.

  • angle_deg (float) – Positive angle strictly below 360 degrees; up is the rotation axis.

Returns:

Route with the tangent rotated and up retained.

Return type:

Path

turn_right(*, radius, angle_deg)#

Append an exact circular turn towards tangent x up.

Parameters:
  • radius (float) – Positive bend radius in meters.

  • angle_deg (float) – Positive angle strictly below 360 degrees.

Returns:

Route with the tangent rotated and up retained.

Return type:

Path

turn_to(direction, *, radius)#

Turn through the shortest circular arc to a world tangent.

Parameters:
  • direction (str or sequence of float) – Target tangent; its length is ignored.

  • radius (float) – Positive bend radius in meters.

Returns:

Route with up carried by the bend’s rigid rotation. An already aligned target returns the receiver without adding an edge.

Return type:

Path

Raises:

ValueError – If the directions are opposite (the bend plane is undetermined). Use an explicit left or right 180-degree turn instead.

property current: tuple#

The point the next segment will start from [meters].

property tangent: tuple | None#

Current unit forward direction; None before an unposed first segment.

property up: tuple | None#

Current perpendicular unit up direction; None for an unposed path.

class magnelio.geo.Profile(_outer, _holes=(), material=None, name=None)#

A bounded planar region with one outer boundary and optional holes.

Use polygon(), rectangle(), circle(), or from_wires() to construct a profile. All coordinates are world coordinates. Boundaries are closed, planar, and non-intersecting; holes lie strictly inside the outer boundary and do not nest.

An optional material is inherited by the solid produced by extrusion, revolution, sweep, or loft. Profiles themselves cannot be meshed.

Parameters:
  • _outer (object)

  • _holes (tuple)

  • material (object)

  • name (str | None)

classmethod circle(center, radius, *, normal='z', material=None, name=None)#

Return the planar disc bounded by an exact circle.

Parameters:
  • center (tuple of float) – World center [meters].

  • radius (float) – Positive radius [meters].

  • normal (str or sequence of float, optional) – Plane normal; defaults to "z".

  • material (Material or str, optional) – Material inherited by subsequent solid construction.

  • name (str, optional) – Optional label.

Returns:

The bounded circular disc.

Return type:

Profile

classmethod from_wires(outer, holes=(), *, material=None, name=None)#

Return the region inside outer, excluding all holes.

Parameters:
  • outer (Curve) – Closed planar outer boundary.

  • holes (iterable of Curve, optional) – Closed boundaries strictly inside outer. Winding is corrected automatically. Touching, intersecting, or nested holes are invalid.

  • material (Material or str, optional) – Material inherited by subsequent solid construction.

  • name (str, optional) – Optional label.

Returns:

Validated planar region, retaining analytic boundary curves.

Return type:

Profile

Raises:
  • TypeError – If any boundary is not a Curve.

  • ValueError – If boundaries are open, non-planar, intersecting, or incorrectly nested.

classmethod polygon(points, *, material=None, name=None)#

Return a planar polygon through three-dimensional world points.

Parameters:
  • points (sequence of tuple of float) – At least three coplanar vertices [meters]. Closure is automatic; an explicit repeated last vertex is also accepted.

  • material (Material or str, optional) – Material inherited by subsequent solid construction.

  • name (str, optional) – Optional label.

Returns:

The bounded polygon region.

Return type:

Profile

classmethod rectangle(center, size, *, normal='z', x_direction=None, material=None, name=None)#

Return an oriented rectangle centred at a world point.

Parameters:
  • center (tuple of float) – World center [meters].

  • size (tuple of float) – Positive width and height [meters].

  • normal (str or sequence of float, optional) – Plane normal; defaults to "z".

  • x_direction (str or sequence of float, optional) – In-plane width direction. Its normal component is discarded. Defaults to the least parallel world axis projected into the plane. Height follows normal x x_direction.

  • material (Material or str, optional) – Material inherited by subsequent solid construction.

  • name (str, optional) – Optional label.

Returns:

The bounded rectangle region.

Return type:

Profile

boundary()#

Return detached boundary Curves, outer first followed by holes.

Returns:

Independent, closed geometry values in the profile’s world placement. Tuple order fixes hole correspondence when lofting multiple profiles.

Return type:

tuple of Curve

bounding_box(scale=None)#

Return the axis-aligned bounding box of this shape.

The box is computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters — a rotated brick reports the box of the rotated solid.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

(min_corner, max_corner), each (x, y, z) in meters.

Return type:

tuple

chamfered(*, near=None, face_near=None, edges=None, faces=None, distance)#

Return a Solid with a flat bevel on selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms use semantic selection and refuse ambiguity.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • distance (float or tuple of float) – Positive bevel distance in metres, or an asymmetric pair.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

extruded(vector, *, face_near=None, material=None)#

Extrude a Sheet into an independent Solid, retaining holes.

Parameters:
  • vector (tuple of float) – Non-zero world extrusion vector in metres.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).extruded(vector). A tied pick raises AmbiguousTopologyError. Invalid on standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Materialless sections produce construction solids for Boolean use.

Returns:

Independent prism, without fusion to an input owner.

Return type:

Solid

filleted(*, near=None, face_near=None, edges=None, faces=None, radius)#

Return a Solid with rounded selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms refuse ties.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • radius (float) – Positive fillet radius in metres.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

lofted(other, *, material=None, blend='spline', tension=None)#

Connect this planar sheet to another section with a Solid.

Parameters:
  • other (Profile or Sheet or FaceRef) – Planar end section in its actual world placement. All sections need the same number of holes, matched in boundary order.

  • material (Material or str, optional) – Override this sheet’s material; otherwise it is inherited. Materialless sections produce construction solids for Boolean use.

  • blend ({'spline', 'ruled', 'tangent'}, optional) – Interpolation mode. Tangent transitions leave both oriented normals.

  • tension (float or tuple of float, optional) – Positive tangent reach fractions, only for tangent blending.

Returns:

Independent transition retaining all corresponding boundaries.

Return type:

Solid

mirrored(normal, position=0.0, *, copy=False, unite=False, group=False)#

Return this shape reflected across a plane.

The plane is the set of points p with p · normal == position, so for an axis letter position is simply the coordinate of the plane on that axis.

A reflection is not a rotation: it leaves the two in-plane directions untouched and reverses only the normal one. That is what makes it the correct operation for a structure symmetric about a plane but not about the axis normal to it — most planar circuits (dividers, couplers, filters) and every layer stack that differs from top to bottom.

Unlike translated() and rotated() there is no repeat: mirroring twice across one plane reproduces the original.

Parameters:
  • normal (str or sequence of float) – Plane normal: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored). normal='x' maps x -> 2 * position - x.

  • position (float) – Signed distance of the plane from the coordinate origin along normal [meters] (default 0).

  • copy (bool, optional) – Include the original first; defaults to False.

  • unite (bool, optional) – Return a Union of original and image. Requires copy and Solid geometry.

  • group (bool, optional) – Return a Group of original and image, retaining member materials. Requires copy; mutually exclusive with unite.

Returns:

The image alone by default, otherwise [original, image] or the explicitly requested Union or Group.

Return type:

Shape or list of Shape or Union or Group

Examples

Complete a half-modelled power divider into one solid:

full = half.mirrored("x", copy=True, unite=True)

Mirror a feed line onto the far side of a board:

far = line.mirrored("z", position=h / 2)
offset(distance)#

Dilate or erode this planar material region.

Positive distance grows the exterior and shrinks holes; negative distance erodes the exterior and enlarges holes. Corner transitions use circular arcs. Every disconnected surviving region is returned.

Parameters:

distance (float) – Signed boundary distance [meters].

Returns:

Independent regions, or an empty tuple after total collapse.

Return type:

tuple of Profile

Raises:

ValueError – If the offset boundaries become invalid.

partition(cutter=None, *, normal=None, position=None)#

Split this solid or sheet into independent connected regions.

Parameters:
  • cutter (Solid or Sheet, optional) – Geometry whose boundary partitions this shape.

  • normal (str or sequence of float, optional) – World normal of a cutting plane. Requires position and excludes cutter.

  • position (float, optional) – Signed plane offset [m], measured as normal dot point.

Returns:

Independently owned regions in kernel order. A non-cut returns one independent region. Order is not persistent across CAD edits.

Return type:

tuple of Solid or Sheet

revolved(axis, angle_deg=360.0, *, origin=(0.0, 0.0, 0.0), material=None)#

Revolve a planar Sheet into an independent Solid.

Parameters:
  • axis (str or sequence of float) – Revolution axis letter or non-zero world vector.

  • angle_deg (float, optional) – Non-zero right-handed angle, at most a full turn, in degrees.

  • origin (tuple of float, optional) – World point on the revolution axis, in metres.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

Returns:

Solid of revolution retaining all holes. A section crossing the axis can produce invalid or self-intersecting geometry.

Return type:

Solid

rotated(axis, angle_deg, origin=(0.0, 0.0, 0.0), *, repeat=1, copy=False, unite=False, group=False)#

Return this shape rotated about an axis.

Parameters:
  • axis (str or sequence of float) – Rotation axis: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored).

  • angle_deg (float) – Rotation angle [degrees], right-handed about axis. Copy i is rotated by i * angle_deg.

  • origin (tuple of float) – A point on the rotation axis (default: the coordinate origin).

  • repeat (int, optional) – Number of rotated copies at angle_deg through repeat * angle_deg; defaults to 1.

  • copy (bool, optional) – Include the unrotated original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One rotated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

Four posts at 90° spacing around the z axis:

posts = post.rotated("z", 90.0, repeat=3, copy=True, group=True)
scaled(factor, center=(0.0, 0.0, 0.0))#

Return this shape scaled uniformly about a fixed point.

The scaling is uniform in all three directions; there is no per-axis factor, because a non-uniform scaling would turn cylinders into elliptic cylinders and spheres into ellipsoids, which the primitives cannot represent.

Parameters:
  • factor (float) – Uniform scale factor. Note that this is not a way to mirror a shape: a negative factor inverts the shape through center, negating all three axes at once. Use mirrored() for a reflection.

  • center (tuple of float) – Fixed point of the scaling (default: the coordinate origin).

Returns:

The scaled shape; a Group is scaled member by member about the common center.

Return type:

Shape or Group

section(cutter=None, *, normal=None, position=None, filled=False)#

Intersect this solid or sheet with a cutter or world plane.

Parameters:
  • cutter (Solid or Sheet, optional) – Intersecting geometry; excludes a plane declaration.

  • normal (str or sequence of float, optional) – World plane normal; requires position.

  • position (float, optional) – Signed world plane offset [m].

  • filled (bool, optional) – Return planar Profiles with holes instead of boundary Curves. Requires a Solid receiver and an explicit plane.

Returns:

Independent intersection geometry. No intersection returns an empty tuple. A coincident face raises rather than choosing a one-dimensional interpretation.

Return type:

tuple of Curve or Profile

shelled(thickness, *, opening_face_near=None, openings=None)#

Hollow this Solid inward to a constant wall thickness.

Parameters:
  • thickness (float) – Positive wall thickness in metres. The outer footprint is retained.

  • opening_face_near (tuple or list of tuple, optional) – World points selecting temporary face references to leave open. Tied picks raise. Mutually exclusive with openings.

  • openings (FaceRef or FaceSetRef or sequence, optional) – Owned faces to leave open; must belong to this exact receiver. Omit both selection modes for a sealed internal void.

Returns:

Hollow body with inherited material.

Return type:

Solid

Raises:
  • TypeError – For a non-Solid receiver; grow a sheet with thickened() instead.

  • RuntimeError – If the offset cannot form a valid closed body.

swept(spine, *, face_near=None, material=None, frame='corrected_frenet', binormal=None, twist_deg=0.0, draft_deg=0.0, tolerance=None)#

Sweep a planar Sheet along a Curve into an independent Solid.

The actual boundary is translated to the spine start and aligned by the shortest normal-to-tangent rotation, retaining in-plane roll. An already aligned section stays in its actual orientation. For an opposite normal, the section plane’s X axis defines the half-turn. The pipe follows corrected Frenet transport unless another frame is selected explicitly.

Parameters:
  • spine (Curve) – World sweep path.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).swept(spine). Tied picks raise. Invalid for standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

  • frame ({'corrected_frenet', 'frenet', 'fixed', 'fixed_binormal'}, optional) – Transport of the initially aligned section. The default retains corrected Frenet transport. Frenet follows curvature and torsion; fixed keeps sections parallel in world space. Fixed binormal preserves their angular relation to the supplied world direction.

  • binormal (str or tuple of float, optional) – Required only for fixed binormal transport. Must not be parallel to the spine tangent. Path’s up direction does not set this value.

  • twist_deg (float, optional) – Total additional right-hand roll about the transported section normal [degrees], distributed uniformly over spine arc length.

  • draft_deg (float, optional) – Constant section-offset angle [degrees], strictly between -90 and 90. Offset equals travelled arc length times its tangent. Positive values expand the exterior and shrink holes. For perpendicular straight sections this is the wall angle to the sweep direction.

  • tolerance (float, optional) – Sampled section-fitting tolerance [m] for nonzero twist or draft. Defaults to one millionth of the initial profile diagonal.

Returns:

Independent pipe retaining the section’s holes.

Return type:

Solid

thickened(thickness, *, direction='forward', material=None)#

Grow this sheet into a solid of constant thickness.

A Sheet, including a planar Profile or curved Surface, can be thickened. A planar sheet becomes a slab whose footprint is exactly the sheet, which makes this the direct way from a drawn outline to a metallisation of a given thickness, without spelling out the extrusion vector. A curved sheet is offset along its own normal into a shell of constant thickness. An unsuitable thickness, curvature or sampled surface can prevent the CAD kernel from building a valid offset.

Parameters:
  • thickness (float) – Slab thickness [meters], positive.

  • direction ({"forward", "backward", "symmetric"}) – Which side of the sheet to grow on. "symmetric" puts half the thickness on each side, leaving the sheet as the slab’s mid-plane (planar sheets only). "forward" and "backward" are opposite sides of it; forward follows the oriented sheet normal. For a FaceRef, forward follows its outward normal.

  • material (Material or str, optional) – Material of the slab. Defaults to the sheet’s material. A materialless sheet produces a construction solid for Boolean use.

Returns:

The solid slab.

Return type:

Solid

Raises:
  • TypeError – If this is a solid — use shelled() instead.

  • ValueError – If the thickness or direction is invalid, or symmetric thickening is requested for a curved sheet.

Examples

A copper patch from a drawn outline:

patch = Profile.from_wires(outline).thickened(thickness=35e-6, material=copper)
translated(vector, *, repeat=1, copy=False, unite=False, group=False)#

Return this shape moved by vector.

Parameters:
  • vector (tuple of float) – (dx, dy, dz) translation [meters].

  • repeat (int, optional) – Number of translated copies, starting at one vector displacement. Copy i is moved by i * vector; defaults to 1.

  • copy (bool, optional) – Include the untransformed original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One translated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

A row of eight vias, including the original, fused into one body:

fence = via.translated((2e-3, 0, 0), repeat=7, copy=True, unite=True)
volume(scale=None)#

Return the volume enclosed by this shape.

Computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters: a Boolean difference reports what is left, and a chamfered block reports what the chamfer took away. That makes it the direct way to check a construction — a filling factor, a metal volume, the agreement between two ways of building the same part.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

Volume in cubic meters. A planar sheet (Profile) has no thickness and reports zero.

Return type:

float

Examples

The fraction of a housing that is metal:

fill = shell.volume() / block.volume()
property area#

Area of the planar region, excluding holes [square meters].

class magnelio.geo.Rotation(axis, angle_deg, origin=(0.0, 0.0, 0.0))#

Right-handed rotation about an axis through an origin.

Parameters:
  • axis (str or tuple of float) – "x", "y", "z" or an arbitrary direction vector.

  • angle_deg (float) – Right-handed rotation angle [degrees].

  • origin (tuple of float) – Point on the rotation axis [meters].

classmethod identity()#

Return the identity transform.

Return type:

Transform

point(point)#

Return point transformed by this affine value.

Return type:

tuple[float, float, float]

class magnelio.geo.Scale(factor, center=(0.0, 0.0, 0.0))#

Uniform scale about a fixed center.

Parameters:
  • factor (float) – Non-zero uniform scale factor.

  • center (tuple of float) – Fixed point of the scale [meters].

classmethod identity()#

Return the identity transform.

Return type:

Transform

point(point)#

Return point transformed by this affine value.

Return type:

tuple[float, float, float]

class magnelio.geo.Shape#

Base class of immutable standalone geometry.

Every standalone geometry object is a Shape. Shape is a base type, not something to instantiate directly; use one of its dimensional subclasses.

Shapes are immutable. Every operator and verb returns a new shape; the receiver is never modified. That is what makes the calls chainable:

pin = Cylinder(radius=0.5e-3, height=4e-3, material=pec)
part = pin.rotated("y", 90.0).translated((0, 0, 1e-3)) - hole

Materials follow the base operand. A Boolean result takes the material of its base (Difference) resp. first (Union, Intersection) operand, and a transformed shape keeps the material of the shape it came from. Tools and profiles therefore need no material of their own — see Brick for construction bodies.

The dimensional subclasses are Curve, Sheet (including Profile) and Solid. Every category supports the same four affine transforms. Boolean operations are restricted to Solid values.

bounding_box(scale=None)#

Return the axis-aligned bounding box of this shape.

The box is computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters — a rotated brick reports the box of the rotated solid.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

(min_corner, max_corner), each (x, y, z) in meters.

Return type:

tuple

chamfered(*, near=None, face_near=None, edges=None, faces=None, distance)#

Return a Solid with a flat bevel on selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms use semantic selection and refuse ambiguity.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • distance (float or tuple of float) – Positive bevel distance in metres, or an asymmetric pair.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

extruded(vector, *, face_near=None, material=None)#

Extrude a Sheet into an independent Solid, retaining holes.

Parameters:
  • vector (tuple of float) – Non-zero world extrusion vector in metres.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).extruded(vector). A tied pick raises AmbiguousTopologyError. Invalid on standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Materialless sections produce construction solids for Boolean use.

Returns:

Independent prism, without fusion to an input owner.

Return type:

Solid

filleted(*, near=None, face_near=None, edges=None, faces=None, radius)#

Return a Solid with rounded selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms refuse ties.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • radius (float) – Positive fillet radius in metres.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

lofted(face_near, other=None, other_face_near=None, *, material=None, blend='spline', tension=None)#

Connect this section to another with an independent Solid.

For sheets, use section.lofted(other_section). Suitable FaceRef values provide the same verb. All boundaries contribute, and hole counts must agree. The retained Solid convenience is body.lofted(face_near, other_body, other_face_near); its temporary FaceRefs use semantic selection and refuse tied picks.

Parameters:
  • face_near (Profile or Sheet or FaceRef or tuple) – Planar end section for a Sheet receiver. For the Solid convenience, a world point in metres selecting its start face.

  • other (Solid, optional) – End owner for the Solid point convenience only.

  • other_face_near (tuple of float, optional) – World point selecting the end face for the Solid convenience.

  • material (Material or str, optional) – Override the start section’s material. Without a material the result is a construction solid.

  • blend ({'spline', 'ruled', 'tangent'}, optional) – Smooth or straight interpolation, or a transition leaving both oriented normals. Tangent mode requires faces looking towards each other and retains holes with the same spine conditions.

  • tension (float or tuple of float, optional) – Positive finite tangent reach fractions, only in tangent mode. Defaults to one third at each end.

Returns:

Independent transition matching corresponding boundaries.

Return type:

Solid

mirrored(normal, position=0.0, *, copy=False, unite=False, group=False)#

Return this shape reflected across a plane.

The plane is the set of points p with p · normal == position, so for an axis letter position is simply the coordinate of the plane on that axis.

A reflection is not a rotation: it leaves the two in-plane directions untouched and reverses only the normal one. That is what makes it the correct operation for a structure symmetric about a plane but not about the axis normal to it — most planar circuits (dividers, couplers, filters) and every layer stack that differs from top to bottom.

Unlike translated() and rotated() there is no repeat: mirroring twice across one plane reproduces the original.

Parameters:
  • normal (str or sequence of float) – Plane normal: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored). normal='x' maps x -> 2 * position - x.

  • position (float) – Signed distance of the plane from the coordinate origin along normal [meters] (default 0).

  • copy (bool, optional) – Include the original first; defaults to False.

  • unite (bool, optional) – Return a Union of original and image. Requires copy and Solid geometry.

  • group (bool, optional) – Return a Group of original and image, retaining member materials. Requires copy; mutually exclusive with unite.

Returns:

The image alone by default, otherwise [original, image] or the explicitly requested Union or Group.

Return type:

Shape or list of Shape or Union or Group

Examples

Complete a half-modelled power divider into one solid:

full = half.mirrored("x", copy=True, unite=True)

Mirror a feed line onto the far side of a board:

far = line.mirrored("z", position=h / 2)
partition(cutter=None, *, normal=None, position=None)#

Split this solid or sheet into independent connected regions.

Parameters:
  • cutter (Solid or Sheet, optional) – Geometry whose boundary partitions this shape.

  • normal (str or sequence of float, optional) – World normal of a cutting plane. Requires position and excludes cutter.

  • position (float, optional) – Signed plane offset [m], measured as normal dot point.

Returns:

Independently owned regions in kernel order. A non-cut returns one independent region. Order is not persistent across CAD edits.

Return type:

tuple of Solid or Sheet

revolved(axis, angle_deg=360.0, *, origin=(0.0, 0.0, 0.0), material=None)#

Revolve a planar Sheet into an independent Solid.

Parameters:
  • axis (str or sequence of float) – Revolution axis letter or non-zero world vector.

  • angle_deg (float, optional) – Non-zero right-handed angle, at most a full turn, in degrees.

  • origin (tuple of float, optional) – World point on the revolution axis, in metres.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

Returns:

Solid of revolution retaining all holes. A section crossing the axis can produce invalid or self-intersecting geometry.

Return type:

Solid

rotated(axis, angle_deg, origin=(0.0, 0.0, 0.0), *, repeat=1, copy=False, unite=False, group=False)#

Return this shape rotated about an axis.

Parameters:
  • axis (str or sequence of float) – Rotation axis: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored).

  • angle_deg (float) – Rotation angle [degrees], right-handed about axis. Copy i is rotated by i * angle_deg.

  • origin (tuple of float) – A point on the rotation axis (default: the coordinate origin).

  • repeat (int, optional) – Number of rotated copies at angle_deg through repeat * angle_deg; defaults to 1.

  • copy (bool, optional) – Include the unrotated original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One rotated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

Four posts at 90° spacing around the z axis:

posts = post.rotated("z", 90.0, repeat=3, copy=True, group=True)
scaled(factor, center=(0.0, 0.0, 0.0))#

Return this shape scaled uniformly about a fixed point.

The scaling is uniform in all three directions; there is no per-axis factor, because a non-uniform scaling would turn cylinders into elliptic cylinders and spheres into ellipsoids, which the primitives cannot represent.

Parameters:
  • factor (float) – Uniform scale factor. Note that this is not a way to mirror a shape: a negative factor inverts the shape through center, negating all three axes at once. Use mirrored() for a reflection.

  • center (tuple of float) – Fixed point of the scaling (default: the coordinate origin).

Returns:

The scaled shape; a Group is scaled member by member about the common center.

Return type:

Shape or Group

section(cutter=None, *, normal=None, position=None, filled=False)#

Intersect this solid or sheet with a cutter or world plane.

Parameters:
  • cutter (Solid or Sheet, optional) – Intersecting geometry; excludes a plane declaration.

  • normal (str or sequence of float, optional) – World plane normal; requires position.

  • position (float, optional) – Signed world plane offset [m].

  • filled (bool, optional) – Return planar Profiles with holes instead of boundary Curves. Requires a Solid receiver and an explicit plane.

Returns:

Independent intersection geometry. No intersection returns an empty tuple. A coincident face raises rather than choosing a one-dimensional interpretation.

Return type:

tuple of Curve or Profile

shelled(thickness, *, opening_face_near=None, openings=None)#

Hollow this Solid inward to a constant wall thickness.

Parameters:
  • thickness (float) – Positive wall thickness in metres. The outer footprint is retained.

  • opening_face_near (tuple or list of tuple, optional) – World points selecting temporary face references to leave open. Tied picks raise. Mutually exclusive with openings.

  • openings (FaceRef or FaceSetRef or sequence, optional) – Owned faces to leave open; must belong to this exact receiver. Omit both selection modes for a sealed internal void.

Returns:

Hollow body with inherited material.

Return type:

Solid

Raises:
  • TypeError – For a non-Solid receiver; grow a sheet with thickened() instead.

  • RuntimeError – If the offset cannot form a valid closed body.

swept(spine, *, face_near=None, material=None, frame='corrected_frenet', binormal=None, twist_deg=0.0, draft_deg=0.0, tolerance=None)#

Sweep a planar Sheet along a Curve into an independent Solid.

The actual boundary is translated to the spine start and aligned by the shortest normal-to-tangent rotation, retaining in-plane roll. An already aligned section stays in its actual orientation. For an opposite normal, the section plane’s X axis defines the half-turn. The pipe follows corrected Frenet transport unless another frame is selected explicitly.

Parameters:
  • spine (Curve) – World sweep path.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).swept(spine). Tied picks raise. Invalid for standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

  • frame ({'corrected_frenet', 'frenet', 'fixed', 'fixed_binormal'}, optional) – Transport of the initially aligned section. The default retains corrected Frenet transport. Frenet follows curvature and torsion; fixed keeps sections parallel in world space. Fixed binormal preserves their angular relation to the supplied world direction.

  • binormal (str or tuple of float, optional) – Required only for fixed binormal transport. Must not be parallel to the spine tangent. Path’s up direction does not set this value.

  • twist_deg (float, optional) – Total additional right-hand roll about the transported section normal [degrees], distributed uniformly over spine arc length.

  • draft_deg (float, optional) – Constant section-offset angle [degrees], strictly between -90 and 90. Offset equals travelled arc length times its tangent. Positive values expand the exterior and shrink holes. For perpendicular straight sections this is the wall angle to the sweep direction.

  • tolerance (float, optional) – Sampled section-fitting tolerance [m] for nonzero twist or draft. Defaults to one millionth of the initial profile diagonal.

Returns:

Independent pipe retaining the section’s holes.

Return type:

Solid

thickened(thickness, *, direction='forward', material=None)#

Grow this sheet into a solid of constant thickness.

A Sheet, including a planar Profile or curved Surface, can be thickened. A planar sheet becomes a slab whose footprint is exactly the sheet, which makes this the direct way from a drawn outline to a metallisation of a given thickness, without spelling out the extrusion vector. A curved sheet is offset along its own normal into a shell of constant thickness. An unsuitable thickness, curvature or sampled surface can prevent the CAD kernel from building a valid offset.

Parameters:
  • thickness (float) – Slab thickness [meters], positive.

  • direction ({"forward", "backward", "symmetric"}) – Which side of the sheet to grow on. "symmetric" puts half the thickness on each side, leaving the sheet as the slab’s mid-plane (planar sheets only). "forward" and "backward" are opposite sides of it; forward follows the oriented sheet normal. For a FaceRef, forward follows its outward normal.

  • material (Material or str, optional) – Material of the slab. Defaults to the sheet’s material. A materialless sheet produces a construction solid for Boolean use.

Returns:

The solid slab.

Return type:

Solid

Raises:
  • TypeError – If this is a solid — use shelled() instead.

  • ValueError – If the thickness or direction is invalid, or symmetric thickening is requested for a curved sheet.

Examples

A copper patch from a drawn outline:

patch = Profile.from_wires(outline).thickened(thickness=35e-6, material=copper)
translated(vector, *, repeat=1, copy=False, unite=False, group=False)#

Return this shape moved by vector.

Parameters:
  • vector (tuple of float) – (dx, dy, dz) translation [meters].

  • repeat (int, optional) – Number of translated copies, starting at one vector displacement. Copy i is moved by i * vector; defaults to 1.

  • copy (bool, optional) – Include the untransformed original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One translated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

A row of eight vias, including the original, fused into one body:

fence = via.translated((2e-3, 0, 0), repeat=7, copy=True, unite=True)
volume(scale=None)#

Return the volume enclosed by this shape.

Computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters: a Boolean difference reports what is left, and a chamfered block reports what the chamfer took away. That makes it the direct way to check a construction — a filling factor, a metal volume, the agreement between two ways of building the same part.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

Volume in cubic meters. A planar sheet (Profile) has no thickness and reports zero.

Return type:

float

Examples

The fraction of a housing that is metal:

fill = shell.volume() / block.volume()
class magnelio.geo.Sheet#

Base class of zero-thickness planar and curved sheets.

Sheets can be extruded or thickened into solids. A standalone sheet cannot yet be meshed; give it a resolved physical thickness first.

bounding_box(scale=None)#

Return the axis-aligned bounding box of this shape.

The box is computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters — a rotated brick reports the box of the rotated solid.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

(min_corner, max_corner), each (x, y, z) in meters.

Return type:

tuple

chamfered(*, near=None, face_near=None, edges=None, faces=None, distance)#

Return a Solid with a flat bevel on selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms use semantic selection and refuse ambiguity.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • distance (float or tuple of float) – Positive bevel distance in metres, or an asymmetric pair.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

extruded(vector, *, face_near=None, material=None)#

Extrude a Sheet into an independent Solid, retaining holes.

Parameters:
  • vector (tuple of float) – Non-zero world extrusion vector in metres.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).extruded(vector). A tied pick raises AmbiguousTopologyError. Invalid on standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Materialless sections produce construction solids for Boolean use.

Returns:

Independent prism, without fusion to an input owner.

Return type:

Solid

filleted(*, near=None, face_near=None, edges=None, faces=None, radius)#

Return a Solid with rounded selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms refuse ties.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • radius (float) – Positive fillet radius in metres.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

lofted(other, *, material=None, blend='spline', tension=None)#

Connect this planar sheet to another section with a Solid.

Parameters:
  • other (Profile or Sheet or FaceRef) – Planar end section in its actual world placement. All sections need the same number of holes, matched in boundary order.

  • material (Material or str, optional) – Override this sheet’s material; otherwise it is inherited. Materialless sections produce construction solids for Boolean use.

  • blend ({'spline', 'ruled', 'tangent'}, optional) – Interpolation mode. Tangent transitions leave both oriented normals.

  • tension (float or tuple of float, optional) – Positive tangent reach fractions, only for tangent blending.

Returns:

Independent transition retaining all corresponding boundaries.

Return type:

Solid

mirrored(normal, position=0.0, *, copy=False, unite=False, group=False)#

Return this shape reflected across a plane.

The plane is the set of points p with p · normal == position, so for an axis letter position is simply the coordinate of the plane on that axis.

A reflection is not a rotation: it leaves the two in-plane directions untouched and reverses only the normal one. That is what makes it the correct operation for a structure symmetric about a plane but not about the axis normal to it — most planar circuits (dividers, couplers, filters) and every layer stack that differs from top to bottom.

Unlike translated() and rotated() there is no repeat: mirroring twice across one plane reproduces the original.

Parameters:
  • normal (str or sequence of float) – Plane normal: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored). normal='x' maps x -> 2 * position - x.

  • position (float) – Signed distance of the plane from the coordinate origin along normal [meters] (default 0).

  • copy (bool, optional) – Include the original first; defaults to False.

  • unite (bool, optional) – Return a Union of original and image. Requires copy and Solid geometry.

  • group (bool, optional) – Return a Group of original and image, retaining member materials. Requires copy; mutually exclusive with unite.

Returns:

The image alone by default, otherwise [original, image] or the explicitly requested Union or Group.

Return type:

Shape or list of Shape or Union or Group

Examples

Complete a half-modelled power divider into one solid:

full = half.mirrored("x", copy=True, unite=True)

Mirror a feed line onto the far side of a board:

far = line.mirrored("z", position=h / 2)
offset(distance, *, tolerance=None)#

Return a curved sheet shifted along its oriented normal.

Positive distance follows the sheet normal; negative distance goes to the opposite side. The actual trimmed boundary moves with the sheet. This operation does not give a sheet physical thickness.

Parameters:
  • distance (float) – Signed normal distance [meters].

  • tolerance (float, optional) – Maximum sampled geometric deviation [meters]. Defaults to one millionth of the sheet extent, subject to the CAD resolution.

Returns:

Independent offset sheet in a tuple.

Return type:

tuple of Surface

Raises:

ValueError – If the normal offset folds, becomes singular, or exceeds the geometric tolerance.

partition(cutter=None, *, normal=None, position=None)#

Split this solid or sheet into independent connected regions.

Parameters:
  • cutter (Solid or Sheet, optional) – Geometry whose boundary partitions this shape.

  • normal (str or sequence of float, optional) – World normal of a cutting plane. Requires position and excludes cutter.

  • position (float, optional) – Signed plane offset [m], measured as normal dot point.

Returns:

Independently owned regions in kernel order. A non-cut returns one independent region. Order is not persistent across CAD edits.

Return type:

tuple of Solid or Sheet

revolved(axis, angle_deg=360.0, *, origin=(0.0, 0.0, 0.0), material=None)#

Revolve a planar Sheet into an independent Solid.

Parameters:
  • axis (str or sequence of float) – Revolution axis letter or non-zero world vector.

  • angle_deg (float, optional) – Non-zero right-handed angle, at most a full turn, in degrees.

  • origin (tuple of float, optional) – World point on the revolution axis, in metres.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

Returns:

Solid of revolution retaining all holes. A section crossing the axis can produce invalid or self-intersecting geometry.

Return type:

Solid

rotated(axis, angle_deg, origin=(0.0, 0.0, 0.0), *, repeat=1, copy=False, unite=False, group=False)#

Return this shape rotated about an axis.

Parameters:
  • axis (str or sequence of float) – Rotation axis: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored).

  • angle_deg (float) – Rotation angle [degrees], right-handed about axis. Copy i is rotated by i * angle_deg.

  • origin (tuple of float) – A point on the rotation axis (default: the coordinate origin).

  • repeat (int, optional) – Number of rotated copies at angle_deg through repeat * angle_deg; defaults to 1.

  • copy (bool, optional) – Include the unrotated original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One rotated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

Four posts at 90° spacing around the z axis:

posts = post.rotated("z", 90.0, repeat=3, copy=True, group=True)
scaled(factor, center=(0.0, 0.0, 0.0))#

Return this shape scaled uniformly about a fixed point.

The scaling is uniform in all three directions; there is no per-axis factor, because a non-uniform scaling would turn cylinders into elliptic cylinders and spheres into ellipsoids, which the primitives cannot represent.

Parameters:
  • factor (float) – Uniform scale factor. Note that this is not a way to mirror a shape: a negative factor inverts the shape through center, negating all three axes at once. Use mirrored() for a reflection.

  • center (tuple of float) – Fixed point of the scaling (default: the coordinate origin).

Returns:

The scaled shape; a Group is scaled member by member about the common center.

Return type:

Shape or Group

section(cutter=None, *, normal=None, position=None, filled=False)#

Intersect this solid or sheet with a cutter or world plane.

Parameters:
  • cutter (Solid or Sheet, optional) – Intersecting geometry; excludes a plane declaration.

  • normal (str or sequence of float, optional) – World plane normal; requires position.

  • position (float, optional) – Signed world plane offset [m].

  • filled (bool, optional) – Return planar Profiles with holes instead of boundary Curves. Requires a Solid receiver and an explicit plane.

Returns:

Independent intersection geometry. No intersection returns an empty tuple. A coincident face raises rather than choosing a one-dimensional interpretation.

Return type:

tuple of Curve or Profile

shelled(thickness, *, opening_face_near=None, openings=None)#

Hollow this Solid inward to a constant wall thickness.

Parameters:
  • thickness (float) – Positive wall thickness in metres. The outer footprint is retained.

  • opening_face_near (tuple or list of tuple, optional) – World points selecting temporary face references to leave open. Tied picks raise. Mutually exclusive with openings.

  • openings (FaceRef or FaceSetRef or sequence, optional) – Owned faces to leave open; must belong to this exact receiver. Omit both selection modes for a sealed internal void.

Returns:

Hollow body with inherited material.

Return type:

Solid

Raises:
  • TypeError – For a non-Solid receiver; grow a sheet with thickened() instead.

  • RuntimeError – If the offset cannot form a valid closed body.

swept(spine, *, face_near=None, material=None, frame='corrected_frenet', binormal=None, twist_deg=0.0, draft_deg=0.0, tolerance=None)#

Sweep a planar Sheet along a Curve into an independent Solid.

The actual boundary is translated to the spine start and aligned by the shortest normal-to-tangent rotation, retaining in-plane roll. An already aligned section stays in its actual orientation. For an opposite normal, the section plane’s X axis defines the half-turn. The pipe follows corrected Frenet transport unless another frame is selected explicitly.

Parameters:
  • spine (Curve) – World sweep path.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).swept(spine). Tied picks raise. Invalid for standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

  • frame ({'corrected_frenet', 'frenet', 'fixed', 'fixed_binormal'}, optional) – Transport of the initially aligned section. The default retains corrected Frenet transport. Frenet follows curvature and torsion; fixed keeps sections parallel in world space. Fixed binormal preserves their angular relation to the supplied world direction.

  • binormal (str or tuple of float, optional) – Required only for fixed binormal transport. Must not be parallel to the spine tangent. Path’s up direction does not set this value.

  • twist_deg (float, optional) – Total additional right-hand roll about the transported section normal [degrees], distributed uniformly over spine arc length.

  • draft_deg (float, optional) – Constant section-offset angle [degrees], strictly between -90 and 90. Offset equals travelled arc length times its tangent. Positive values expand the exterior and shrink holes. For perpendicular straight sections this is the wall angle to the sweep direction.

  • tolerance (float, optional) – Sampled section-fitting tolerance [m] for nonzero twist or draft. Defaults to one millionth of the initial profile diagonal.

Returns:

Independent pipe retaining the section’s holes.

Return type:

Solid

thickened(thickness, *, direction='forward', material=None)#

Grow this sheet into a solid of constant thickness.

A Sheet, including a planar Profile or curved Surface, can be thickened. A planar sheet becomes a slab whose footprint is exactly the sheet, which makes this the direct way from a drawn outline to a metallisation of a given thickness, without spelling out the extrusion vector. A curved sheet is offset along its own normal into a shell of constant thickness. An unsuitable thickness, curvature or sampled surface can prevent the CAD kernel from building a valid offset.

Parameters:
  • thickness (float) – Slab thickness [meters], positive.

  • direction ({"forward", "backward", "symmetric"}) – Which side of the sheet to grow on. "symmetric" puts half the thickness on each side, leaving the sheet as the slab’s mid-plane (planar sheets only). "forward" and "backward" are opposite sides of it; forward follows the oriented sheet normal. For a FaceRef, forward follows its outward normal.

  • material (Material or str, optional) – Material of the slab. Defaults to the sheet’s material. A materialless sheet produces a construction solid for Boolean use.

Returns:

The solid slab.

Return type:

Solid

Raises:
  • TypeError – If this is a solid — use shelled() instead.

  • ValueError – If the thickness or direction is invalid, or symmetric thickening is requested for a curved sheet.

Examples

A copper patch from a drawn outline:

patch = Profile.from_wires(outline).thickened(thickness=35e-6, material=copper)
translated(vector, *, repeat=1, copy=False, unite=False, group=False)#

Return this shape moved by vector.

Parameters:
  • vector (tuple of float) – (dx, dy, dz) translation [meters].

  • repeat (int, optional) – Number of translated copies, starting at one vector displacement. Copy i is moved by i * vector; defaults to 1.

  • copy (bool, optional) – Include the untransformed original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One translated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

A row of eight vias, including the original, fused into one body:

fence = via.translated((2e-3, 0, 0), repeat=7, copy=True, unite=True)
volume(scale=None)#

Return the volume enclosed by this shape.

Computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters: a Boolean difference reports what is left, and a chamfered block reports what the chamfer took away. That makes it the direct way to check a construction — a filling factor, a metal volume, the agreement between two ways of building the same part.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

Volume in cubic meters. A planar sheet (Profile) has no thickness and reports zero.

Return type:

float

Examples

The fraction of a housing that is metal:

fill = shell.volume() / block.volume()
class magnelio.geo.Solid#

Base class of closed three-dimensional bodies.

Primitive bodies, imported CAD, Boolean results and construction results derive from this category. Boolean union, difference and intersection accept only Solid operands.

bounding_box(scale=None)#

Return the axis-aligned bounding box of this shape.

The box is computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters — a rotated brick reports the box of the rotated solid.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

(min_corner, max_corner), each (x, y, z) in meters.

Return type:

tuple

chamfered(*, near=None, face_near=None, edges=None, faces=None, distance)#

Return a Solid with a flat bevel on selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms use semantic selection and refuse ambiguity.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • distance (float or tuple of float) – Positive bevel distance in metres, or an asymmetric pair.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

edge(name=None, *, near=None, curve_type=None)#

Select one owned edge, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

EdgeRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

edges(name=None, *, near=None, curve_type=None)#

Select a deliberate set of owned edges, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered set selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

Read-only view bound to this Solid. With no constraints, selects all members.

Return type:

EdgeSetRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

extruded(vector, *, face_near=None, material=None)#

Extrude a Sheet into an independent Solid, retaining holes.

Parameters:
  • vector (tuple of float) – Non-zero world extrusion vector in metres.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).extruded(vector). A tied pick raises AmbiguousTopologyError. Invalid on standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Materialless sections produce construction solids for Boolean use.

Returns:

Independent prism, without fusion to an input owner.

Return type:

Solid

face(name=None, *, near=None, normal=None, surface_type=None)#

Select one owned face, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

FaceRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

faces(name=None, *, near=None, normal=None, surface_type=None)#

Select a deliberate set of owned faces, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered set selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

Read-only view bound to this Solid. With no constraints, selects all members.

Return type:

FaceSetRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

filleted(*, near=None, face_near=None, edges=None, faces=None, radius)#

Return a Solid with rounded selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms refuse ties.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • radius (float) – Positive fillet radius in metres.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

imprinted(cutter)#

Split this body’s boundary faces along a cutter’s intersection.

The receiver keeps its volume and material. Only its boundary topology changes; the cutter remains an independent shape.

Parameters:

cutter (Solid or Sheet) – Shape whose intersection curves split the receiver’s faces.

Returns:

An independent body with imprinted boundary faces.

Return type:

Solid

Raises:

TopologyEvolutionError – If a singular named selection splits or loses its identity.

lofted(face_near, other=None, other_face_near=None, *, material=None, blend='spline', tension=None)#

Connect this section to another with an independent Solid.

For sheets, use section.lofted(other_section). Suitable FaceRef values provide the same verb. All boundaries contribute, and hole counts must agree. The retained Solid convenience is body.lofted(face_near, other_body, other_face_near); its temporary FaceRefs use semantic selection and refuse tied picks.

Parameters:
  • face_near (Profile or Sheet or FaceRef or tuple) – Planar end section for a Sheet receiver. For the Solid convenience, a world point in metres selecting its start face.

  • other (Solid, optional) – End owner for the Solid point convenience only.

  • other_face_near (tuple of float, optional) – World point selecting the end face for the Solid convenience.

  • material (Material or str, optional) – Override the start section’s material. Without a material the result is a construction solid.

  • blend ({'spline', 'ruled', 'tangent'}, optional) – Smooth or straight interpolation, or a transition leaving both oriented normals. Tangent mode requires faces looking towards each other and retains holes with the same spine conditions.

  • tension (float or tuple of float, optional) – Positive finite tangent reach fractions, only in tangent mode. Defaults to one third at each end.

Returns:

Independent transition matching corresponding boundaries.

Return type:

Solid

mirrored(normal, position=0.0, *, copy=False, unite=False, group=False)#

Return this shape reflected across a plane.

The plane is the set of points p with p · normal == position, so for an axis letter position is simply the coordinate of the plane on that axis.

A reflection is not a rotation: it leaves the two in-plane directions untouched and reverses only the normal one. That is what makes it the correct operation for a structure symmetric about a plane but not about the axis normal to it — most planar circuits (dividers, couplers, filters) and every layer stack that differs from top to bottom.

Unlike translated() and rotated() there is no repeat: mirroring twice across one plane reproduces the original.

Parameters:
  • normal (str or sequence of float) – Plane normal: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored). normal='x' maps x -> 2 * position - x.

  • position (float) – Signed distance of the plane from the coordinate origin along normal [meters] (default 0).

  • copy (bool, optional) – Include the original first; defaults to False.

  • unite (bool, optional) – Return a Union of original and image. Requires copy and Solid geometry.

  • group (bool, optional) – Return a Group of original and image, retaining member materials. Requires copy; mutually exclusive with unite.

Returns:

The image alone by default, otherwise [original, image] or the explicitly requested Union or Group.

Return type:

Shape or list of Shape or Union or Group

Examples

Complete a half-modelled power divider into one solid:

full = half.mirrored("x", copy=True, unite=True)

Mirror a feed line onto the far side of a board:

far = line.mirrored("z", position=h / 2)
partition(cutter=None, *, normal=None, position=None)#

Split this solid or sheet into independent connected regions.

Parameters:
  • cutter (Solid or Sheet, optional) – Geometry whose boundary partitions this shape.

  • normal (str or sequence of float, optional) – World normal of a cutting plane. Requires position and excludes cutter.

  • position (float, optional) – Signed plane offset [m], measured as normal dot point.

Returns:

Independently owned regions in kernel order. A non-cut returns one independent region. Order is not persistent across CAD edits.

Return type:

tuple of Solid or Sheet

revolved(axis, angle_deg=360.0, *, origin=(0.0, 0.0, 0.0), material=None)#

Revolve a planar Sheet into an independent Solid.

Parameters:
  • axis (str or sequence of float) – Revolution axis letter or non-zero world vector.

  • angle_deg (float, optional) – Non-zero right-handed angle, at most a full turn, in degrees.

  • origin (tuple of float, optional) – World point on the revolution axis, in metres.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

Returns:

Solid of revolution retaining all holes. A section crossing the axis can produce invalid or self-intersecting geometry.

Return type:

Solid

rotated(axis, angle_deg, origin=(0.0, 0.0, 0.0), *, repeat=1, copy=False, unite=False, group=False)#

Return this shape rotated about an axis.

Parameters:
  • axis (str or sequence of float) – Rotation axis: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored).

  • angle_deg (float) – Rotation angle [degrees], right-handed about axis. Copy i is rotated by i * angle_deg.

  • origin (tuple of float) – A point on the rotation axis (default: the coordinate origin).

  • repeat (int, optional) – Number of rotated copies at angle_deg through repeat * angle_deg; defaults to 1.

  • copy (bool, optional) – Include the unrotated original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One rotated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

Four posts at 90° spacing around the z axis:

posts = post.rotated("z", 90.0, repeat=3, copy=True, group=True)
scaled(factor, center=(0.0, 0.0, 0.0))#

Return this shape scaled uniformly about a fixed point.

The scaling is uniform in all three directions; there is no per-axis factor, because a non-uniform scaling would turn cylinders into elliptic cylinders and spheres into ellipsoids, which the primitives cannot represent.

Parameters:
  • factor (float) – Uniform scale factor. Note that this is not a way to mirror a shape: a negative factor inverts the shape through center, negating all three axes at once. Use mirrored() for a reflection.

  • center (tuple of float) – Fixed point of the scaling (default: the coordinate origin).

Returns:

The scaled shape; a Group is scaled member by member about the common center.

Return type:

Shape or Group

section(cutter=None, *, normal=None, position=None, filled=False)#

Intersect this solid or sheet with a cutter or world plane.

Parameters:
  • cutter (Solid or Sheet, optional) – Intersecting geometry; excludes a plane declaration.

  • normal (str or sequence of float, optional) – World plane normal; requires position.

  • position (float, optional) – Signed world plane offset [m].

  • filled (bool, optional) – Return planar Profiles with holes instead of boundary Curves. Requires a Solid receiver and an explicit plane.

Returns:

Independent intersection geometry. No intersection returns an empty tuple. A coincident face raises rather than choosing a one-dimensional interpretation.

Return type:

tuple of Curve or Profile

shelled(thickness, *, opening_face_near=None, openings=None)#

Hollow this Solid inward to a constant wall thickness.

Parameters:
  • thickness (float) – Positive wall thickness in metres. The outer footprint is retained.

  • opening_face_near (tuple or list of tuple, optional) – World points selecting temporary face references to leave open. Tied picks raise. Mutually exclusive with openings.

  • openings (FaceRef or FaceSetRef or sequence, optional) – Owned faces to leave open; must belong to this exact receiver. Omit both selection modes for a sealed internal void.

Returns:

Hollow body with inherited material.

Return type:

Solid

Raises:
  • TypeError – For a non-Solid receiver; grow a sheet with thickened() instead.

  • RuntimeError – If the offset cannot form a valid closed body.

swept(spine, *, face_near=None, material=None, frame='corrected_frenet', binormal=None, twist_deg=0.0, draft_deg=0.0, tolerance=None)#

Sweep a planar Sheet along a Curve into an independent Solid.

The actual boundary is translated to the spine start and aligned by the shortest normal-to-tangent rotation, retaining in-plane roll. An already aligned section stays in its actual orientation. For an opposite normal, the section plane’s X axis defines the half-turn. The pipe follows corrected Frenet transport unless another frame is selected explicitly.

Parameters:
  • spine (Curve) – World sweep path.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).swept(spine). Tied picks raise. Invalid for standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

  • frame ({'corrected_frenet', 'frenet', 'fixed', 'fixed_binormal'}, optional) – Transport of the initially aligned section. The default retains corrected Frenet transport. Frenet follows curvature and torsion; fixed keeps sections parallel in world space. Fixed binormal preserves their angular relation to the supplied world direction.

  • binormal (str or tuple of float, optional) – Required only for fixed binormal transport. Must not be parallel to the spine tangent. Path’s up direction does not set this value.

  • twist_deg (float, optional) – Total additional right-hand roll about the transported section normal [degrees], distributed uniformly over spine arc length.

  • draft_deg (float, optional) – Constant section-offset angle [degrees], strictly between -90 and 90. Offset equals travelled arc length times its tangent. Positive values expand the exterior and shrink holes. For perpendicular straight sections this is the wall angle to the sweep direction.

  • tolerance (float, optional) – Sampled section-fitting tolerance [m] for nonzero twist or draft. Defaults to one millionth of the initial profile diagonal.

Returns:

Independent pipe retaining the section’s holes.

Return type:

Solid

tagged_edge(name, *, near=None, curve_type=None)#

Register an immutable named edge selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_edges(name, *, near=None, curve_type=None)#

Register an immutable named set of edges.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_face(name, *, near=None, normal=None, surface_type=None)#

Register an immutable named face selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_faces(name, *, near=None, normal=None, surface_type=None)#

Register an immutable named set of faces.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_vertex(name, *, near=None)#

Register an immutable named vertex selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

thickened(thickness, *, direction='forward', material=None)#

Grow this sheet into a solid of constant thickness.

A Sheet, including a planar Profile or curved Surface, can be thickened. A planar sheet becomes a slab whose footprint is exactly the sheet, which makes this the direct way from a drawn outline to a metallisation of a given thickness, without spelling out the extrusion vector. A curved sheet is offset along its own normal into a shell of constant thickness. An unsuitable thickness, curvature or sampled surface can prevent the CAD kernel from building a valid offset.

Parameters:
  • thickness (float) – Slab thickness [meters], positive.

  • direction ({"forward", "backward", "symmetric"}) – Which side of the sheet to grow on. "symmetric" puts half the thickness on each side, leaving the sheet as the slab’s mid-plane (planar sheets only). "forward" and "backward" are opposite sides of it; forward follows the oriented sheet normal. For a FaceRef, forward follows its outward normal.

  • material (Material or str, optional) – Material of the slab. Defaults to the sheet’s material. A materialless sheet produces a construction solid for Boolean use.

Returns:

The solid slab.

Return type:

Solid

Raises:
  • TypeError – If this is a solid — use shelled() instead.

  • ValueError – If the thickness or direction is invalid, or symmetric thickening is requested for a curved sheet.

Examples

A copper patch from a drawn outline:

patch = Profile.from_wires(outline).thickened(thickness=35e-6, material=copper)
translated(vector, *, repeat=1, copy=False, unite=False, group=False)#

Return this shape moved by vector.

Parameters:
  • vector (tuple of float) – (dx, dy, dz) translation [meters].

  • repeat (int, optional) – Number of translated copies, starting at one vector displacement. Copy i is moved by i * vector; defaults to 1.

  • copy (bool, optional) – Include the untransformed original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One translated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

A row of eight vias, including the original, fused into one body:

fence = via.translated((2e-3, 0, 0), repeat=7, copy=True, unite=True)
vertex(name=None, *, near=None)#

Select one owned vertex, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

VertexRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

volume(scale=None)#

Return the volume enclosed by this shape.

Computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters: a Boolean difference reports what is left, and a chamfered block reports what the chamfer took away. That makes it the direct way to check a construction — a filling factor, a metal volume, the agreement between two ways of building the same part.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

Volume in cubic meters. A planar sheet (Profile) has no thickness and reports zero.

Return type:

float

Examples

The fraction of a housing that is metal:

fill = shell.volume() / block.volume()
class magnelio.geo.Sphere(material=None, name=None, center=(0.0, 0.0, 0.0), radius=1.0)#

Sphere.

Parameters:
  • center (tuple of float) – (x, y, z) center position [meters].

  • radius (float) – Radius [meters], positive.

  • material (Material or str, optional) – Material filling this volume. Omit it for a construction solid used only as a Boolean operand.

  • name (str, optional) – Optional label.

bounding_box(scale=None)#

Return the axis-aligned bounding box of this shape.

The box is computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters — a rotated brick reports the box of the rotated solid.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

(min_corner, max_corner), each (x, y, z) in meters.

Return type:

tuple

chamfered(*, near=None, face_near=None, edges=None, faces=None, distance)#

Return a Solid with a flat bevel on selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms use semantic selection and refuse ambiguity.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • distance (float or tuple of float) – Positive bevel distance in metres, or an asymmetric pair.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

edge(name=None, *, near=None, curve_type=None)#

Select one owned edge, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

EdgeRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

edges(name=None, *, near=None, curve_type=None)#

Select a deliberate set of owned edges, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered set selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

Read-only view bound to this Solid. With no constraints, selects all members.

Return type:

EdgeSetRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

extruded(vector, *, face_near=None, material=None)#

Extrude a Sheet into an independent Solid, retaining holes.

Parameters:
  • vector (tuple of float) – Non-zero world extrusion vector in metres.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).extruded(vector). A tied pick raises AmbiguousTopologyError. Invalid on standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Materialless sections produce construction solids for Boolean use.

Returns:

Independent prism, without fusion to an input owner.

Return type:

Solid

face(name=None, *, near=None, normal=None, surface_type=None)#

Select one owned face, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

FaceRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

faces(name=None, *, near=None, normal=None, surface_type=None)#

Select a deliberate set of owned faces, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered set selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

Read-only view bound to this Solid. With no constraints, selects all members.

Return type:

FaceSetRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

filleted(*, near=None, face_near=None, edges=None, faces=None, radius)#

Return a Solid with rounded selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms refuse ties.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • radius (float) – Positive fillet radius in metres.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

imprinted(cutter)#

Split this body’s boundary faces along a cutter’s intersection.

The receiver keeps its volume and material. Only its boundary topology changes; the cutter remains an independent shape.

Parameters:

cutter (Solid or Sheet) – Shape whose intersection curves split the receiver’s faces.

Returns:

An independent body with imprinted boundary faces.

Return type:

Solid

Raises:

TopologyEvolutionError – If a singular named selection splits or loses its identity.

lofted(face_near, other=None, other_face_near=None, *, material=None, blend='spline', tension=None)#

Connect this section to another with an independent Solid.

For sheets, use section.lofted(other_section). Suitable FaceRef values provide the same verb. All boundaries contribute, and hole counts must agree. The retained Solid convenience is body.lofted(face_near, other_body, other_face_near); its temporary FaceRefs use semantic selection and refuse tied picks.

Parameters:
  • face_near (Profile or Sheet or FaceRef or tuple) – Planar end section for a Sheet receiver. For the Solid convenience, a world point in metres selecting its start face.

  • other (Solid, optional) – End owner for the Solid point convenience only.

  • other_face_near (tuple of float, optional) – World point selecting the end face for the Solid convenience.

  • material (Material or str, optional) – Override the start section’s material. Without a material the result is a construction solid.

  • blend ({'spline', 'ruled', 'tangent'}, optional) – Smooth or straight interpolation, or a transition leaving both oriented normals. Tangent mode requires faces looking towards each other and retains holes with the same spine conditions.

  • tension (float or tuple of float, optional) – Positive finite tangent reach fractions, only in tangent mode. Defaults to one third at each end.

Returns:

Independent transition matching corresponding boundaries.

Return type:

Solid

mirrored(normal, position=0.0, *, copy=False, unite=False, group=False)#

Return this shape reflected across a plane.

The plane is the set of points p with p · normal == position, so for an axis letter position is simply the coordinate of the plane on that axis.

A reflection is not a rotation: it leaves the two in-plane directions untouched and reverses only the normal one. That is what makes it the correct operation for a structure symmetric about a plane but not about the axis normal to it — most planar circuits (dividers, couplers, filters) and every layer stack that differs from top to bottom.

Unlike translated() and rotated() there is no repeat: mirroring twice across one plane reproduces the original.

Parameters:
  • normal (str or sequence of float) – Plane normal: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored). normal='x' maps x -> 2 * position - x.

  • position (float) – Signed distance of the plane from the coordinate origin along normal [meters] (default 0).

  • copy (bool, optional) – Include the original first; defaults to False.

  • unite (bool, optional) – Return a Union of original and image. Requires copy and Solid geometry.

  • group (bool, optional) – Return a Group of original and image, retaining member materials. Requires copy; mutually exclusive with unite.

Returns:

The image alone by default, otherwise [original, image] or the explicitly requested Union or Group.

Return type:

Shape or list of Shape or Union or Group

Examples

Complete a half-modelled power divider into one solid:

full = half.mirrored("x", copy=True, unite=True)

Mirror a feed line onto the far side of a board:

far = line.mirrored("z", position=h / 2)
partition(cutter=None, *, normal=None, position=None)#

Split this solid or sheet into independent connected regions.

Parameters:
  • cutter (Solid or Sheet, optional) – Geometry whose boundary partitions this shape.

  • normal (str or sequence of float, optional) – World normal of a cutting plane. Requires position and excludes cutter.

  • position (float, optional) – Signed plane offset [m], measured as normal dot point.

Returns:

Independently owned regions in kernel order. A non-cut returns one independent region. Order is not persistent across CAD edits.

Return type:

tuple of Solid or Sheet

revolved(axis, angle_deg=360.0, *, origin=(0.0, 0.0, 0.0), material=None)#

Revolve a planar Sheet into an independent Solid.

Parameters:
  • axis (str or sequence of float) – Revolution axis letter or non-zero world vector.

  • angle_deg (float, optional) – Non-zero right-handed angle, at most a full turn, in degrees.

  • origin (tuple of float, optional) – World point on the revolution axis, in metres.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

Returns:

Solid of revolution retaining all holes. A section crossing the axis can produce invalid or self-intersecting geometry.

Return type:

Solid

rotated(axis, angle_deg, origin=(0.0, 0.0, 0.0), *, repeat=1, copy=False, unite=False, group=False)#

Return this shape rotated about an axis.

Parameters:
  • axis (str or sequence of float) – Rotation axis: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored).

  • angle_deg (float) – Rotation angle [degrees], right-handed about axis. Copy i is rotated by i * angle_deg.

  • origin (tuple of float) – A point on the rotation axis (default: the coordinate origin).

  • repeat (int, optional) – Number of rotated copies at angle_deg through repeat * angle_deg; defaults to 1.

  • copy (bool, optional) – Include the unrotated original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One rotated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

Four posts at 90° spacing around the z axis:

posts = post.rotated("z", 90.0, repeat=3, copy=True, group=True)
scaled(factor, center=(0.0, 0.0, 0.0))#

Return this shape scaled uniformly about a fixed point.

The scaling is uniform in all three directions; there is no per-axis factor, because a non-uniform scaling would turn cylinders into elliptic cylinders and spheres into ellipsoids, which the primitives cannot represent.

Parameters:
  • factor (float) – Uniform scale factor. Note that this is not a way to mirror a shape: a negative factor inverts the shape through center, negating all three axes at once. Use mirrored() for a reflection.

  • center (tuple of float) – Fixed point of the scaling (default: the coordinate origin).

Returns:

The scaled shape; a Group is scaled member by member about the common center.

Return type:

Shape or Group

section(cutter=None, *, normal=None, position=None, filled=False)#

Intersect this solid or sheet with a cutter or world plane.

Parameters:
  • cutter (Solid or Sheet, optional) – Intersecting geometry; excludes a plane declaration.

  • normal (str or sequence of float, optional) – World plane normal; requires position.

  • position (float, optional) – Signed world plane offset [m].

  • filled (bool, optional) – Return planar Profiles with holes instead of boundary Curves. Requires a Solid receiver and an explicit plane.

Returns:

Independent intersection geometry. No intersection returns an empty tuple. A coincident face raises rather than choosing a one-dimensional interpretation.

Return type:

tuple of Curve or Profile

shelled(thickness, *, opening_face_near=None, openings=None)#

Hollow this Solid inward to a constant wall thickness.

Parameters:
  • thickness (float) – Positive wall thickness in metres. The outer footprint is retained.

  • opening_face_near (tuple or list of tuple, optional) – World points selecting temporary face references to leave open. Tied picks raise. Mutually exclusive with openings.

  • openings (FaceRef or FaceSetRef or sequence, optional) – Owned faces to leave open; must belong to this exact receiver. Omit both selection modes for a sealed internal void.

Returns:

Hollow body with inherited material.

Return type:

Solid

Raises:
  • TypeError – For a non-Solid receiver; grow a sheet with thickened() instead.

  • RuntimeError – If the offset cannot form a valid closed body.

swept(spine, *, face_near=None, material=None, frame='corrected_frenet', binormal=None, twist_deg=0.0, draft_deg=0.0, tolerance=None)#

Sweep a planar Sheet along a Curve into an independent Solid.

The actual boundary is translated to the spine start and aligned by the shortest normal-to-tangent rotation, retaining in-plane roll. An already aligned section stays in its actual orientation. For an opposite normal, the section plane’s X axis defines the half-turn. The pipe follows corrected Frenet transport unless another frame is selected explicitly.

Parameters:
  • spine (Curve) – World sweep path.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).swept(spine). Tied picks raise. Invalid for standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

  • frame ({'corrected_frenet', 'frenet', 'fixed', 'fixed_binormal'}, optional) – Transport of the initially aligned section. The default retains corrected Frenet transport. Frenet follows curvature and torsion; fixed keeps sections parallel in world space. Fixed binormal preserves their angular relation to the supplied world direction.

  • binormal (str or tuple of float, optional) – Required only for fixed binormal transport. Must not be parallel to the spine tangent. Path’s up direction does not set this value.

  • twist_deg (float, optional) – Total additional right-hand roll about the transported section normal [degrees], distributed uniformly over spine arc length.

  • draft_deg (float, optional) – Constant section-offset angle [degrees], strictly between -90 and 90. Offset equals travelled arc length times its tangent. Positive values expand the exterior and shrink holes. For perpendicular straight sections this is the wall angle to the sweep direction.

  • tolerance (float, optional) – Sampled section-fitting tolerance [m] for nonzero twist or draft. Defaults to one millionth of the initial profile diagonal.

Returns:

Independent pipe retaining the section’s holes.

Return type:

Solid

tagged_edge(name, *, near=None, curve_type=None)#

Register an immutable named edge selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_edges(name, *, near=None, curve_type=None)#

Register an immutable named set of edges.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_face(name, *, near=None, normal=None, surface_type=None)#

Register an immutable named face selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_faces(name, *, near=None, normal=None, surface_type=None)#

Register an immutable named set of faces.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_vertex(name, *, near=None)#

Register an immutable named vertex selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

thickened(thickness, *, direction='forward', material=None)#

Grow this sheet into a solid of constant thickness.

A Sheet, including a planar Profile or curved Surface, can be thickened. A planar sheet becomes a slab whose footprint is exactly the sheet, which makes this the direct way from a drawn outline to a metallisation of a given thickness, without spelling out the extrusion vector. A curved sheet is offset along its own normal into a shell of constant thickness. An unsuitable thickness, curvature or sampled surface can prevent the CAD kernel from building a valid offset.

Parameters:
  • thickness (float) – Slab thickness [meters], positive.

  • direction ({"forward", "backward", "symmetric"}) – Which side of the sheet to grow on. "symmetric" puts half the thickness on each side, leaving the sheet as the slab’s mid-plane (planar sheets only). "forward" and "backward" are opposite sides of it; forward follows the oriented sheet normal. For a FaceRef, forward follows its outward normal.

  • material (Material or str, optional) – Material of the slab. Defaults to the sheet’s material. A materialless sheet produces a construction solid for Boolean use.

Returns:

The solid slab.

Return type:

Solid

Raises:
  • TypeError – If this is a solid — use shelled() instead.

  • ValueError – If the thickness or direction is invalid, or symmetric thickening is requested for a curved sheet.

Examples

A copper patch from a drawn outline:

patch = Profile.from_wires(outline).thickened(thickness=35e-6, material=copper)
translated(vector, *, repeat=1, copy=False, unite=False, group=False)#

Return this shape moved by vector.

Parameters:
  • vector (tuple of float) – (dx, dy, dz) translation [meters].

  • repeat (int, optional) – Number of translated copies, starting at one vector displacement. Copy i is moved by i * vector; defaults to 1.

  • copy (bool, optional) – Include the untransformed original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One translated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

A row of eight vias, including the original, fused into one body:

fence = via.translated((2e-3, 0, 0), repeat=7, copy=True, unite=True)
vertex(name=None, *, near=None)#

Select one owned vertex, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

VertexRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

volume(scale=None)#

Return the volume enclosed by this shape.

Computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters: a Boolean difference reports what is left, and a chamfered block reports what the chamfer took away. That makes it the direct way to check a construction — a filling factor, a metal volume, the agreement between two ways of building the same part.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

Volume in cubic meters. A planar sheet (Profile) has no thickness and reports zero.

Return type:

float

Examples

The fraction of a housing that is metal:

fill = shell.volume() / block.volume()
class magnelio.geo.Surface(points, material=None, name=None)#

A curved zero-thickness sheet through a grid of sample points.

Build one with parametric(); the constructor itself takes the point grid, which is what a stored or hand-sampled surface provides. The sheet is the B-spline surface interpolating the samples exactly (a degree-3 interpolant between them), bounded by the grid’s four edge rows.

Like a Profile, a Surface carries an optional material: none (default) makes it a construction profile — the input to extruded() or thickened(), which turn it into a solid; a material makes it a thin sheet, whose physics is not wired yet, so it cannot be added to a model on its own.

Parameters:
  • points (sequence of sequence of (float, float, float)) – The sample grid, nu rows of nv points [meters], at least 2 × 2. Rows follow the first parameter, columns the second. A row may collapse onto one point (the pole of a polar parametrisation) — the surface closes there.

  • material (Material or str, optional) – Material of the thin sheet. None (default) = construction profile.

  • name (str, optional) – Optional label.

classmethod parametric(fn, *, u, v, samples=(32, 32), material=None, name=None)#

Sample a parametric map (u, v) -> (x, y, z) into a Surface.

Parameters:
  • fn (callable) – The map. Called once with two NumPy arrays of parameter values (shape (nu, nv)) and expected to return the three coordinates (x, y, z) [meters] — each an array of the same shape or a scalar. A function written for scalars is accepted too: if the array call fails, it is evaluated point by point.

  • u ((float, float)) – Parameter intervals (start, end) of the two parameters.

  • v ((float, float)) – Parameter intervals (start, end) of the two parameters.

  • samples ((int, int)) – Number of sample points along u and v (default (32, 32), at least 2 each). The interpolant is exact at the samples and degree-3 between them, so the count sets how closely the sheet follows the map between samples — 32 × 32 places a 240 mm paraboloid dish to a few micrometres, 32 × 64 to 1e-8 m.

  • material (Material or str, optional) – Material of the thin sheet; None (default) makes a construction profile.

  • name (str, optional) – Optional label.

Returns:

The sampled sheet.

Return type:

Surface

Examples

An offset paraboloid dish of focal length F and aperture D, centred x_c off the axis, parametrised in polar coordinates about the aperture center so that its rim is a circle:

def dish(r, phi):
    x = x_c + r * np.cos(phi)
    y = r * np.sin(phi)
    return x, y, (x**2 + y**2) / (4 * F)

sheet = geo.Surface.parametric(dish, u=(0.0, D / 2), v=(0.0, 2 * np.pi))
reflector = sheet.extruded(vector=(0, 0, -5e-3), material="pec")
bounding_box(scale=None)#

Return the axis-aligned bounding box of this shape.

The box is computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters — a rotated brick reports the box of the rotated solid.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

(min_corner, max_corner), each (x, y, z) in meters.

Return type:

tuple

chamfered(*, near=None, face_near=None, edges=None, faces=None, distance)#

Return a Solid with a flat bevel on selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms use semantic selection and refuse ambiguity.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • distance (float or tuple of float) – Positive bevel distance in metres, or an asymmetric pair.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

extruded(vector, *, face_near=None, material=None)#

Extrude a Sheet into an independent Solid, retaining holes.

Parameters:
  • vector (tuple of float) – Non-zero world extrusion vector in metres.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).extruded(vector). A tied pick raises AmbiguousTopologyError. Invalid on standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Materialless sections produce construction solids for Boolean use.

Returns:

Independent prism, without fusion to an input owner.

Return type:

Solid

filleted(*, near=None, face_near=None, edges=None, faces=None, radius)#

Return a Solid with rounded selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms refuse ties.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • radius (float) – Positive fillet radius in metres.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

lofted(other, *, material=None, blend='spline', tension=None)#

Connect this planar sheet to another section with a Solid.

Parameters:
  • other (Profile or Sheet or FaceRef) – Planar end section in its actual world placement. All sections need the same number of holes, matched in boundary order.

  • material (Material or str, optional) – Override this sheet’s material; otherwise it is inherited. Materialless sections produce construction solids for Boolean use.

  • blend ({'spline', 'ruled', 'tangent'}, optional) – Interpolation mode. Tangent transitions leave both oriented normals.

  • tension (float or tuple of float, optional) – Positive tangent reach fractions, only for tangent blending.

Returns:

Independent transition retaining all corresponding boundaries.

Return type:

Solid

mirrored(normal, position=0.0, *, copy=False, unite=False, group=False)#

Return this shape reflected across a plane.

The plane is the set of points p with p · normal == position, so for an axis letter position is simply the coordinate of the plane on that axis.

A reflection is not a rotation: it leaves the two in-plane directions untouched and reverses only the normal one. That is what makes it the correct operation for a structure symmetric about a plane but not about the axis normal to it — most planar circuits (dividers, couplers, filters) and every layer stack that differs from top to bottom.

Unlike translated() and rotated() there is no repeat: mirroring twice across one plane reproduces the original.

Parameters:
  • normal (str or sequence of float) – Plane normal: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored). normal='x' maps x -> 2 * position - x.

  • position (float) – Signed distance of the plane from the coordinate origin along normal [meters] (default 0).

  • copy (bool, optional) – Include the original first; defaults to False.

  • unite (bool, optional) – Return a Union of original and image. Requires copy and Solid geometry.

  • group (bool, optional) – Return a Group of original and image, retaining member materials. Requires copy; mutually exclusive with unite.

Returns:

The image alone by default, otherwise [original, image] or the explicitly requested Union or Group.

Return type:

Shape or list of Shape or Union or Group

Examples

Complete a half-modelled power divider into one solid:

full = half.mirrored("x", copy=True, unite=True)

Mirror a feed line onto the far side of a board:

far = line.mirrored("z", position=h / 2)
offset(distance, *, tolerance=None)#

Return a curved sheet shifted along its oriented normal.

Positive distance follows the sheet normal; negative distance goes to the opposite side. The actual trimmed boundary moves with the sheet. This operation does not give a sheet physical thickness.

Parameters:
  • distance (float) – Signed normal distance [meters].

  • tolerance (float, optional) – Maximum sampled geometric deviation [meters]. Defaults to one millionth of the sheet extent, subject to the CAD resolution.

Returns:

Independent offset sheet in a tuple.

Return type:

tuple of Surface

Raises:

ValueError – If the normal offset folds, becomes singular, or exceeds the geometric tolerance.

partition(cutter=None, *, normal=None, position=None)#

Split this solid or sheet into independent connected regions.

Parameters:
  • cutter (Solid or Sheet, optional) – Geometry whose boundary partitions this shape.

  • normal (str or sequence of float, optional) – World normal of a cutting plane. Requires position and excludes cutter.

  • position (float, optional) – Signed plane offset [m], measured as normal dot point.

Returns:

Independently owned regions in kernel order. A non-cut returns one independent region. Order is not persistent across CAD edits.

Return type:

tuple of Solid or Sheet

revolved(axis, angle_deg=360.0, *, origin=(0.0, 0.0, 0.0), material=None)#

Revolve a planar Sheet into an independent Solid.

Parameters:
  • axis (str or sequence of float) – Revolution axis letter or non-zero world vector.

  • angle_deg (float, optional) – Non-zero right-handed angle, at most a full turn, in degrees.

  • origin (tuple of float, optional) – World point on the revolution axis, in metres.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

Returns:

Solid of revolution retaining all holes. A section crossing the axis can produce invalid or self-intersecting geometry.

Return type:

Solid

rotated(axis, angle_deg, origin=(0.0, 0.0, 0.0), *, repeat=1, copy=False, unite=False, group=False)#

Return this shape rotated about an axis.

Parameters:
  • axis (str or sequence of float) – Rotation axis: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored).

  • angle_deg (float) – Rotation angle [degrees], right-handed about axis. Copy i is rotated by i * angle_deg.

  • origin (tuple of float) – A point on the rotation axis (default: the coordinate origin).

  • repeat (int, optional) – Number of rotated copies at angle_deg through repeat * angle_deg; defaults to 1.

  • copy (bool, optional) – Include the unrotated original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One rotated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

Four posts at 90° spacing around the z axis:

posts = post.rotated("z", 90.0, repeat=3, copy=True, group=True)
scaled(factor, center=(0.0, 0.0, 0.0))#

Return this shape scaled uniformly about a fixed point.

The scaling is uniform in all three directions; there is no per-axis factor, because a non-uniform scaling would turn cylinders into elliptic cylinders and spheres into ellipsoids, which the primitives cannot represent.

Parameters:
  • factor (float) – Uniform scale factor. Note that this is not a way to mirror a shape: a negative factor inverts the shape through center, negating all three axes at once. Use mirrored() for a reflection.

  • center (tuple of float) – Fixed point of the scaling (default: the coordinate origin).

Returns:

The scaled shape; a Group is scaled member by member about the common center.

Return type:

Shape or Group

section(cutter=None, *, normal=None, position=None, filled=False)#

Intersect this solid or sheet with a cutter or world plane.

Parameters:
  • cutter (Solid or Sheet, optional) – Intersecting geometry; excludes a plane declaration.

  • normal (str or sequence of float, optional) – World plane normal; requires position.

  • position (float, optional) – Signed world plane offset [m].

  • filled (bool, optional) – Return planar Profiles with holes instead of boundary Curves. Requires a Solid receiver and an explicit plane.

Returns:

Independent intersection geometry. No intersection returns an empty tuple. A coincident face raises rather than choosing a one-dimensional interpretation.

Return type:

tuple of Curve or Profile

shelled(thickness, *, opening_face_near=None, openings=None)#

Hollow this Solid inward to a constant wall thickness.

Parameters:
  • thickness (float) – Positive wall thickness in metres. The outer footprint is retained.

  • opening_face_near (tuple or list of tuple, optional) – World points selecting temporary face references to leave open. Tied picks raise. Mutually exclusive with openings.

  • openings (FaceRef or FaceSetRef or sequence, optional) – Owned faces to leave open; must belong to this exact receiver. Omit both selection modes for a sealed internal void.

Returns:

Hollow body with inherited material.

Return type:

Solid

Raises:
  • TypeError – For a non-Solid receiver; grow a sheet with thickened() instead.

  • RuntimeError – If the offset cannot form a valid closed body.

swept(spine, *, face_near=None, material=None, frame='corrected_frenet', binormal=None, twist_deg=0.0, draft_deg=0.0, tolerance=None)#

Sweep a planar Sheet along a Curve into an independent Solid.

The actual boundary is translated to the spine start and aligned by the shortest normal-to-tangent rotation, retaining in-plane roll. An already aligned section stays in its actual orientation. For an opposite normal, the section plane’s X axis defines the half-turn. The pipe follows corrected Frenet transport unless another frame is selected explicitly.

Parameters:
  • spine (Curve) – World sweep path.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).swept(spine). Tied picks raise. Invalid for standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

  • frame ({'corrected_frenet', 'frenet', 'fixed', 'fixed_binormal'}, optional) – Transport of the initially aligned section. The default retains corrected Frenet transport. Frenet follows curvature and torsion; fixed keeps sections parallel in world space. Fixed binormal preserves their angular relation to the supplied world direction.

  • binormal (str or tuple of float, optional) – Required only for fixed binormal transport. Must not be parallel to the spine tangent. Path’s up direction does not set this value.

  • twist_deg (float, optional) – Total additional right-hand roll about the transported section normal [degrees], distributed uniformly over spine arc length.

  • draft_deg (float, optional) – Constant section-offset angle [degrees], strictly between -90 and 90. Offset equals travelled arc length times its tangent. Positive values expand the exterior and shrink holes. For perpendicular straight sections this is the wall angle to the sweep direction.

  • tolerance (float, optional) – Sampled section-fitting tolerance [m] for nonzero twist or draft. Defaults to one millionth of the initial profile diagonal.

Returns:

Independent pipe retaining the section’s holes.

Return type:

Solid

thickened(thickness, *, direction='forward', material=None)#

Grow this sheet into a solid of constant thickness.

A Sheet, including a planar Profile or curved Surface, can be thickened. A planar sheet becomes a slab whose footprint is exactly the sheet, which makes this the direct way from a drawn outline to a metallisation of a given thickness, without spelling out the extrusion vector. A curved sheet is offset along its own normal into a shell of constant thickness. An unsuitable thickness, curvature or sampled surface can prevent the CAD kernel from building a valid offset.

Parameters:
  • thickness (float) – Slab thickness [meters], positive.

  • direction ({"forward", "backward", "symmetric"}) – Which side of the sheet to grow on. "symmetric" puts half the thickness on each side, leaving the sheet as the slab’s mid-plane (planar sheets only). "forward" and "backward" are opposite sides of it; forward follows the oriented sheet normal. For a FaceRef, forward follows its outward normal.

  • material (Material or str, optional) – Material of the slab. Defaults to the sheet’s material. A materialless sheet produces a construction solid for Boolean use.

Returns:

The solid slab.

Return type:

Solid

Raises:
  • TypeError – If this is a solid — use shelled() instead.

  • ValueError – If the thickness or direction is invalid, or symmetric thickening is requested for a curved sheet.

Examples

A copper patch from a drawn outline:

patch = Profile.from_wires(outline).thickened(thickness=35e-6, material=copper)
translated(vector, *, repeat=1, copy=False, unite=False, group=False)#

Return this shape moved by vector.

Parameters:
  • vector (tuple of float) – (dx, dy, dz) translation [meters].

  • repeat (int, optional) – Number of translated copies, starting at one vector displacement. Copy i is moved by i * vector; defaults to 1.

  • copy (bool, optional) – Include the untransformed original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One translated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

A row of eight vias, including the original, fused into one body:

fence = via.translated((2e-3, 0, 0), repeat=7, copy=True, unite=True)
volume(scale=None)#

Return the volume enclosed by this shape.

Computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters: a Boolean difference reports what is left, and a chamfered block reports what the chamfer took away. That makes it the direct way to check a construction — a filling factor, a metal volume, the agreement between two ways of building the same part.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

Volume in cubic meters. A planar sheet (Profile) has no thickness and reports zero.

Return type:

float

Examples

The fraction of a housing that is metal:

fill = shell.volume() / block.volume()
class magnelio.geo.ThinWire(curve, radius, name=None)#

A thin PEC wire along a Curve (radius far below the cell size).

A new leaf-node category in the geometry-object protocol: like a solid it exposes .material (always PEC), ._occ_shape() (the curve’s TopoDS_Wire) and bounding_box() — so persistence, validation and critical-plane extraction work unchanged — but it has no volume: the mesher never fills or classifies it, it applies the thin-wire sub-cell model instead.

Parameters:
  • curve (Curve) – The wire’s path (polyline / arc / spline / helix). Rasterised to an axis-aligned edge staircase at meshing time.

  • radius (float) – Physical wire radius [m]. Must be positive and stay below ~0.3 of the smallest transverse cell along the path (checked at meshing time — the thin-wire model is a sub-cell model; a fatter conductor should be a resolved cylinder instead).

  • name (str, optional) – Optional label used in warnings and error messages.

bounding_box(scale=None)#

Bounding box of the wire’s curve (the radius is NOT included).

The radius is a sub-cell model parameter: inflating the box by ~a would introduce feature planes 2a apart and collapse the mesher’s fine cell size.

Parameters:

scale (float | None)

Return type:

tuple[tuple[float, float, float], tuple[float, float, float]]

property material: Material#

The wire’s material — always PEC in v1.

class magnelio.geo.TopologyRef(owner, _shape, _scale, _origin=None)#

Read-only subshape view strongly bound to one immutable Solid.

References are produced by Solid selectors, not constructed by users. They cannot be transformed, meshed or used as Boolean operands.

Parameters:
  • owner (object)

  • _shape (object)

  • _scale (float)

  • _origin (object)

owner#

Body whose topology this view describes.

Type:

Solid

bounding_box()#

Return world-coordinate minimum and maximum corners in metres.

class magnelio.geo.Torus(material=None, name=None, center=(0.0, 0.0, 0.0), major_radius=1.0, minor_radius=0.25, axis='z')#

Torus.

Parameters:
  • center (tuple of float) – (x, y, z) center of the torus [meters].

  • major_radius (float) – Major radius (center of tube to center of torus) [meters].

  • minor_radius (float) – Minor radius (tube radius) [meters]. Must stay below major_radius: a tube reaching the symmetry axis would pass through itself.

  • axis (str or tuple of float) – Symmetry axis: 'x'/'y'/'z' or any 3-vector.

  • material (Material or str, optional) – Material filling this volume. Omit it for a construction solid used only as a Boolean operand.

  • name (str, optional) – Optional label.

bounding_box(scale=None)#

Return the axis-aligned bounding box of this shape.

The box is computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters — a rotated brick reports the box of the rotated solid.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

(min_corner, max_corner), each (x, y, z) in meters.

Return type:

tuple

chamfered(*, near=None, face_near=None, edges=None, faces=None, distance)#

Return a Solid with a flat bevel on selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms use semantic selection and refuse ambiguity.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • distance (float or tuple of float) – Positive bevel distance in metres, or an asymmetric pair.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

edge(name=None, *, near=None, curve_type=None)#

Select one owned edge, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

EdgeRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

edges(name=None, *, near=None, curve_type=None)#

Select a deliberate set of owned edges, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered set selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

Read-only view bound to this Solid. With no constraints, selects all members.

Return type:

EdgeSetRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

extruded(vector, *, face_near=None, material=None)#

Extrude a Sheet into an independent Solid, retaining holes.

Parameters:
  • vector (tuple of float) – Non-zero world extrusion vector in metres.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).extruded(vector). A tied pick raises AmbiguousTopologyError. Invalid on standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Materialless sections produce construction solids for Boolean use.

Returns:

Independent prism, without fusion to an input owner.

Return type:

Solid

face(name=None, *, near=None, normal=None, surface_type=None)#

Select one owned face, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

FaceRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

faces(name=None, *, near=None, normal=None, surface_type=None)#

Select a deliberate set of owned faces, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered set selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

Read-only view bound to this Solid. With no constraints, selects all members.

Return type:

FaceSetRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

filleted(*, near=None, face_near=None, edges=None, faces=None, radius)#

Return a Solid with rounded selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms refuse ties.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • radius (float) – Positive fillet radius in metres.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

imprinted(cutter)#

Split this body’s boundary faces along a cutter’s intersection.

The receiver keeps its volume and material. Only its boundary topology changes; the cutter remains an independent shape.

Parameters:

cutter (Solid or Sheet) – Shape whose intersection curves split the receiver’s faces.

Returns:

An independent body with imprinted boundary faces.

Return type:

Solid

Raises:

TopologyEvolutionError – If a singular named selection splits or loses its identity.

lofted(face_near, other=None, other_face_near=None, *, material=None, blend='spline', tension=None)#

Connect this section to another with an independent Solid.

For sheets, use section.lofted(other_section). Suitable FaceRef values provide the same verb. All boundaries contribute, and hole counts must agree. The retained Solid convenience is body.lofted(face_near, other_body, other_face_near); its temporary FaceRefs use semantic selection and refuse tied picks.

Parameters:
  • face_near (Profile or Sheet or FaceRef or tuple) – Planar end section for a Sheet receiver. For the Solid convenience, a world point in metres selecting its start face.

  • other (Solid, optional) – End owner for the Solid point convenience only.

  • other_face_near (tuple of float, optional) – World point selecting the end face for the Solid convenience.

  • material (Material or str, optional) – Override the start section’s material. Without a material the result is a construction solid.

  • blend ({'spline', 'ruled', 'tangent'}, optional) – Smooth or straight interpolation, or a transition leaving both oriented normals. Tangent mode requires faces looking towards each other and retains holes with the same spine conditions.

  • tension (float or tuple of float, optional) – Positive finite tangent reach fractions, only in tangent mode. Defaults to one third at each end.

Returns:

Independent transition matching corresponding boundaries.

Return type:

Solid

mirrored(normal, position=0.0, *, copy=False, unite=False, group=False)#

Return this shape reflected across a plane.

The plane is the set of points p with p · normal == position, so for an axis letter position is simply the coordinate of the plane on that axis.

A reflection is not a rotation: it leaves the two in-plane directions untouched and reverses only the normal one. That is what makes it the correct operation for a structure symmetric about a plane but not about the axis normal to it — most planar circuits (dividers, couplers, filters) and every layer stack that differs from top to bottom.

Unlike translated() and rotated() there is no repeat: mirroring twice across one plane reproduces the original.

Parameters:
  • normal (str or sequence of float) – Plane normal: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored). normal='x' maps x -> 2 * position - x.

  • position (float) – Signed distance of the plane from the coordinate origin along normal [meters] (default 0).

  • copy (bool, optional) – Include the original first; defaults to False.

  • unite (bool, optional) – Return a Union of original and image. Requires copy and Solid geometry.

  • group (bool, optional) – Return a Group of original and image, retaining member materials. Requires copy; mutually exclusive with unite.

Returns:

The image alone by default, otherwise [original, image] or the explicitly requested Union or Group.

Return type:

Shape or list of Shape or Union or Group

Examples

Complete a half-modelled power divider into one solid:

full = half.mirrored("x", copy=True, unite=True)

Mirror a feed line onto the far side of a board:

far = line.mirrored("z", position=h / 2)
partition(cutter=None, *, normal=None, position=None)#

Split this solid or sheet into independent connected regions.

Parameters:
  • cutter (Solid or Sheet, optional) – Geometry whose boundary partitions this shape.

  • normal (str or sequence of float, optional) – World normal of a cutting plane. Requires position and excludes cutter.

  • position (float, optional) – Signed plane offset [m], measured as normal dot point.

Returns:

Independently owned regions in kernel order. A non-cut returns one independent region. Order is not persistent across CAD edits.

Return type:

tuple of Solid or Sheet

revolved(axis, angle_deg=360.0, *, origin=(0.0, 0.0, 0.0), material=None)#

Revolve a planar Sheet into an independent Solid.

Parameters:
  • axis (str or sequence of float) – Revolution axis letter or non-zero world vector.

  • angle_deg (float, optional) – Non-zero right-handed angle, at most a full turn, in degrees.

  • origin (tuple of float, optional) – World point on the revolution axis, in metres.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

Returns:

Solid of revolution retaining all holes. A section crossing the axis can produce invalid or self-intersecting geometry.

Return type:

Solid

rotated(axis, angle_deg, origin=(0.0, 0.0, 0.0), *, repeat=1, copy=False, unite=False, group=False)#

Return this shape rotated about an axis.

Parameters:
  • axis (str or sequence of float) – Rotation axis: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored).

  • angle_deg (float) – Rotation angle [degrees], right-handed about axis. Copy i is rotated by i * angle_deg.

  • origin (tuple of float) – A point on the rotation axis (default: the coordinate origin).

  • repeat (int, optional) – Number of rotated copies at angle_deg through repeat * angle_deg; defaults to 1.

  • copy (bool, optional) – Include the unrotated original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One rotated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

Four posts at 90° spacing around the z axis:

posts = post.rotated("z", 90.0, repeat=3, copy=True, group=True)
scaled(factor, center=(0.0, 0.0, 0.0))#

Return this shape scaled uniformly about a fixed point.

The scaling is uniform in all three directions; there is no per-axis factor, because a non-uniform scaling would turn cylinders into elliptic cylinders and spheres into ellipsoids, which the primitives cannot represent.

Parameters:
  • factor (float) – Uniform scale factor. Note that this is not a way to mirror a shape: a negative factor inverts the shape through center, negating all three axes at once. Use mirrored() for a reflection.

  • center (tuple of float) – Fixed point of the scaling (default: the coordinate origin).

Returns:

The scaled shape; a Group is scaled member by member about the common center.

Return type:

Shape or Group

section(cutter=None, *, normal=None, position=None, filled=False)#

Intersect this solid or sheet with a cutter or world plane.

Parameters:
  • cutter (Solid or Sheet, optional) – Intersecting geometry; excludes a plane declaration.

  • normal (str or sequence of float, optional) – World plane normal; requires position.

  • position (float, optional) – Signed world plane offset [m].

  • filled (bool, optional) – Return planar Profiles with holes instead of boundary Curves. Requires a Solid receiver and an explicit plane.

Returns:

Independent intersection geometry. No intersection returns an empty tuple. A coincident face raises rather than choosing a one-dimensional interpretation.

Return type:

tuple of Curve or Profile

shelled(thickness, *, opening_face_near=None, openings=None)#

Hollow this Solid inward to a constant wall thickness.

Parameters:
  • thickness (float) – Positive wall thickness in metres. The outer footprint is retained.

  • opening_face_near (tuple or list of tuple, optional) – World points selecting temporary face references to leave open. Tied picks raise. Mutually exclusive with openings.

  • openings (FaceRef or FaceSetRef or sequence, optional) – Owned faces to leave open; must belong to this exact receiver. Omit both selection modes for a sealed internal void.

Returns:

Hollow body with inherited material.

Return type:

Solid

Raises:
  • TypeError – For a non-Solid receiver; grow a sheet with thickened() instead.

  • RuntimeError – If the offset cannot form a valid closed body.

swept(spine, *, face_near=None, material=None, frame='corrected_frenet', binormal=None, twist_deg=0.0, draft_deg=0.0, tolerance=None)#

Sweep a planar Sheet along a Curve into an independent Solid.

The actual boundary is translated to the spine start and aligned by the shortest normal-to-tangent rotation, retaining in-plane roll. An already aligned section stays in its actual orientation. For an opposite normal, the section plane’s X axis defines the half-turn. The pipe follows corrected Frenet transport unless another frame is selected explicitly.

Parameters:
  • spine (Curve) – World sweep path.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).swept(spine). Tied picks raise. Invalid for standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

  • frame ({'corrected_frenet', 'frenet', 'fixed', 'fixed_binormal'}, optional) – Transport of the initially aligned section. The default retains corrected Frenet transport. Frenet follows curvature and torsion; fixed keeps sections parallel in world space. Fixed binormal preserves their angular relation to the supplied world direction.

  • binormal (str or tuple of float, optional) – Required only for fixed binormal transport. Must not be parallel to the spine tangent. Path’s up direction does not set this value.

  • twist_deg (float, optional) – Total additional right-hand roll about the transported section normal [degrees], distributed uniformly over spine arc length.

  • draft_deg (float, optional) – Constant section-offset angle [degrees], strictly between -90 and 90. Offset equals travelled arc length times its tangent. Positive values expand the exterior and shrink holes. For perpendicular straight sections this is the wall angle to the sweep direction.

  • tolerance (float, optional) – Sampled section-fitting tolerance [m] for nonzero twist or draft. Defaults to one millionth of the initial profile diagonal.

Returns:

Independent pipe retaining the section’s holes.

Return type:

Solid

tagged_edge(name, *, near=None, curve_type=None)#

Register an immutable named edge selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_edges(name, *, near=None, curve_type=None)#

Register an immutable named set of edges.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_face(name, *, near=None, normal=None, surface_type=None)#

Register an immutable named face selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_faces(name, *, near=None, normal=None, surface_type=None)#

Register an immutable named set of faces.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_vertex(name, *, near=None)#

Register an immutable named vertex selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

thickened(thickness, *, direction='forward', material=None)#

Grow this sheet into a solid of constant thickness.

A Sheet, including a planar Profile or curved Surface, can be thickened. A planar sheet becomes a slab whose footprint is exactly the sheet, which makes this the direct way from a drawn outline to a metallisation of a given thickness, without spelling out the extrusion vector. A curved sheet is offset along its own normal into a shell of constant thickness. An unsuitable thickness, curvature or sampled surface can prevent the CAD kernel from building a valid offset.

Parameters:
  • thickness (float) – Slab thickness [meters], positive.

  • direction ({"forward", "backward", "symmetric"}) – Which side of the sheet to grow on. "symmetric" puts half the thickness on each side, leaving the sheet as the slab’s mid-plane (planar sheets only). "forward" and "backward" are opposite sides of it; forward follows the oriented sheet normal. For a FaceRef, forward follows its outward normal.

  • material (Material or str, optional) – Material of the slab. Defaults to the sheet’s material. A materialless sheet produces a construction solid for Boolean use.

Returns:

The solid slab.

Return type:

Solid

Raises:
  • TypeError – If this is a solid — use shelled() instead.

  • ValueError – If the thickness or direction is invalid, or symmetric thickening is requested for a curved sheet.

Examples

A copper patch from a drawn outline:

patch = Profile.from_wires(outline).thickened(thickness=35e-6, material=copper)
translated(vector, *, repeat=1, copy=False, unite=False, group=False)#

Return this shape moved by vector.

Parameters:
  • vector (tuple of float) – (dx, dy, dz) translation [meters].

  • repeat (int, optional) – Number of translated copies, starting at one vector displacement. Copy i is moved by i * vector; defaults to 1.

  • copy (bool, optional) – Include the untransformed original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One translated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

A row of eight vias, including the original, fused into one body:

fence = via.translated((2e-3, 0, 0), repeat=7, copy=True, unite=True)
vertex(name=None, *, near=None)#

Select one owned vertex, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

VertexRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

volume(scale=None)#

Return the volume enclosed by this shape.

Computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters: a Boolean difference reports what is left, and a chamfered block reports what the chamfer took away. That makes it the direct way to check a construction — a filling factor, a metal volume, the agreement between two ways of building the same part.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

Volume in cubic meters. A planar sheet (Profile) has no thickness and reports zero.

Return type:

float

Examples

The fraction of a housing that is metal:

fill = shell.volume() / block.volume()
class magnelio.geo.Transform(matrix)#

An immutable affine placement value.

Matrices act on column-vector points. Consequently A @ B @ shape applies B first and then A. Only rigid transforms, reflections and uniform scales are accepted; shear and non-uniform scale would change the public analytic geometry categories.

Parameters:

matrix (sequence of sequence of float) – Homogeneous 4 x 4 affine matrix. Prefer Translation, Rotation, Mirror, Scale, and composition.

classmethod identity()#

Return the identity transform.

Return type:

Transform

point(point)#

Return point transformed by this affine value.

Return type:

tuple[float, float, float]

class magnelio.geo.Translation(vector)#

Translation by a three-dimensional vector.

Parameters:

vector (tuple of float) – (dx, dy, dz) translation [meters].

classmethod identity()#

Return the identity transform.

Return type:

Transform

point(point)#

Return point transformed by this affine value.

Return type:

tuple[float, float, float]

class magnelio.geo.Union(*shapes, material=None, name=None)#

Boolean union of two or more shapes.

Parameters:
  • shapes – Two or more CSG shapes to unite.

  • material – Material for the resulting volume. If None, uses the material of the first shape.

  • name – Optional label.

bounding_box(scale=None)#

Return the axis-aligned bounding box of this shape.

The box is computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters — a rotated brick reports the box of the rotated solid.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

(min_corner, max_corner), each (x, y, z) in meters.

Return type:

tuple

chamfered(*, near=None, face_near=None, edges=None, faces=None, distance)#

Return a Solid with a flat bevel on selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms use semantic selection and refuse ambiguity.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • distance (float or tuple of float) – Positive bevel distance in metres, or an asymmetric pair.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

edge(name=None, *, near=None, curve_type=None)#

Select one owned edge, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

EdgeRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

edges(name=None, *, near=None, curve_type=None)#

Select a deliberate set of owned edges, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered set selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

Read-only view bound to this Solid. With no constraints, selects all members.

Return type:

EdgeSetRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

extruded(vector, *, face_near=None, material=None)#

Extrude a Sheet into an independent Solid, retaining holes.

Parameters:
  • vector (tuple of float) – Non-zero world extrusion vector in metres.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).extruded(vector). A tied pick raises AmbiguousTopologyError. Invalid on standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Materialless sections produce construction solids for Boolean use.

Returns:

Independent prism, without fusion to an input owner.

Return type:

Solid

face(name=None, *, near=None, normal=None, surface_type=None)#

Select one owned face, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

FaceRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

faces(name=None, *, near=None, normal=None, surface_type=None)#

Select a deliberate set of owned faces, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered set selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

Read-only view bound to this Solid. With no constraints, selects all members.

Return type:

FaceSetRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

filleted(*, near=None, face_near=None, edges=None, faces=None, radius)#

Return a Solid with rounded selected owned edges.

Select exactly one of edges, faces, near or face_near. References must belong to this exact Solid; point forms refuse ties.

Parameters:
  • near (tuple or list of tuple, optional) – World points in metres selecting nearest edges.

  • face_near (tuple of float, optional) – World point selecting a face’s complete boundary.

  • edges (EdgeRef or EdgeSetRef or sequence or str, optional) – Owned edges, or "all" for every edge.

  • faces (FaceRef or FaceSetRef or sequence, optional) – Owned faces whose boundary edges are selected.

  • radius (float) – Positive fillet radius in metres.

Returns:

Modified body, inheriting this Solid’s material.

Return type:

Solid

imprinted(cutter)#

Split this body’s boundary faces along a cutter’s intersection.

The receiver keeps its volume and material. Only its boundary topology changes; the cutter remains an independent shape.

Parameters:

cutter (Solid or Sheet) – Shape whose intersection curves split the receiver’s faces.

Returns:

An independent body with imprinted boundary faces.

Return type:

Solid

Raises:

TopologyEvolutionError – If a singular named selection splits or loses its identity.

lofted(face_near, other=None, other_face_near=None, *, material=None, blend='spline', tension=None)#

Connect this section to another with an independent Solid.

For sheets, use section.lofted(other_section). Suitable FaceRef values provide the same verb. All boundaries contribute, and hole counts must agree. The retained Solid convenience is body.lofted(face_near, other_body, other_face_near); its temporary FaceRefs use semantic selection and refuse tied picks.

Parameters:
  • face_near (Profile or Sheet or FaceRef or tuple) – Planar end section for a Sheet receiver. For the Solid convenience, a world point in metres selecting its start face.

  • other (Solid, optional) – End owner for the Solid point convenience only.

  • other_face_near (tuple of float, optional) – World point selecting the end face for the Solid convenience.

  • material (Material or str, optional) – Override the start section’s material. Without a material the result is a construction solid.

  • blend ({'spline', 'ruled', 'tangent'}, optional) – Smooth or straight interpolation, or a transition leaving both oriented normals. Tangent mode requires faces looking towards each other and retains holes with the same spine conditions.

  • tension (float or tuple of float, optional) – Positive finite tangent reach fractions, only in tangent mode. Defaults to one third at each end.

Returns:

Independent transition matching corresponding boundaries.

Return type:

Solid

mirrored(normal, position=0.0, *, copy=False, unite=False, group=False)#

Return this shape reflected across a plane.

The plane is the set of points p with p · normal == position, so for an axis letter position is simply the coordinate of the plane on that axis.

A reflection is not a rotation: it leaves the two in-plane directions untouched and reverses only the normal one. That is what makes it the correct operation for a structure symmetric about a plane but not about the axis normal to it — most planar circuits (dividers, couplers, filters) and every layer stack that differs from top to bottom.

Unlike translated() and rotated() there is no repeat: mirroring twice across one plane reproduces the original.

Parameters:
  • normal (str or sequence of float) – Plane normal: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored). normal='x' maps x -> 2 * position - x.

  • position (float) – Signed distance of the plane from the coordinate origin along normal [meters] (default 0).

  • copy (bool, optional) – Include the original first; defaults to False.

  • unite (bool, optional) – Return a Union of original and image. Requires copy and Solid geometry.

  • group (bool, optional) – Return a Group of original and image, retaining member materials. Requires copy; mutually exclusive with unite.

Returns:

The image alone by default, otherwise [original, image] or the explicitly requested Union or Group.

Return type:

Shape or list of Shape or Union or Group

Examples

Complete a half-modelled power divider into one solid:

full = half.mirrored("x", copy=True, unite=True)

Mirror a feed line onto the far side of a board:

far = line.mirrored("z", position=h / 2)
partition(cutter=None, *, normal=None, position=None)#

Split this solid or sheet into independent connected regions.

Parameters:
  • cutter (Solid or Sheet, optional) – Geometry whose boundary partitions this shape.

  • normal (str or sequence of float, optional) – World normal of a cutting plane. Requires position and excludes cutter.

  • position (float, optional) – Signed plane offset [m], measured as normal dot point.

Returns:

Independently owned regions in kernel order. A non-cut returns one independent region. Order is not persistent across CAD edits.

Return type:

tuple of Solid or Sheet

revolved(axis, angle_deg=360.0, *, origin=(0.0, 0.0, 0.0), material=None)#

Revolve a planar Sheet into an independent Solid.

Parameters:
  • axis (str or sequence of float) – Revolution axis letter or non-zero world vector.

  • angle_deg (float, optional) – Non-zero right-handed angle, at most a full turn, in degrees.

  • origin (tuple of float, optional) – World point on the revolution axis, in metres.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

Returns:

Solid of revolution retaining all holes. A section crossing the axis can produce invalid or self-intersecting geometry.

Return type:

Solid

rotated(axis, angle_deg, origin=(0.0, 0.0, 0.0), *, repeat=1, copy=False, unite=False, group=False)#

Return this shape rotated about an axis.

Parameters:
  • axis (str or sequence of float) – Rotation axis: 'x', 'y', 'z', or any non-zero 3-vector (its length is ignored).

  • angle_deg (float) – Rotation angle [degrees], right-handed about axis. Copy i is rotated by i * angle_deg.

  • origin (tuple of float) – A point on the rotation axis (default: the coordinate origin).

  • repeat (int, optional) – Number of rotated copies at angle_deg through repeat * angle_deg; defaults to 1.

  • copy (bool, optional) – Include the unrotated original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One rotated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

Four posts at 90° spacing around the z axis:

posts = post.rotated("z", 90.0, repeat=3, copy=True, group=True)
scaled(factor, center=(0.0, 0.0, 0.0))#

Return this shape scaled uniformly about a fixed point.

The scaling is uniform in all three directions; there is no per-axis factor, because a non-uniform scaling would turn cylinders into elliptic cylinders and spheres into ellipsoids, which the primitives cannot represent.

Parameters:
  • factor (float) – Uniform scale factor. Note that this is not a way to mirror a shape: a negative factor inverts the shape through center, negating all three axes at once. Use mirrored() for a reflection.

  • center (tuple of float) – Fixed point of the scaling (default: the coordinate origin).

Returns:

The scaled shape; a Group is scaled member by member about the common center.

Return type:

Shape or Group

section(cutter=None, *, normal=None, position=None, filled=False)#

Intersect this solid or sheet with a cutter or world plane.

Parameters:
  • cutter (Solid or Sheet, optional) – Intersecting geometry; excludes a plane declaration.

  • normal (str or sequence of float, optional) – World plane normal; requires position.

  • position (float, optional) – Signed world plane offset [m].

  • filled (bool, optional) – Return planar Profiles with holes instead of boundary Curves. Requires a Solid receiver and an explicit plane.

Returns:

Independent intersection geometry. No intersection returns an empty tuple. A coincident face raises rather than choosing a one-dimensional interpretation.

Return type:

tuple of Curve or Profile

shelled(thickness, *, opening_face_near=None, openings=None)#

Hollow this Solid inward to a constant wall thickness.

Parameters:
  • thickness (float) – Positive wall thickness in metres. The outer footprint is retained.

  • opening_face_near (tuple or list of tuple, optional) – World points selecting temporary face references to leave open. Tied picks raise. Mutually exclusive with openings.

  • openings (FaceRef or FaceSetRef or sequence, optional) – Owned faces to leave open; must belong to this exact receiver. Omit both selection modes for a sealed internal void.

Returns:

Hollow body with inherited material.

Return type:

Solid

Raises:
  • TypeError – For a non-Solid receiver; grow a sheet with thickened() instead.

  • RuntimeError – If the offset cannot form a valid closed body.

swept(spine, *, face_near=None, material=None, frame='corrected_frenet', binormal=None, twist_deg=0.0, draft_deg=0.0, tolerance=None)#

Sweep a planar Sheet along a Curve into an independent Solid.

The actual boundary is translated to the spine start and aligned by the shortest normal-to-tangent rotation, retaining in-plane roll. An already aligned section stays in its actual orientation. For an opposite normal, the section plane’s X axis defines the half-turn. The pipe follows corrected Frenet transport unless another frame is selected explicitly.

Parameters:
  • spine (Curve) – World sweep path.

  • face_near (tuple of float, optional) – For a Solid receiver, select a temporary FaceRef near this world point. Prefer solid.face(...).swept(spine). Tied picks raise. Invalid for standalone sheets.

  • material (Material or str, optional) – Override the section’s material; otherwise it is inherited. Without material the result is a construction solid.

  • frame ({'corrected_frenet', 'frenet', 'fixed', 'fixed_binormal'}, optional) – Transport of the initially aligned section. The default retains corrected Frenet transport. Frenet follows curvature and torsion; fixed keeps sections parallel in world space. Fixed binormal preserves their angular relation to the supplied world direction.

  • binormal (str or tuple of float, optional) – Required only for fixed binormal transport. Must not be parallel to the spine tangent. Path’s up direction does not set this value.

  • twist_deg (float, optional) – Total additional right-hand roll about the transported section normal [degrees], distributed uniformly over spine arc length.

  • draft_deg (float, optional) – Constant section-offset angle [degrees], strictly between -90 and 90. Offset equals travelled arc length times its tangent. Positive values expand the exterior and shrink holes. For perpendicular straight sections this is the wall angle to the sweep direction.

  • tolerance (float, optional) – Sampled section-fitting tolerance [m] for nonzero twist or draft. Defaults to one millionth of the initial profile diagonal.

Returns:

Independent pipe retaining the section’s holes.

Return type:

Solid

tagged_edge(name, *, near=None, curve_type=None)#

Register an immutable named edge selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_edges(name, *, near=None, curve_type=None)#

Register an immutable named set of edges.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • curve_type (str, optional) – line, circle, ellipse, hyperbola, parabola, bezier, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_face(name, *, near=None, normal=None, surface_type=None)#

Register an immutable named face selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_faces(name, *, near=None, normal=None, surface_type=None)#

Register an immutable named set of faces.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

  • normal (str or tuple of float, optional) – Outward unit normal constraint. Curved faces require near; without near this filters planar faces only.

  • surface_type (str, optional) – plane, cylinder, cone, sphere, torus, bspline or other.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

tagged_vertex(name, *, near=None)#

Register an immutable named vertex selection.

Parameters:
  • name (str) – Non-empty name, unique within this topology kind on this owner.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

Returns:

New owner with the selection registered. The receiver is unchanged. Affine transforms preserve it; construction requires provable OCC successors and raises TopologyEvolutionError if identity is lost.

Return type:

Solid

thickened(thickness, *, direction='forward', material=None)#

Grow this sheet into a solid of constant thickness.

A Sheet, including a planar Profile or curved Surface, can be thickened. A planar sheet becomes a slab whose footprint is exactly the sheet, which makes this the direct way from a drawn outline to a metallisation of a given thickness, without spelling out the extrusion vector. A curved sheet is offset along its own normal into a shell of constant thickness. An unsuitable thickness, curvature or sampled surface can prevent the CAD kernel from building a valid offset.

Parameters:
  • thickness (float) – Slab thickness [meters], positive.

  • direction ({"forward", "backward", "symmetric"}) – Which side of the sheet to grow on. "symmetric" puts half the thickness on each side, leaving the sheet as the slab’s mid-plane (planar sheets only). "forward" and "backward" are opposite sides of it; forward follows the oriented sheet normal. For a FaceRef, forward follows its outward normal.

  • material (Material or str, optional) – Material of the slab. Defaults to the sheet’s material. A materialless sheet produces a construction solid for Boolean use.

Returns:

The solid slab.

Return type:

Solid

Raises:
  • TypeError – If this is a solid — use shelled() instead.

  • ValueError – If the thickness or direction is invalid, or symmetric thickening is requested for a curved sheet.

Examples

A copper patch from a drawn outline:

patch = Profile.from_wires(outline).thickened(thickness=35e-6, material=copper)
translated(vector, *, repeat=1, copy=False, unite=False, group=False)#

Return this shape moved by vector.

Parameters:
  • vector (tuple of float) – (dx, dy, dz) translation [meters].

  • repeat (int, optional) – Number of translated copies, starting at one vector displacement. Copy i is moved by i * vector; defaults to 1.

  • copy (bool, optional) – Include the untransformed original first; defaults to False.

  • unite (bool, optional) – Return a Union of the copies. Only Solid geometry is eligible.

  • group (bool, optional) – Return a Group, preserving each member’s material. Mutually exclusive with unite.

Returns:

One translated value by default; otherwise a list, or the explicitly requested Union or Group, including for one copy.

Return type:

Shape or list of Shape or Union or Group

Examples

A row of eight vias, including the original, fused into one body:

fence = via.translated((2e-3, 0, 0), repeat=7, copy=True, unite=True)
vertex(name=None, *, near=None)#

Select one owned vertex, or retrieve a registered name.

Parameters:
  • name (str, optional) – Registered singular selection name; excludes semantic constraints.

  • near (tuple of float, optional) – World point in metres; distance is measured to the complete subshape.

Returns:

Read-only view bound to this Solid. At least one semantic constraint is required for unnamed selection.

Return type:

VertexRef

Raises:
  • TopologySelectionError – If no candidate or matching registered name exists.

  • AmbiguousTopologyError – If a singular selection has equally eligible candidates. Supply additional constraints or use a plural selector deliberately.

volume(scale=None)#

Return the volume enclosed by this shape.

Computed from the CAD kernel’s representation, so it accounts for the true geometry rather than the shape’s nominal parameters: a Boolean difference reports what is left, and a chamfered block reports what the chamfer took away. That makes it the direct way to check a construction — a filling factor, a metal volume, the agreement between two ways of building the same part.

Parameters:

scale (float, optional) – Unit scale factor at which to build the kernel shape. Leave it unset: the scale is then derived from the shape itself so the result is correct for models spanning nanometres to kilometres.

Returns:

Volume in cubic meters. A planar sheet (Profile) has no thickness and reports zero.

Return type:

float

Examples

The fraction of a housing that is metal:

fill = shell.volume() / block.volume()
class magnelio.geo.VertexRef(owner, _shape, _scale, _origin=None)#

Owned vertex with a read-only world-coordinate point.

Parameters:
  • owner (object)

  • _shape (object)

  • _scale (float)

  • _origin (object)

bounding_box()#

Return world-coordinate minimum and maximum corners in metres.

property point#

Vertex coordinates in metres.

Type:

tuple of float

class magnelio.geo.Wrap(target, origin, along, across, u, v, max_strain, tolerance=None)#

Wrap a flat source component onto a target surface chart.

Source points are measured from origin along orthonormal along and across directions, with their cross product as the layer direction. Coordinates (u, v, w) map to S(u, v) + w*n(u, v) over the whole source. The target’s bounded parameter intervals correspond linearly to the declared source intervals. All members of a Group share the map.

Parameters:
  • target (Sheet) – One regular, hole-free target surface face.

  • origin (sequence of float) – World origin of the flat source chart [m].

  • along (str or sequence of float) – Perpendicular world directions of the source chart.

  • across (str or sequence of float) – Perpendicular world directions of the source chart.

  • u (pair of float) – Source intervals covered by the target surface [m].

  • v (pair of float) – Source intervals covered by the target surface [m].

  • max_strain (float) – Required upper bound on sampled principal in-plane stretch or compression of the neutral surface.

  • tolerance (float, optional) – Absolute sampled CAD approximation budget [m]. Defaults to one millionth of the source/target extent, subject to CAD resolution.

Notes

The mapping can change lengths and volume. The strain, fold and CAD fit checks are sampled, not global certificates. A source must lie completely within the declared chart. Periodic targets need one explicitly cut chart; crossing its seam is not inferred.

magnelio.geo.insert(*bodies, priorities, voids=())#

Trim overlapping material bodies according to explicit priorities.

Every retained region keeps the material of its source body. A body with a larger priority wins any shared volume. Equal-priority bodies may be disjoint, but overlapping equal-priority bodies raise an error. Void tools remove volume from every body and are absent from the result.

Parameters:
  • *bodies (Solid) – Physical bodies, each carrying a material.

  • priorities (sequence of int) – One priority per body; larger values win. Priorities govern geometry independently of the order in which the result enters a model.

  • voids (sequence of Solid, optional) – Material-less construction solids subtracted from every body.

Returns:

Material-preserving, non-overlapping retained bodies. Fully removed unnamed bodies are omitted. The Group can be added to a GeometryModel.

Return type:

Group

Raises:
  • ValueError – If priorities leave an actual overlap unresolved.

  • TopologyEvolutionError – If trimming deletes or ambiguously splits a named selection.

Examples

Give a dielectric insert priority over its metal housing:

assembly = insert(housing, dielectric, priorities=(0, 1))
model.add(assembly)