Tree — leaf nodes#

Leaves are terminal Node subclasses: they do not wrap other nodes as children. They are where concrete implicit geometry and sources live—analytic primitives, meshes, CAD imports, lattices, extruded profiles, and signed-distance fields.

Nodes that combine or transform subtrees are composition operators; see Tree — composition nodes.

class pyvcad.Function#

A function geometry primitive/leaf node. This is analogous to an F-rep. Functions can be defined in Cartesian, cylindrical, or spherical coordinates.

__init__(*args, **kwargs)#

Overloaded function.

  1. __init__(self: pyvcad.pyvcad.Function, function: str, min: pyvcad.pyvcad.Vec3 = <pyvcad.pyvcad.Vec3 object at 0x1077c24b0>, max: pyvcad.pyvcad.Vec3 = <pyvcad.pyvcad.Vec3 object at 0x1077da4f0>) -> None

Constructor that takes a math expression string to evaluate and a bounding box.

Parameters:
  • function (string) – The function expression to evaluate. This can be any math expression, such as x^2 + y^2 + z^2 - 1.

  • min (glm::vec3) – The minimum bounding box coordinates.

  • max (glm::vec3) – The maximum bounding box coordinates.

  1. __init__(self: pyvcad.pyvcad.Function, function: object, min: pyvcad.pyvcad.Vec3 = <pyvcad.pyvcad.Vec3 object at 0x1077c26b0>, max: pyvcad.pyvcad.Vec3 = <pyvcad.pyvcad.Vec3 object at 0x1077da6f0>) -> None

Constructor that takes a callable to evaluate and a bounding box.

The callable must return the signed distance to the surface for a given point. Two kinds of callable are accepted:

  • A numba.cfunc with signature float64(float64, float64, float64) -> (x, y, z). This is dispatched through the native function pointer and is the fast path.

  • A plain Python callable taking eight doubles (x, y, z, rho, phic, r, theta, phis). This is supported for convenience but is slow (a Python call per evaluation).

Parameters:
  • function (callable) – The signed-distance callable (numba.cfunc preferred).

  • min (glm::vec3) – The minimum bounding box coordinates.

  • max (glm::vec3) – The maximum bounding box coordinates.

Example

>>> from numba import cfunc, types
>>> import math
>>> @cfunc(types.float64(types.float64, types.float64, types.float64))
... def gyroid(x, y, z):
...     f = 2.0 * math.pi / 10.0
...     return (math.sin(f*x)*math.cos(f*y) + math.sin(f*y)*math.cos(f*z)
...             + math.sin(f*z)*math.cos(f*x))
>>> node = pv.Function(gyroid, pv.Vec3(-15, -15, -15), pv.Vec3(15, 15, 15))
class pyvcad.Mesh#

A mesh geometry primitive/leaf node. The mesh is loaded from a file and converted into a signed distance field using OpenVDB.

__init__(*args, **kwargs)#

Overloaded function.

  1. __init__(self: pyvcad.pyvcad.Mesh, path: str, center: bool = False, disable_validation: bool = False, override_voxel_size: typing.SupportsFloat | None = None, compensate_slicer_ras: bool = False) -> None

Creates a Mesh from a file path.

Parameters:
  • path (string) – The path to the mesh file to load.

  • center (bool) – If true, the mesh will be centered at the origin after loading.

  • disable_validation (bool) – If true, the mesh will not be validated for errors.

  • override_voxel_size (float, optional) – Explicit voxel size to use when voxelizing the mesh into an SDF.

  • compensate_slicer_ras (bool) – If true, mirrors the mesh across Y to compensate for 3D Slicer RAS mesh exports used with DICOMLoader volumes.

Example

>>> import pyvcad as pv
>>> node = pv.Mesh('model.stl', center=True, override_voxel_size=0.1)
  1. __init__(self: pyvcad.pyvcad.Mesh, path: str, sample_size: pyvcad.pyvcad.Vec3, center: bool = False, disable_validation: bool = False, override_voxel_size: typing.SupportsFloat | None = None, compensate_slicer_ras: bool = False) -> None

Creates a Mesh from a file path and sample size.

Parameters:
  • path (string) – The path to the mesh file to load.

  • sample_size (Vec3) – The voxel size to use when voxelizing the mesh into an SDF.

  • center (bool) – If true, the mesh will be centered at the origin after loading.

  • disable_validation (bool) – If true, the mesh will not be validated for errors.

  • override_voxel_size (float, optional) – Explicit voxel size to use when voxelizing the mesh into an SDF. If provided, this takes precedence over sample_size.

  • compensate_slicer_ras (bool) – If true, mirrors the mesh across Y to compensate for 3D Slicer RAS mesh exports used with DICOMLoader volumes.

Example

>>> import pyvcad as pv
>>> node = pv.Mesh('model.stl', pv.Vec3(0.1, 0.1, 0.1), center=True)
  1. __init__(self: pyvcad.pyvcad.Mesh, mesh: pyvcad.pyvcad.SurfaceMesh, center: bool = False, override_voxel_size: typing.SupportsFloat | None = None, compensate_slicer_ras: bool = False) -> None

Creates a Mesh from an existing SurfaceMesh.

Parameters:
  • mesh (SurfaceMesh) – The mesh to load.

  • center (bool) – If true, the mesh will be centered at the origin before voxelization.

  • override_voxel_size (float, optional) – Explicit voxel size to use when voxelizing the mesh into an SDF.

  • compensate_slicer_ras (bool) – If true, mirrors the mesh across Y to compensate for 3D Slicer RAS mesh exports used with DICOMLoader volumes.

Example

>>> import pyvcad as pv
>>> surface = pv.SurfaceMesh('model.stl')
>>> node = pv.Mesh(surface, center=True, override_voxel_size=0.1)
class pyvcad.TexturedMesh#

A closed 3MF or OBJ textured solid with an intrinsic volumetric COLOR_RGBA field.

__init__(self: pyvcad.pyvcad.TexturedMesh, path: str, color_depth: SupportsFloat = 1.0, core_color: pyvcad.pyvcad.Vec3 = <pyvcad.pyvcad.Vec3 object at 0x1077db370>, fallback_color: pyvcad.pyvcad.Vec3 | None = None, center: bool = False, obj_unit_scale: SupportsFloat = 1.0, override_voxel_size: SupportsFloat | None = None, disable_validation: bool = False) → None#

Loads a closed textured 3MF or OBJ solid. Surface color is extended inward from the closest surface point during prepare(). Source alpha is ignored and the intrinsic COLOR_RGBA field is opaque.

Parameters:
  • path (string) – Path to a .3mf or .obj file. OBJ dependencies resolve relative to this path.

  • color_depth (float) – Inward textured-shell depth in millimeters.

  • core_color (Vec3) – RGB color below the shell, with components in [0, 1].

  • fallback_color (Vec3, optional) – RGB color for triangles that have no imported appearance.

  • center (bool) – If true, center the resolved scene at the origin.

  • obj_unit_scale (float) – Millimeters per OBJ coordinate unit; 3MF units are automatic.

  • override_voxel_size (float, optional) – Explicit SDF and color-shell preparation voxel size.

  • disable_validation (bool) – Bypass closed-manifold validation for imperfect scans.

Example

>>> import pyvcad as pv
>>> node = pv.TexturedMesh('model.3mf', color_depth=1.0, center=True)
color_depth(self: pyvcad.pyvcad.TexturedMesh) → float#

Returns the inward textured-shell depth.

Parameters:

arguments. (This method takes no)

Example

>>> depth = node.color_depth()
core_color(self: pyvcad.pyvcad.TexturedMesh) → pyvcad.pyvcad.Vec3#

Returns the opaque core RGB color.

Parameters:

arguments. (This method takes no)

Example

>>> color = node.core_color()
obj_unit_scale(self: pyvcad.pyvcad.TexturedMesh) → float#

Returns the OBJ millimeters-per-source-unit scale.

Parameters:

arguments. (This method takes no)

Example

>>> scale = node.obj_unit_scale()
class pyvcad.RectPrism#

A rectangular prism leaf node/geometric primitive. This node is a rectangular prism with a center point, size, and material ID.

static FromMinAndMax(min: pyvcad.pyvcad.Vec3, max: pyvcad.pyvcad.Vec3) → pyvcad.pyvcad.RectPrism#

Create a RectPrism from the given minimum and maximum points.

Parameters:
  • min (vec3) – The minimum point of the RectPrism.

  • max (vec3) – The maximum point of the RectPrism.

Returns:

The created RectPrism.

Return type:

RectPrism

__init__(*args, **kwargs)#

Overloaded function.

  1. __init__(self: pyvcad.pyvcad.RectPrism) -> None

Default constructor. Creates a RectPrism with a center of (0, 0, 0), size of (1, 1, 1).

  1. __init__(self: pyvcad.pyvcad.RectPrism, center: pyvcad.pyvcad.Vec3, size: pyvcad.pyvcad.Vec3) -> None

Constructor. Creates a RectPrism with a center, size.

Parameters:
  • center (vec3) – The center point of the RectPrism.

  • size (vec3) – The side length of the RectPrism.

class pyvcad.Sphere#

A sphere leaf node/geometric primitive. This node is a sphere with a center point, radius

__init__(*args, **kwargs)#

Overloaded function.

  1. __init__(self: pyvcad.pyvcad.Sphere) -> None

Default constructor. Creates a Sphere with a center of (0, 0, 0), radius of 1

Example

>>> from libvcad import pyvcad as pv
>>> sphere = pv.Sphere()
  1. __init__(self: pyvcad.pyvcad.Sphere, center: pyvcad.pyvcad.Vec3, radius: typing.SupportsFloat) -> None

Constructor. Creates a Sphere with a center, radius, and material id.

Parameters:
  • center (vec3) – The center point of the Sphere.

  • radius (double) – The radius of the Sphere.

class pyvcad.Strut#

A leaf node that represents a strut. A strut is the conical frustum swept between two points, closed by a capping mode at each end.

__init__(*args, **kwargs)#

Overloaded function.

  1. __init__(self: pyvcad.pyvcad.Strut, start: pyvcad.pyvcad.Vec3, end: pyvcad.pyvcad.Vec3, radius: typing.SupportsFloat) -> None

Constructor. Creates a capsule shaped Strut with a start point, end point, and one radius.

Parameters:
  • start (vec3) – The start point of the strut.

  • end (vec3) – The end point of the strut.

  • radius (double) – The radius of the strut.

Example

>>> from libvcad import pyvcad as pv
>>> strut = pv.Strut(pv.vec3(0, 0, 0), pv.vec3(10, 0, 0), 1.0)
  1. __init__(self: pyvcad.pyvcad.Strut, start: pyvcad.pyvcad.Vec3, end: pyvcad.pyvcad.Vec3, start_radius: typing.SupportsFloat, end_radius: typing.SupportsFloat, start_cap: pyvcad.pyvcad.CapMode = <CapMode.Sphere: 0>, end_cap: pyvcad.pyvcad.CapMode = <CapMode.Sphere: 0>) -> None

Constructor. Creates a Strut with an independent radius and cap mode at each end.

Parameters:
  • start (vec3) – The start point of the strut.

  • end (vec3) – The end point of the strut.

  • start_radius (double) – The radius at the start point.

  • end_radius (double) – The radius at the end point.

  • start_cap (CapMode) – The capping mode at the start point. Defaults to CapMode.Sphere.

  • end_cap (CapMode) – The capping mode at the end point. Defaults to CapMode.Sphere.

Example

>>> from libvcad import pyvcad as pv
>>> beam = pv.Strut(pv.vec3(0, 0, 0), pv.vec3(10, 0, 0), 1.0, 3.0, pv.CapMode.Butt, pv.CapMode.Sphere)
property end#

The end point of the strut.

property end_cap#

The capping mode at the end point.

property end_radius#

The radius at the end point.

property start#

The start point of the strut.

property start_cap#

The capping mode at the start point.

property start_radius#

The radius at the start point.

class pyvcad.CAD#

A CAD geometry primitive/leaf node. The CAD is loaded from a file into memory for sampling. The node supports .STEP and .igs files. NOTE: using fast mode will convert the CAD model into a mesh for faster sampling. This hurts acuracy but dramatically speeds up performance. For the Inkjet compiler fast mode is recommended.

__init__(self: pyvcad.pyvcad.CAD, path: str, use_fast_mode: bool = True, fast_sdf_voxel_size: SupportsFloat | None = None) → None#

Constructor that takes a path to the CAD file to load.

Parameters:
  • path (string) – The path to the CAD file to load.

  • use_fast_mode (bool) – Whether to build an accelerated SDF cache during prepare.

  • fast_sdf_voxel_size (float | None) – Optional uniform SDF cache spacing in millimetres. None uses the smallest sampling voxel dimension.

property fast_sdf_voxel_size#

Requested uniform fast-SDF cache spacing in millimetres, or None for the sampler-derived default.

property prepared_fast_sdf_voxel_size#

Uniform fast-SDF cache spacing used by the latest prepare call, or None before preparation.

class pyvcad.Cylinder#

A cylinder leaf node/ geometric primitive. The cylinder is aligned along the Z-axis, standing upright, and centered at (0,0,0).

__init__(*args, **kwargs)#

Overloaded function.

  1. __init__(self: pyvcad.pyvcad.Cylinder) -> None

Default constructor. Creates a Cylinder with a center of (0,0,0), radius of 1, height of 1.

  1. __init__(self: pyvcad.pyvcad.Cylinder, center: pyvcad.pyvcad.Vec3, radius: typing.SupportsFloat, height: typing.SupportsFloat) -> None

Constructor. Creates a Cylinder with a center, radius, height.

Parameters:
  • center (vec3) – The center point of the Cylinder.

  • radius (double) – The radius of the Cylinder.

  • height (double) – The height of the Cylinder.

class pyvcad.Cone#

A cone leaf node/geometric primitive.

__init__(*args, **kwargs)#

Overloaded function.

  1. __init__(self: pyvcad.pyvcad.Cone) -> None

Default constructor. Creates a Cone with default dimensions.

  1. __init__(self: pyvcad.pyvcad.Cone, angle: typing.SupportsFloat, height: typing.SupportsFloat) -> None

Constructor. Creates a Cone defined by an angle and height.

Parameters:
  • angle (double) – The aperture half-angle in radians.

  • height (double) – The height of the cone.

class pyvcad.Torus#

A torus leaf node/geometric primitive. This node is a torus with a major and minor radius

__init__(*args, **kwargs)#

Overloaded function.

  1. __init__(self: pyvcad.pyvcad.Torus) -> None

Default constructor. Creates a Torus with a center of (0, 0, 0), major radius of 2 and minor radius of 1.

  1. __init__(self: pyvcad.pyvcad.Torus, r1: typing.SupportsFloat, r2: typing.SupportsFloat) -> None

Constructor. Creates a Torus with a major and minor radii.

Parameters:
  • r1 (double) – Major radius.

  • r2 (double) – Minor radius.

class pyvcad.GraphLattice#

A graph lattice leaf node. This class represents a lattice structure defined by a set of edges and a radius for the struts.

__init__(*args, **kwargs)#

Overloaded function.

  1. __init__(self: pyvcad.pyvcad.GraphLattice, edges: collections.abc.Sequence[tuple[pyvcad.pyvcad.Vec3, pyvcad.pyvcad.Vec3]], radius: typing.SupportsFloat) -> None

Constructor. Creates a GraphLattice with edges, radius, and material.

Parameters:
  • edges (List[Tuple[Vec3, Vec3]]) – The edges of the lattice.

  • radius (float) – The radius of the struts.

  1. __init__(self: pyvcad.pyvcad.GraphLattice, type: pyvcad.pyvcad.LatticeType, size: pyvcad.pyvcad.Vec3, radius: typing.SupportsFloat) -> None

Constructor. Creates a GraphLattice with a lattice type, size, radius.

Parameters:
  • type (LatticeType) – The type of the lattice (BodyCenteredCubic, FaceCenteredCubic, Cubic, or KelvinCell).

  • size (Vec3) – The size of the lattice unit cell.

  • radius (float) – The radius of the struts.

class pyvcad.BeamLattice#

A beam and ball lattice defined over a shared vertex list, following the geometry model of the 3MF Beam Lattice Extension.

__init__(self: pyvcad.pyvcad.BeamLattice, vertices: collections.abc.Sequence[pyvcad.pyvcad.Vec3], beams: collections.abc.Sequence[pyvcad.pyvcad.Beam], radius: typing.SupportsFloat, min_length: typing.SupportsFloat = 0.0, cap: pyvcad.pyvcad.CapMode = <CapMode.Sphere: 0>, ball_mode: pyvcad.pyvcad.BallMode = <BallMode.None_: 0>, ball_radius: typing.SupportsFloat = 0.0, balls: collections.abc.Sequence[pyvcad.pyvcad.Ball] = []) → None#

Constructor. Creates a BeamLattice from a vertex list and a list of beams.

Parameters:
  • vertices (List[Vec3]) – The shared vertex list that beams and balls index into.

  • beams (List[Beam]) – The beams of the lattice.

  • radius (float) – The default beam radius, used when a beam does not specify one.

  • min_length (float) – Beams shorter than this length are discarded. Defaults to 0.

  • cap (CapMode) – The default cap mode. Defaults to CapMode.Sphere.

  • ball_mode (BallMode) – Whether balls are generated. Defaults to no balls.

  • ball_radius (float) – The default ball radius. Required when balls are enabled.

  • balls (List[Ball]) – Explicit per-vertex ball entries. Defaults to an empty list.

Example

>>> from libvcad import pyvcad as pv
>>> vertices = [pv.vec3(0, 0, 0), pv.vec3(10, 0, 0)]
>>> lattice = pv.BeamLattice(vertices, [pv.Beam(0, 1)], 1.0)
>>> lattice.prepare(pv.vec3(0.25), 1.0)
property active_ball_count#

The number of balls that were generated.

property active_beam_count#

The number of beams that survived the min_length filter.

property ball_mode#

The ball mode.

property ball_radius#

The default ball radius.

property balls#

The explicit ball entries as supplied.

property beams#

The beams as supplied, including any dropped by min_length.

property cap#

The default cap mode.

property min_length#

The minimum beam length.

property radius#

The default beam radius.

property vertices#

The shared vertex list.

class pyvcad.Beam#

One beam of a BeamLattice. Unset radii and cap modes fall back to the lattice defaults.

__init__(self: pyvcad.pyvcad.Beam, v1: SupportsInt, v2: SupportsInt, r1: SupportsFloat | None = None, r2: SupportsFloat | None = None, cap1: pyvcad.pyvcad.CapMode | None = None, cap2: pyvcad.pyvcad.CapMode | None = None) → None#

Constructor. Creates a Beam between two vertex indices.

Parameters:
  • v1 (int) – Index of the first vertex.

  • v2 (int) – Index of the second vertex.

  • r1 (float) – Radius at v1. Defaults to None, meaning the lattice radius.

  • r2 (float) – Radius at v2. Defaults to None, meaning r1.

  • cap1 (CapMode) – Cap at v1. Defaults to None, meaning the lattice cap mode.

  • cap2 (CapMode) – Cap at v2. Defaults to None, meaning the lattice cap mode.

Example

>>> from libvcad import pyvcad as pv
>>> beam = pv.Beam(0, 1, r1=1.0, r2=2.0, cap2=pv.CapMode.Butt)
property cap1#

Cap mode at v1, or None to use the lattice cap mode.

property cap2#

Cap mode at v2, or None to use the lattice cap mode.

property r1#

Radius at v1, or None to use the lattice radius.

property r2#

Radius at v2, or None to use r1.

property v1#

Index of the first vertex.

property v2#

Index of the second vertex.

class pyvcad.Ball#

One ball of a BeamLattice, centred on a vertex.

__init__(self: pyvcad.pyvcad.Ball, vertex: SupportsInt, radius: SupportsFloat | None = None) → None#

Constructor. Creates a Ball centred on a vertex index.

Parameters:
  • vertex (int) – Index of the vertex the ball is centred on.

  • radius (float) – Ball radius. Defaults to None, meaning the lattice ball radius.

Example

>>> from libvcad import pyvcad as pv
>>> ball = pv.Ball(3, radius=2.0)
property radius#

Ball radius, or None to use the lattice ball radius.

property vertex#

Index of the vertex the ball is centred on.

class pyvcad.ThreeMFBeamLattice#

Imports a 3MF Beam Lattice Extension file as an implicit tree. Covers geometry only; per-beam property references are not read.

__init__(self: pyvcad.pyvcad.ThreeMFBeamLattice, path: str, object_id: SupportsInt | None = None, include_triangle_mesh: bool = True, apply_clipping: bool = True, use_representation_mesh: bool = False, mesh_voxel_size: SupportsFloat | None = None) → None#

Constructor. Imports the beam lattice geometry of a 3MF file.

Parameters:
  • path (str) – The path to the .3mf file.

  • object_id (int) – Imports only this object resource id. Defaults to None, the whole build.

  • include_triangle_mesh (bool) – Unions each object’s triangle shell with its lattice. Defaults to True.

  • apply_clipping (bool) – Applies the lattice clipping mode against its clipping mesh. Defaults to True.

  • use_representation_mesh (bool) – Substitutes the representation mesh for the lattice.

  • preview (The specification restricts representation meshes to display and)

  • part (so a)

  • False. (must not be manufactured from that result. Defaults to)

  • mesh_voxel_size (float) – Explicit voxel size for triangle and clipping meshes. Defaults to None.

Example

>>> from libvcad import pyvcad as pv
>>> lattice = pv.ThreeMFBeamLattice('pyramid.3mf')
>>> lattice.prepare(pv.vec3(0.5), 1.0)
property ball_count#

The total number of explicit balls across the imported objects.

property beam_count#

The total number of beams across the imported objects.

property file_path#

The source file path.

property imported_objects#

The objects that were imported into the tree.

property scene#

The scene that was read from the file.

class pyvcad.ThreeMFBeamLatticeObject#

One mesh object resolved from a 3MF build, with its beam lattice if it carries one. Coordinates are in millimeters and already carry the build transforms.

property ball_mode#

The ball mode.

property ball_radius#

The default ball radius.

property balls#

The explicit ball entries of the lattice.

property beams#

The beams of the lattice.

property cap#

The default cap mode, derived from the resolved beam cap modes.

property clip_mode#

The clipping mode of the lattice.

property clip_triangles#

Clipping mesh triangles, as (i, j, k) vertex index tuples.

property clip_vertices#

Clipping mesh vertices, under the same transform.

property clipping_mesh_id#

The resource id of the clipping mesh, or None.

property has_lattice#

True when the object carries a beam lattice.

property min_length#

The minimum beam length.

property name#

The object name, when the file supplies one.

property object_id#

The 3MF resource id of the object.

property radius#

The default beam radius, derived from the resolved beam radii.

property representation_mesh_id#

The resource id of the representation mesh, or None.

property representation_triangles#

Representation mesh triangles, as (i, j, k) vertex index tuples.

property representation_vertices#

Representation mesh vertices, under the same transform.

property triangles#

The triangle shell of the same object, as (i, j, k) vertex index tuples.

property vertices#

The mesh vertex list beams index into.

class pyvcad.ThreeMFBeamLatticeScene#

The resolved contents of a 3MF file read through the Beam Lattice Extension.

property objects#

Objects in build order.

property unit_scale_mm#

Millimeters per source model unit.

pyvcad.read_3mf_beam_lattice(path: str) → pyvcad.pyvcad.ThreeMFBeamLatticeScene#

Reads the geometry of a 3MF file, including any beam lattices, without building a tree.

Every build item is resolved through its component graph, transforms are baked into the returned coordinates, and coordinates are converted to millimeters. Beam and ball property references are not read; this importer covers geometry only.

Parameters:

path (str) – The path to the .3mf file.

Example

>>> from libvcad import pyvcad as pv
>>> scene = pv.read_3mf_beam_lattice('pyramid.3mf')
>>> len(scene.objects[0].beams)
class pyvcad.MappedImplicitLattice#

A metric-corrected periodic implicit lattice evaluated through a CellMap.

__init__(self: pyvcad.pyvcad.MappedImplicitLattice, cell_map: pyvcad.pyvcad.CellMap, unit_cell: pyvcad.pyvcad.ImplicitUnitCell, mode: str = 'sheet', wall_thickness: object = None, level: object = None) → None#

Construct a mapped implicit lattice node.

Parameters:
  • cell_map (CellMap) – Immutable coordinate map.

  • unit_cell (ImplicitUnitCell) – Periodic scalar unit cell.

  • mode (str) – ‘sheet’ or ‘solid’.

  • wall_thickness (FloatAttribute | float | None) – Consumer-relative sheet thickness.

  • level (FloatAttribute | float | None) – Consumer-relative solid level offset.

Example

>>> node = pv.MappedImplicitLattice(cell_map, cell, 'sheet', thickness, level)
property cell_map#

Immutable coordinate map.

property component_side#

Negative or positive side of the underlying TPMS mid-surface.

property component_surface_distance#

Signed distance to the underlying TPMS mid-surface.

property shell#

Repeated implicit shell component.

property unit_cell#

Periodic implicit unit cell.

class pyvcad.MappedGraphLattice#

A compact graph unit cell tiled and curved through a CellMap.

__init__(self: pyvcad.pyvcad.MappedGraphLattice, cell_map: pyvcad.pyvcad.CellMap, unit_cell: pyvcad.pyvcad.GraphUnitCell, beam_radius: object, node_radius: object = None, curve_tolerance: SupportsFloat = 0.05) → None#

Construct a mapped graph lattice node.

Parameters:
  • cell_map (CellMap) – Immutable coordinate map.

  • unit_cell (GraphUnitCell) – Normalized graph unit cell.

  • beam_radius (FloatAttribute | float) – Consumer-relative beam radius.

  • node_radius (FloatAttribute | float | None) – Optional node radius.

  • curve_tolerance (float) – Maximum mapped chord error in millimetres.

Example

>>> node = pv.MappedGraphLattice(cell_map, cell, radius)
property component_direction#

Selected strut tangent as a Vec3Attribute.

property component_id#

Selected component ID as a float attribute.

property component_material_tag#

Selected component legacy material tag as a float attribute.

property component_orientation_tag#

Selected component orientation tag as a float attribute.

property component_parameter#

Axial fraction along the selected strut.

property component_surface_distance#

Signed distance to the selected graph component.

property component_tag#

Selected component topology tag as a float attribute.

property joints#

Reusable unit-cell joint components.

segment_info(self: pyvcad.pyvcad.MappedGraphLattice, world: pyvcad.pyvcad.Vec3) → object#

Return provenance for the nearest prepared beam segment inside the mapped domain.

Parameters:

world (Vec3) – World coordinate to inspect.

property struts#

Reusable unit-cell strut components.

class pyvcad.MappedGraphSegmentInfo#

Unit-cell provenance for the nearest prepared mapped graph segment.

class pyvcad.Text#

A text leaf node which generates a 3D text object by extruding the text along the Z-axis. The node takes a string, height, depth, material id, font aspect, font name, and alignment options. The CAD part is created from the provided text.

__init__(self: pyvcad.pyvcad.Text, text: str, height: SupportsFloat, depth: SupportsFloat, aspect: pyvcad.pyvcad.FontAspect = <FontAspect.Regular: 0>, font: str = 'Consolas', h_align: pyvcad.pyvcad.HorizontalAlignment = <HorizontalAlignment.Center: 1>, v_align: pyvcad.pyvcad.VerticalAlignment = <VerticalAlignment.Center: 1>) → None#

Constructor. Creates a Text node with the provided text content, height, depth, material id, font aspect, font name and alignment options.

Parameters:
  • text (str) – The text content for the 3D text.

  • height (float) – The height of the text.

  • depth (float) – The extrusion depth of the text.

  • aspect (FontAspect, optional) – The font aspect. Defaults to FontAspect.Regular.

  • font (str, optional) – The name of the font to use. Defaults to Consolas.

  • h_align (HorizontalAlignment, optional) – Horizontal alignment of the text. Defaults to Center.

  • v_align (VerticalAlignment, optional) – Vertical alignment of the text. Defaults to Center.

class pyvcad.SignedDistanceField#

Represents a signed distance field using OpenVDB.

__init__(*args, **kwargs)#

Overloaded function.

  1. __init__(self: pyvcad.pyvcad.SignedDistanceField) -> None

  2. __init__(self: pyvcad.pyvcad.SignedDistanceField, grid: openvdb::v13_0::Grid<openvdb::v13_0::tree::Tree<openvdb::v13_0::tree::RootNode<openvdb::v13_0::tree::InternalNode<openvdb::v13_0::tree::InternalNode<openvdb::v13_0::tree::LeafNode<float, 3u>, 4u>, 5u>>>>) -> None

  3. __init__(self: pyvcad.pyvcad.SignedDistanceField, occupancy_grid: openvdb::v13_0::Grid<openvdb::v13_0::tree::Tree<openvdb::v13_0::tree::RootNode<openvdb::v13_0::tree::InternalNode<openvdb::v13_0::tree::InternalNode<openvdb::v13_0::tree::LeafNode<bool, 3u>, 4u>, 5u>>>>, half_width_voxels: typing.SupportsInt = 3, closing_steps: typing.SupportsInt = 0, dilation_voxels: typing.SupportsInt = 0, smoothing_steps: typing.SupportsInt = 3) -> None

Create a SignedDistanceField from an OpenVDB BoolGrid occupancy grid.

The topology options are passed to OpenVDB topologyToLevelSet(). They only apply when converting boolean occupancy grids. The defaults preserve OpenVCAD’s existing conversion behavior.

Parameters:
  • occupancy_grid – BoolGrid whose active voxels represent occupied space.

  • half_width_voxels – Half the width of the generated narrow-band level set, in voxel units.

  • closing_steps – Number of morphological closing steps used to fill gaps in the active voxel region.

  • dilation_voxels – Number of voxels to expand the active voxel region before conversion.

  • smoothing_steps – Number of smoothing iterations applied after level-set generation.

  1. __init__(self: pyvcad.pyvcad.SignedDistanceField, vdb_volume: VDBVolume<openvdb::v13_0::Grid<openvdb::v13_0::tree::Tree<openvdb::v13_0::tree::RootNode<openvdb::v13_0::tree::InternalNode<openvdb::v13_0::tree::InternalNode<openvdb::v13_0::tree::LeafNode<float, 3u>, 4u>, 5u>>>>>) -> None

  2. __init__(self: pyvcad.pyvcad.SignedDistanceField, vdb_file_path: str, grid_name: str = ‘occupancy’, half_width_voxels: typing.SupportsInt = 3, closing_steps: typing.SupportsInt = 0, dilation_voxels: typing.SupportsInt = 0, smoothing_steps: typing.SupportsInt = 3) -> None

Create a SignedDistanceField from a VDB file.

The named grid may be either a FloatGrid signed distance field or a BoolGrid occupancy grid. FloatGrid inputs are used directly, and the topology options are ignored. BoolGrid inputs are converted with OpenVDB topologyToLevelSet() using the supplied topology options. The defaults preserve OpenVCAD’s existing conversion behavior.

Parameters:
  • vdb_file_path – Path to the VDB file.

  • grid_name – Name of the grid to load from the file.

  • half_width_voxels – Half the width of the generated narrow-band level set, in voxel units.

  • closing_steps – Number of morphological closing steps used to fill gaps in the active voxel region.

  • dilation_voxels – Number of voxels to expand the active voxel region before conversion.

  • smoothing_steps – Number of smoothing iterations applied after level-set generation.

bounding_box(self: pyvcad.pyvcad.SignedDistanceField) → tuple[pyvcad.pyvcad.Vec3, pyvcad.pyvcad.Vec3]#
clone(self: pyvcad.pyvcad.SignedDistanceField) → pyvcad.pyvcad.Node#
evaluate(self: pyvcad.pyvcad.SignedDistanceField, x: SupportsFloat, y: SupportsFloat, z: SupportsFloat) → float | None#
prepare(self: pyvcad.pyvcad.SignedDistanceField, voxel_size: pyvcad.pyvcad.Vec3, bandwidth: SupportsFloat) → None#
save_openvdb_occupancy_grid(self: pyvcad.pyvcad.SignedDistanceField, file_path: str) → None#

Save this node as a single OpenVDB BoolGrid named ‘occupancy’. Active SDF voxels with values <= 0 are occupied.

save_openvdb_sdf_grid(self: pyvcad.pyvcad.SignedDistanceField, file_path: str) → None#

Save this node as a single OpenVDB FloatGrid named ‘surface’.

class pyvcad.SurfaceReliefVolume#

A compact live implicit relief operand over an explicitly selected parametric surface. The operand extends inward by embed_mm and outward by the sampled height. Its zero surface is correct, but the varying-height field is not necessarily an exact Euclidean signed-distance field.

__init__(self: pyvcad.pyvcad.SurfaceReliefVolume, surface: pyvcad.pyvcad.ParametricSurface, height_field: pyvcad.pyvcad.HeightField, embed_mm: SupportsFloat, edge_falloff_mm: SupportsFloat = 0.0) → None#
property edge_falloff_mm#
property embed_mm#
property height_field#
property surface#
class pyvcad.PolygonExtrude#

An extruded polygon leaf node/geometric primitive. Takes a planar polygon defined by 3D vertices and extrudes it along its computed normal (right-hand rule) by a given height.

__init__(*args, **kwargs)#

Overloaded function.

  1. __init__(self: pyvcad.pyvcad.PolygonExtrude) -> None

Default constructor. Creates a unit square in the XY plane extruded 1 unit in +Z.

Example

>>> from libvcad import pyvcad as pv
>>> poly = pv.PolygonExtrude()
  1. __init__(self: pyvcad.pyvcad.PolygonExtrude, vertices: collections.abc.Sequence[pyvcad.pyvcad.Vec3], height: typing.SupportsFloat, symmetric: bool = False) -> None

Constructor. Creates an extruded polygon from coplanar 3D vertices.

Parameters:
  • vertices (list[Vec3]) – The vertices of the planar polygon (minimum 3, must be coplanar).

  • height (float) – The extrusion distance along the polygon normal.

  • symmetric (bool) – If True, extrudes height/2 on each side of the polygon plane.

Example

>>> from libvcad import pyvcad as pv
>>> verts = [pv.Vec3(0,0,0), pv.Vec3(10,0,0), pv.Vec3(10,10,0), pv.Vec3(0,10,0)]
>>> poly = pv.PolygonExtrude(verts, 5.0, False)