Attributes#
In attribute modeling, attributes are typed spatial fields. They acquire a name only when attached to a node in your Node tree. They describe quantities that vary through the interior of a part—modulus, color, material volume fractions, and more—using the same sampling idea as implicit geometry: at each point, the engine evaluates whether you are inside the solid and, when you are, evaluates the attached fields at that location.
Conceptually, each attribute implements a sample at (x, y, z) together with the signed distance d to the surface. Expression strings (see the math expressions guide) can use coordinates and d; results are aggregated under string names so renderers and compilers can pick them up consistently.
Interface you use in Python
Attach fields to geometry with
node.set_attribute(name, attribute).Use canonical names from
DefaultAttributes(e.g.MODULUS,COLOR_RGBA,VOLUME_FRACTIONS) so downstream tools know which field to read.``FloatAttribute`` — one scalar per point (physical scalars, temperatures, etc.).
``Vec3Attribute`` — three components per point, with composition methods for directions and displacements.
``Vec4Attribute`` — four components per point (typical use: linear RGBA in
[0, 1]).``VolumeFractionsAttribute`` — maps material IDs to fractions at each point; fractions should sum to 1 where mixtures apply.
Python function support is Numba-only. Use
numba.cfuncwith the signaturefloat64(float64, float64, float64, float64). Field-valued parameters also accept a plain callable and compile it with numba for you (seeas_float_attribute).
Attributes are only evaluated where the geometry exists (inside or on the surface), so expensive expressions are not run in empty space.
Examples#
The patterns below mirror the getting-started guide (lessons 4–6); they show the minimal attach-and-name workflow.
Scalar field (constant or expression)
import pyvcad as pv
cube = pv.RectPrism(pv.Vec3(0, 0, 0), pv.Vec3(10, 10, 10))
cube.set_attribute(pv.DefaultAttributes.MODULUS, pv.FloatAttribute(5.0))
cube = pv.RectPrism(pv.Vec3(0, 0, 0), pv.Vec3(10, 10, 50))
cube.set_attribute(
pv.DefaultAttributes.MODULUS,
pv.FloatAttribute("0.18 * z + 5.5"),
)
Scalar field (Numba function)
import pyvcad as pv
from numba import cfunc, types
@cfunc(types.float64(types.float64, types.float64, types.float64, types.float64))
def modulus_gradient(x, y, z, d):
return 0.18 * z + 5.5
cube = pv.RectPrism(pv.Vec3(0, 0, 0), pv.Vec3(10, 10, 50))
cube.set_attribute(
pv.DefaultAttributes.MODULUS,
pv.FloatAttribute(modulus_gradient),
)
RGBA color field
cube = pv.RectPrism(pv.Vec3(0, 0, 0), pv.Vec3(50, 10, 10))
color = pv.Vec4Attribute("x/50 + 0.5", "-x/50 + 0.5", "x/50 + 0.5", "1.0")
cube.set_attribute(pv.DefaultAttributes.COLOR_RGBA, color)
Volume fractions (multi-material)
materials = pv.default_materials
cube = pv.RectPrism(pv.Vec3(0, 0, 0), pv.Vec3(50, 10, 10))
cube.set_attribute(
pv.DefaultAttributes.VOLUME_FRACTIONS,
pv.VolumeFractionsAttribute(
[
("x/50 + 0.5", materials.id("blue")),
("-x/50 + 0.5", materials.id("red")),
]
),
)
See Getting Started with OpenVCAD for full lessons, hierarchy/priority rules, and expression details. See also the Python functions guide at Python Functions for Attributes.
Core types#
- class pyvcad.Attribute#
Base class for all attributes.
Defines the common interface for sampling an attribute map, including material volume fractions and values like density or elastic modulus.
- class ReturnType#
Value type an attribute produces when sampled.
Members:
none : No value (unknown name or missing sample).
dbl : A float.
vec3 : A Vec3.
vec4 : A Vec4.
vfm_ptr : A volume-fraction dict (material id to fraction).
- __init__(self: pyvcad.pyvcad.Attribute.ReturnType, value: SupportsInt | SupportsIndex) None#
- dbl = <ReturnType.dbl: 0>#
- Attribute.ReturnType.name -> str
- none = <ReturnType.none: -1>#
- property value#
- vec3 = <ReturnType.vec3: 1>#
- vec4 = <ReturnType.vec4: 2>#
- vfm_ptr = <ReturnType.vfm_ptr: 3>#
- __init__(*args, **kwargs)#
- clone(self: pyvcad.pyvcad.Attribute) pyvcad.pyvcad.Attribute#
Returns an independent deep copy of the attribute.
- Returns:
The copy.
- Return type:
- return_type(self: pyvcad.pyvcad.Attribute) pyvcad.pyvcad.Attribute.ReturnType#
Returns the return type of the attribute.
- Returns:
The type of value sample() produces.
- Return type:
- sample(self: pyvcad.pyvcad.Attribute, x: SupportsFloat | SupportsIndex, y: SupportsFloat | SupportsIndex, z: SupportsFloat | SupportsIndex, d: SupportsFloat | SupportsIndex) object#
Samples the attribute at the given point.
- Parameters:
x (float) – The x-coordinate of the point to sample.
y (float) – The y-coordinate of the point to sample.
z (float) – The z-coordinate of the point to sample.
d (float) – The signed distance to the surface.
- Returns:
- The value, by return_type(): a float,
a Vec3, a Vec4, or a material id to volume fraction dict.
- Return type:
- class pyvcad.FloatAttribute#
A scalar attribute defined by a constant, math expression, numba.cfunc callback or FloatVolume.
The source is set once, by the constructor or by one setter. set_expression(), set_function(), set_value() and set_volume() raise RuntimeError if a source is already set.
Example
>>> import pyvcad as pv >>> modulus = pv.FloatAttribute("0.5 + 0.5 * sin(x)") >>> modulus.sample(0.0, 0.0, 0.0, 0.0) 0.5
- __init__(*args, **kwargs)#
Overloaded function.
__init__(self: pyvcad.pyvcad.FloatAttribute) -> None
Default constructor. The attribute has no source until a setter is called.
__init__(self: pyvcad.pyvcad.FloatAttribute, volume: VDBVolume<openvdb::v13_2::Grid<openvdb::v13_2::tree::Tree<openvdb::v13_2::tree::RootNode<openvdb::v13_2::tree::InternalNode<openvdb::v13_2::tree::InternalNode<openvdb::v13_2::tree::LeafNode<float, 3u>, 4u>, 5u>>>>>) -> None
Constructor that takes a float volume to sample the attribute from.
- Parameters:
volume (FloatVolume) – The volume to sample. The signed distance is ignored.
__init__(self: pyvcad.pyvcad.FloatAttribute, definition: object) -> None
Constructor that takes a constant value, math expression string, or numba.cfunc callback.
Expressions may use x, y, z, rho, phic, r, theta, phis and d (signed distance).
- Parameters:
definition (float | str | numba.cfunc) – A constant value, expression string, or numba.cfunc callback with signature float64(float64, float64, float64, float64).
- Raises:
RuntimeError – If an expression fails to compile.
- static between()#
(first: pyvcad.pyvcad.Node, second: pyvcad.pyvcad.Node, exponent: typing.SupportsFloat | typing.SupportsIndex = 1.0, voxel_size: typing.SupportsFloat | typing.SupportsIndex = 0.5, bandwidth: typing.SupportsFloat | typing.SupportsIndex = 10.0) -> pyvcad.pyvcad.FloatAttribute
Return a field that is 0 at the first body, 1 at the second, and grades smoothly between them.
The value is d1^p / (d1^p + d2^p), with d1 and d2 the distances to the two bodies (0 inside them). Use it to grade material or a geometry parameter from one part to another, whatever their shapes. exponent = 1 gives an even grade; larger exponents hold the end values longer and switch more sharply midway. The range is [0, 1]. Choose a bandwidth at least as large as the gap between the bodies so both distances are accurate where the field grades.
- Parameters:
Example
>>> blend = pv.FloatAttribute.between(stiff_insert, soft_shell, bandwidth=30.0) >>> fractions = pv.VolumeFractionsAttribute([(1.0 - blend, red), (blend, blue)])
- clamp(self: pyvcad.pyvcad.FloatAttribute, minimum: SupportsFloat | SupportsIndex, maximum: SupportsFloat | SupportsIndex) pyvcad.pyvcad.FloatAttribute#
Clamp this scalar attribute to explicit bounds.
- Parameters:
minimum (float) – Inclusive lower bound.
maximum (float) – Inclusive upper bound.
Example
>>> bounded = attribute.clamp(0.0, 1.0)
- static curvature()#
(body: pyvcad.pyvcad.Node, kind: object = ‘mean’, voxel_size: typing.SupportsFloat | typing.SupportsIndex = 0.5, bandwidth: typing.SupportsFloat | typing.SupportsIndex = 10.0) -> pyvcad.pyvcad.FloatAttribute
Return the curvature of a body’s surface as a field, in 1/mm (a CurvatureAttribute).
“mean” is positive on convex skin and negative in hollows (1/R on a sphere); “gaussian” is the product of the principal curvatures (negative on saddles); “maximum” is 1 / the tightest bend radius, high at tight bends and sharp edges, where a fillet or extra thickness may be needed. Use a voxel size about a quarter of the smallest radius that matters: features smaller than half the voxel size are smoothed over.
- Parameters:
body (Node) – The node whose surface is measured; your node is not modified.
kind (str | CurvatureAttribute.Kind) – “mean”, “gaussian” or “maximum”.
voxel_size (float) – Voxel size in mm used to prepare the body.
bandwidth (float) – Distance in mm around the body’s box where its field is evaluated.
Example
>>> bend = pv.FloatAttribute.curvature(part, "maximum", voxel_size=0.2) >>> part.set_attribute("curvature", bend)
- static distance_to()#
(body: pyvcad.pyvcad.Node, voxel_size: typing.SupportsFloat | typing.SupportsIndex = 0.5, bandwidth: typing.SupportsFloat | typing.SupportsIndex = 10.0, signed: bool = True) -> pyvcad.pyvcad.FloatAttribute
Return a DistanceFieldAttribute: the distance in mm to a body node.
- Parameters:
body (Node) – Node to measure distance to.
voxel_size (float) – Voxel size in mm used to prepare the body.
bandwidth (float) – Distance in mm around the body’s box where the field is evaluated.
signed (bool) – True for signed distance (negative inside).
Example
>>> radius = pv.FloatAttribute.distance_to(sphere, bandwidth=20.0).map_range(0, 20, 1.0, 0.4)
- ease(self: pyvcad.pyvcad.FloatAttribute, easing: object = 'smoothstep', shape: object = None) pyvcad.pyvcad.FloatAttribute#
Return this attribute clamped to [0, 1] and passed through an easing curve.
Use it to shape a ramp or any field already normalized to [0, 1]. Every curve runs from 0 to 1 and never decreases, so the result stays in [0, 1]:
linear: t.smoothstep: 3t^2 - 2t^3, flat at both ends.smootherstep: 6t^5 - 15t^4 + 10t^3, flat and without a curvature jump at both ends.power: t^p. p > 1 starts slowly, p < 1 starts quickly (default p = 2).sine: (1 - cos(pi t)) / 2, flat at both ends.exponential: (e^(kt) - 1) / (e^k - 1). k > 0 starts slowly, k < 0 quickly (default k = 4).
The result knows its range, so it can drive geometry (an offset or a shell thickness) without hand-written bounds.
- Parameters:
easing (str | Easing) – The curve, by name or as a pv.Easing value.
shape (float | None) – The exponent p of power or the rate k of exponential; None for the default.
Example
>>> ramp = pv.FloatAttribute("z").normalize(0.0, 40.0).ease("smootherstep") >>> late = pv.FloatAttribute("z").normalize(0.0, 40.0).ease("power", 3.0)
- static from_points()#
(points: typing.Annotated[numpy.typing.ArrayLike, numpy.float64], values: typing.Annotated[numpy.typing.ArrayLike, numpy.float64], method: str = ‘idw’, neighbors: typing.SupportsInt | typing.SupportsIndex = 8, power: typing.SupportsFloat | typing.SupportsIndex = 2.0, kernel: str = ‘thin_plate_spline’, radius: object = None, smoothing: typing.SupportsFloat | typing.SupportsIndex = 0.0) -> pyvcad.pyvcad.FloatAttribute
Return a ScatteredFloatAttribute: a scalar field from values at scattered points.
- Parameters:
points (numpy.ndarray) – (N, 3) positions in mm.
values (numpy.ndarray) – (N,) values, one per point.
method (str) – How the values fill the space between the points. “nearest” takes the value of the nearest point. “idw” averages the nearest points, closer ones weighing more: exact at the points, continuous, and always within the range of the data. “rbf” fits a smooth radial-basis-function surface through every point.
neighbors (int) – idw: how many nearest points are averaged.
power (float) – idw: how fast a point’s weight falls with distance.
kernel (str) – rbf: “thin_plate_spline” (smooth and global; at most 2,500 points; each sample visits every point) or “wendland” (compact: each point reaches only radius, so it scales to many points; away from the data it returns to the mean value).
radius (float | None) – rbf with wendland: the reach of each point in mm. None uses three times the median spacing between points.
smoothing (float) – rbf: 0 passes exactly through every value; larger values fit noisy data loosely (and allow repeated points).
Example
>>> sensors = np.array([[0, 0, 0], [40, 0, 0], [0, 30, 0], [40, 30, 10]], dtype=float) >>> readings = np.array([1.0, 3.0, 2.0, 5.0]) >>> modulus = pv.FloatAttribute.from_points(sensors, readings, method="rbf")
- static inverse_distance_weight(distances: collections.abc.Sequence, index: SupportsInt | SupportsIndex, exponent: SupportsFloat | SupportsIndex = 2.0) pyvcad.pyvcad.FloatAttribute#
Return the normalized inverse-distance weight of one of several distance fields.
The weight of field i is d_i^-p / sum_j d_j^-p, and the weights of all fields sum to 1 everywhere. Distances below 0 (inside a body) count as 0. Where some distances are 0, those fields share the weight equally (1/k each for k zero distances) and the others get 0. With distances to seed points this is inverse-distance (Shepard) weighting; with distances to bodies it blends between parts. The range is [0, 1].
- Parameters:
distances (list[FloatAttribute]) – One distance field per seed or body.
index (int) – Which field’s weight to return.
exponent (float) – The power p, positive. Larger values make each region more uniform.
- Raises:
RuntimeError – If distances is empty, index is out of range, or exponent is not positive.
Example
>>> near = [pv.FloatAttribute.distance_to(body, bandwidth=20.0) for body in parts] >>> weight = pv.FloatAttribute.inverse_distance_weight(near, 0, exponent=2.0)
- lipschitz_bound(self: pyvcad.pyvcad.FloatAttribute) float | None#
Return a known bound L on this field’s slope (
|f(p) - f(q)| <= L |p - q|), or None.Known by construction, never estimated by sampling (0 for a constant). Operators use it to keep a field-valued offset or shell a safe distance bound.
- map_range(self: pyvcad.pyvcad.FloatAttribute, input_minimum: SupportsFloat | SupportsIndex, input_maximum: SupportsFloat | SupportsIndex, output_minimum: SupportsFloat | SupportsIndex, output_maximum: SupportsFloat | SupportsIndex, clamp: bool = False) pyvcad.pyvcad.FloatAttribute#
Map this scalar attribute between explicit input and output ranges.
The input bounds may be given in either order but must differ. Values outside the input range extrapolate linearly unless clamp is True.
- Parameters:
input_minimum (float) – Input value mapped to output_minimum.
input_maximum (float) – Input value mapped to output_maximum.
output_minimum (float) – Output at input_minimum.
output_maximum (float) – Output at input_maximum.
clamp (bool) – Keep the result between the two output values.
Example
>>> radius = control.map_range(0.0, 1.0, 0.2, 1.0) >>> radius = distance.map_range(0.0, 10.0, 1.0, 0.4, clamp=True)
- static noise()#
(type: object = ‘simplex’, seed: typing.SupportsInt | typing.SupportsIndex = 0, frequency: typing.SupportsFloat | typing.SupportsIndex = 0.1, octaves: typing.SupportsInt | typing.SupportsIndex = 1, lacunarity: typing.SupportsFloat | typing.SupportsIndex = 2.0, gain: typing.SupportsFloat | typing.SupportsIndex = 0.5) -> pyvcad.pyvcad.FloatAttribute
Return a noise field (a NoiseFloatAttribute): smooth blobs or random cells.
- Parameters:
type (str | NoiseType) – “simplex” (smooth gradient noise in [-1, 1]), “cellular_f1” (distance to the nearest random feature point: round cells), “cellular_f2” (distance to the second nearest) or “cellular_f2_minus_f1” (0 on the walls between cells: a Voronoi web). Cellular values are in cell units, typically 0 to about 1.2.
seed (int) – Any integer; different seeds give unrelated fields, the same seed the same field everywhere.
frequency (float) – Features per mm of the first octave; 0.1 gives features about 10 mm across.
octaves (int) – Number of octaves of detail, 1 to 16. Each octave adds finer detail.
lacunarity (float) – Frequency multiplier from one octave to the next.
gain (float) – Weight multiplier from one octave to the next. The octaves are averaged with these weights, so the range does not grow with more octaves.
Example
>>> blobs = pv.FloatAttribute.noise("simplex", seed=3, frequency=0.08, octaves=3) >>> cells = pv.FloatAttribute.noise("cellular_f2_minus_f1", frequency=0.15)
- normalize(self: pyvcad.pyvcad.FloatAttribute, minimum: SupportsFloat | SupportsIndex, maximum: SupportsFloat | SupportsIndex) pyvcad.pyvcad.FloatAttribute#
Normalize this scalar attribute with required explicit input bounds.
Returns (value - minimum) / (maximum - minimum). The result is not clamped, so values outside [minimum, maximum] map outside [0, 1]; chain clamp() if needed.
- Parameters:
minimum (float) – Input value mapped to zero. Must be finite.
maximum (float) – Input value mapped to one. Must be finite and greater than minimum.
- Raises:
RuntimeError – If the bounds are not finite or minimum >= maximum.
Example
>>> normalized = attribute.normalize(2.0, 8.0)
- set_expression(self: pyvcad.pyvcad.FloatAttribute, expression: str) None#
Sets the math expression for the attribute.
- Parameters:
expression (str) – The math expression.
- Raises:
RuntimeError – If a source is already set or the expression fails to compile.
- set_function(self: pyvcad.pyvcad.FloatAttribute, function: object) None#
Sets the numba.cfunc callback for the attribute.
- Parameters:
function (numba.cfunc) – A numba.cfunc callback with signature float64(float64, float64, float64, float64).
- Raises:
RuntimeError – If a source is already set.
- set_value(self: pyvcad.pyvcad.FloatAttribute, value: SupportsFloat | SupportsIndex) None#
Sets a constant value for the attribute.
- Parameters:
value (float) – A constant value.
- Raises:
RuntimeError – If a source is already set.
- set_volume(self: pyvcad.pyvcad.FloatAttribute, volume: VDBVolume<openvdb::v13_2::Grid<openvdb::v13_2::tree::Tree<openvdb::v13_2::tree::RootNode<openvdb::v13_2::tree::InternalNode<openvdb::v13_2::tree::InternalNode<openvdb::v13_2::tree::LeafNode<float, 3u>, 4u>, 5u>>>>>) None#
Sets the attribute to be sampled from a float volume.
- Parameters:
volume (FloatVolume) – The volume to sample. The signed distance is ignored.
- Raises:
RuntimeError – If a source is already set.
- static surface_angle()#
(body: pyvcad.pyvcad.Node, direction: object = (0.0, 0.0, 1.0), voxel_size: typing.SupportsFloat | typing.SupportsIndex = 0.5, bandwidth: typing.SupportsFloat | typing.SupportsIndex = 10.0, degrees: bool = True) -> pyvcad.pyvcad.FloatAttribute
Return the angle between a body’s surface normal and a direction.
0 where the surface faces the direction, 90 where the surface runs along it, 180 where it faces away. With the build direction +Z (the default), up-facing skin reads 0 and down-facing overhangs read near 180, so the field grades material by how a surface faces the build plate. Off the surface it is the angle of the closest surface point’s normal. The range [0, 180] is known, so the field can drive geometry directly.
- Parameters:
body (Node) – The node whose surface is measured.
direction (Vec3 | tuple) – The direction, for example the build direction (not normalized is fine).
voxel_size (float) – Voxel size in mm used to prepare the body.
bandwidth (float) – Distance in mm around the body’s box where its field is evaluated.
degrees (bool) – Degrees in [0, 180] (True) or radians in [0, pi] (False).
Example
>>> overhang = pv.FloatAttribute.surface_angle(part).normalize(90.0, 180.0).clamp(0.0, 1.0)
- transfer(self: pyvcad.pyvcad.FloatAttribute, points: object, interpolation: str = 'linear') pyvcad.pyvcad.FloatAttribute#
Return this attribute mapped through a transfer curve drawn through control points.
Each control point (x, y) maps the input value x to the output y. Between points the curve is a straight line (
"linear") or a smooth monotone cubic ("smooth"), which never overshoots: between two points it stays between their values. Below the first and above the last point the curve holds the end values. Use it for any non-linear material law, for example density to stiffness.- Parameters:
points (list[tuple[float, float]] | numpy.ndarray) – At least two (x, y) control points with distinct x, in any order; an (N, 2) array works too.
interpolation (str) – “linear” or “smooth”.
Example
>>> density = pv.FloatAttribute("x").normalize(0.0, 50.0) >>> modulus = density.transfer([(0.0, 1.0), (0.4, 2.0), (1.0, 9.0)], interpolation="smooth")
- value_bounds(self: pyvcad.pyvcad.FloatAttribute) tuple[float, float] | None#
Return the range (minimum, maximum) this field is known to stay in, or None.
The range is known by construction, never estimated by sampling: constants, noise, clamp(), ease(), transfer() and arithmetic on such fields report one. Operators that take field-valued geometry parameters (offsets, shells, blend radii) use it to size their bounding box, so a field that knows its range needs no ScalarParameter bounds.
Example
>>> pv.FloatAttribute("x").clamp(0.0, 2.0).value_bounds() (0.0, 2.0)
- with_fallback(self: pyvcad.pyvcad.FloatAttribute, value: SupportsFloat | SupportsIndex, cell_map: pyvcad.pyvcad.CellMap = None) pyvcad.pyvcad.FloatAttribute#
Return this attribute, or a constant wherever it cannot be evaluated.
Sampling falls back to value when this attribute raises an error or returns a non-finite number, for example a CellMap coordinate sampled outside the map domain. Valid samples are returned unchanged. When cell_map is given, points outside that map’s active domain return value without evaluating this attribute at all, which is much faster than catching the adapter’s error.
- Parameters:
value (float) – Finite value used where this attribute is undefined.
cell_map (CellMap | None) – Map whose domain guards the evaluation.
Example
>>> weight = cell_map.u_field.normalize(0.0, 6.0).with_fallback(0.0, cell_map)
- class pyvcad.Vec3Attribute#
An attribute that stores a function for spatial grading that returns a vec3.
When used for representing color, the components should be in the range [0, 1]. The source is set once, by the constructor or by one setter; the setters raise RuntimeError if a source is already set.
Example
>>> import pyvcad as pv >>> color = pv.Vec3Attribute("x / 10", "0.5", "0")
- __init__(*args, **kwargs)#
Overloaded function.
__init__(self: pyvcad.pyvcad.Vec3Attribute) -> None
Default constructor. The attribute has no source until a setter is called.
__init__(self: pyvcad.pyvcad.Vec3Attribute, volume: VDBVolume<openvdb::v13_2::Grid<openvdb::v13_2::tree::Tree<openvdb::v13_2::tree::RootNode<openvdb::v13_2::tree::InternalNode<openvdb::v13_2::tree::InternalNode<openvdb::v13_2::tree::LeafNode<openvdb::v13_2::math::Vec3<float>, 3u>, 4u>, 5u>>>>>) -> None
Constructor that samples a Vec3s VDB volume.
- Parameters:
volume (Vec3sVolume) – A Vec3s VDB volume to sample.
__init__(self: pyvcad.pyvcad.Vec3Attribute, x: object, y: object, z: object) -> None
Constructor that takes math expression strings, constant values, or numba.cfunc callbacks for each component.
- Parameters:
x (str | float | numba.cfunc) – X component definition.
y (str | float | numba.cfunc) – Y component definition.
z (str | float | numba.cfunc) – Z component definition.
__init__(self: pyvcad.pyvcad.Vec3Attribute, function: object) -> None
Constructor that takes one callback returning all three components.
The callback is a numba.cfunc with signature void(float64, float64, float64, float64, CPointer(float64)) that writes the three components into its last argument, or a plain callable f(x, y, z, d) returning three numbers, which is compiled to that cfunc with numba. Either runs natively, without the GIL.
- Parameters:
function (numba.cfunc | callable) – The vector callback.
Example
>>> import math >>> import pyvcad as pv >>> swirl = pv.Vec3Attribute(lambda x, y, z, d: (math.cos(z), math.sin(z), 0.0))
- angle(self: pyvcad.pyvcad.Vec3Attribute, other: object, degrees: bool = True) pyvcad.pyvcad.DerivedFloatAttribute#
Return the angle between this vector field and another, as a scalar attribute.
The result is in [0, 180] degrees (or [0, pi] radians) and is 90 degrees wherever either vector is zero.
- Parameters:
other (Vec3Attribute | Vec3 | tuple) – The other vector field or a constant direction.
degrees (bool) – Degrees (True) or radians (False).
Example
>>> tilt = pv.NormalFieldAttribute(part).angle((0.0, 0.0, 1.0))
- component(self: pyvcad.pyvcad.Vec3Attribute, index: SupportsInt | SupportsIndex) pyvcad.pyvcad.FloatAttribute#
Extract one vector component as a scalar attribute.
- Parameters:
index (int) – Component index 0, 1, or 2.
Example
>>> x_field = direction.component(0)
- dot(self: pyvcad.pyvcad.Vec3Attribute, other: pyvcad.pyvcad.Vec3Attribute) pyvcad.pyvcad.FloatAttribute#
Return the dot product with another vector attribute.
- Parameters:
other (Vec3Attribute) – Other vector dependency.
Example
>>> alignment = first.dot(second)
- static from_points()#
(points: typing.Annotated[numpy.typing.ArrayLike, numpy.float64], vectors: typing.Annotated[numpy.typing.ArrayLike, numpy.float64], method: str = ‘idw’, neighbors: typing.SupportsInt | typing.SupportsIndex = 8, power: typing.SupportsFloat | typing.SupportsIndex = 2.0, kernel: str = ‘thin_plate_spline’, radius: object = None, smoothing: typing.SupportsFloat | typing.SupportsIndex = 0.0) -> pyvcad.pyvcad.Vec3Attribute
Return a ScatteredVec3Attribute: a vector field from vectors at scattered points.
- Parameters:
points (numpy.ndarray) – (N, 3) positions in mm.
vectors (numpy.ndarray) – (N, 3) vectors, one per point.
method (str) – How the values fill the space between the points. “nearest” takes the value of the nearest point. “idw” averages the nearest points, closer ones weighing more: exact at the points, continuous, and always within the range of the data. “rbf” fits a smooth radial-basis-function surface through every point.
neighbors (int) – idw: how many nearest points are averaged.
power (float) – idw: how fast a point’s weight falls with distance.
kernel (str) – rbf: “thin_plate_spline” (smooth and global; at most 2,500 points; each sample visits every point) or “wendland” (compact: each point reaches only radius, so it scales to many points; away from the data it returns to the mean value).
radius (float | None) – rbf with wendland: the reach of each point in mm. None uses three times the median spacing between points.
smoothing (float) – rbf: 0 passes exactly through every value; larger values fit noisy data loosely (and allow repeated points).
Example
>>> displacement = pv.Vec3Attribute.from_points(nodes, offsets, method="idw") >>> moved = pv.Warp.displace(displacement, part)
- is_volume_backed(self: pyvcad.pyvcad.Vec3Attribute) bool#
Returns True if this attribute samples a VDB volume.
- magnitude(self: pyvcad.pyvcad.Vec3Attribute) pyvcad.pyvcad.FloatAttribute#
Return vector magnitude as a scalar attribute.
Example
>>> radius = vectors.magnitude()
- static noise()#
(type: object = ‘simplex’, seed: typing.SupportsInt | typing.SupportsIndex = 0, frequency: typing.SupportsFloat | typing.SupportsIndex = 0.1, octaves: typing.SupportsInt | typing.SupportsIndex = 1, lacunarity: typing.SupportsFloat | typing.SupportsIndex = 2.0, gain: typing.SupportsFloat | typing.SupportsIndex = 0.5) -> pyvcad.pyvcad.Vec3Attribute
Return a vector noise field (a NoiseVec3Attribute): three unrelated noise fields, one per component, for example to displace material.
- Parameters:
type (str | NoiseType) – “simplex” (smooth gradient noise in [-1, 1]), “cellular_f1” (distance to the nearest random feature point: round cells), “cellular_f2” (distance to the second nearest) or “cellular_f2_minus_f1” (0 on the walls between cells: a Voronoi web). Cellular values are in cell units, typically 0 to about 1.2.
seed (int) – Any integer; different seeds give unrelated fields, the same seed the same field everywhere.
frequency (float) – Features per mm of the first octave; 0.1 gives features about 10 mm across.
octaves (int) – Number of octaves of detail, 1 to 16. Each octave adds finer detail.
lacunarity (float) – Frequency multiplier from one octave to the next.
gain (float) – Weight multiplier from one octave to the next. The octaves are averaged with these weights, so the range does not grow with more octaves.
Example
>>> wobble = pv.Vec3Attribute.noise(seed=1, frequency=0.05, octaves=2) * 1.5 >>> rough = pv.Warp.displace(wobble, body)
- normalized(self: pyvcad.pyvcad.Vec3Attribute) pyvcad.pyvcad.Vec3Attribute#
Normalize this vector attribute at every sample.
Example
>>> direction = vectors.normalized()
- set_expression(self: pyvcad.pyvcad.Vec3Attribute, x_expression: str, y_expression: str, z_expression: str) None#
Sets the math expressions for the attribute.
- Parameters:
x_expression (str) – Expression for the x component.
y_expression (str) – Expression for the y component.
z_expression (str) – Expression for the z component.
- Raises:
RuntimeError – If a source is already set or an expression fails to compile.
- set_function(self: pyvcad.pyvcad.Vec3Attribute, x_function: object, y_function: object, z_function: object) None#
Sets numba.cfunc callbacks for each component of the attribute.
- Parameters:
x_function (numba.cfunc) – X component callback with signature float64(float64, float64, float64, float64).
y_function (numba.cfunc) – Y component callback with signature float64(float64, float64, float64, float64).
z_function (numba.cfunc) – Z component callback with signature float64(float64, float64, float64, float64).
- Raises:
RuntimeError – If a source is already set.
- set_value(self: pyvcad.pyvcad.Vec3Attribute, x: SupportsFloat | SupportsIndex, y: SupportsFloat | SupportsIndex, z: SupportsFloat | SupportsIndex) None#
Sets constant values for the attribute (no spatial grading).
- Parameters:
x (float) – Value for the x component.
y (float) – Value for the y component.
z (float) – Value for the z component.
- Raises:
RuntimeError – If a source is already set.
- set_volume(self: pyvcad.pyvcad.Vec3Attribute, volume: VDBVolume<openvdb::v13_2::Grid<openvdb::v13_2::tree::Tree<openvdb::v13_2::tree::RootNode<openvdb::v13_2::tree::InternalNode<openvdb::v13_2::tree::InternalNode<openvdb::v13_2::tree::LeafNode<openvdb::v13_2::math::Vec3<float>, 3u>, 4u>, 5u>>>>>) None#
Sets the attribute to be sampled from a VDB volume.
- Parameters:
volume (Vec3sVolume) – A Vec3s VDB volume to sample.
- Raises:
RuntimeError – If a source is already set.
- static surface_normal()#
(body: pyvcad.pyvcad.Node, voxel_size: typing.SupportsFloat | typing.SupportsIndex = 0.5, bandwidth: typing.SupportsFloat | typing.SupportsIndex = 10.0) -> pyvcad.pyvcad.Vec3Attribute
Return the unit surface normal of a body as a vector field (a NormalFieldAttribute).
On the surface it points straight out of the body; elsewhere it is the normal of the closest surface point. It is the zero vector where that is undefined, for example at a sphere’s centre.
- Parameters:
body (Node) – The node whose surface is measured; your node is not modified.
voxel_size (float) – Voxel size in mm used to prepare the body.
bandwidth (float) – Distance in mm around the body’s box where its field is evaluated.
Example
>>> normals = pv.Vec3Attribute.surface_normal(part) >>> tilt = normals.angle((1.0, 0.0, 0.0))
- volume_type_name(self: pyvcad.pyvcad.Vec3Attribute) str#
Returns the backing volume type name for diagrams (an empty string when not volume-backed).
- property x#
X component as a scalar attribute.
- property y#
Y component as a scalar attribute.
- property z#
Z component as a scalar attribute.
- class pyvcad.Vec4Attribute#
An attribute that stores a function for spatial grading that returns a vec4.
When used for representing color, the components should be in the range [0, 1]. The source is set once, by the constructor or by one setter; the setters raise RuntimeError if a source is already set.
Example
>>> import pyvcad as pv >>> color = pv.Vec4Attribute(1.0, 0.0, 0.0, 0.5)
- __init__(*args, **kwargs)#
Overloaded function.
__init__(self: pyvcad.pyvcad.Vec4Attribute) -> None
Default constructor. The attribute has no source until a setter is called.
__init__(self: pyvcad.pyvcad.Vec4Attribute, volume: VDBVolume<openvdb::v13_2::Grid<openvdb::v13_2::tree::Tree<openvdb::v13_2::tree::RootNode<openvdb::v13_2::tree::InternalNode<openvdb::v13_2::tree::InternalNode<openvdb::v13_2::tree::LeafNode<openvdb::v13_2::math::Vec4<float>, 3u>, 4u>, 5u>>>>>) -> None
Constructor that samples a Vec4s VDB volume.
- Parameters:
volume (Vec4sVolume) – A Vec4s VDB volume to sample.
__init__(self: pyvcad.pyvcad.Vec4Attribute, r: object, g: object, b: object, a: object) -> None
Constructor that takes math expression strings, constant values, or numba.cfunc callbacks for each component.
- Parameters:
r (str | float | numba.cfunc) – Red component definition.
g (str | float | numba.cfunc) – Green component definition.
b (str | float | numba.cfunc) – Blue component definition.
a (str | float | numba.cfunc) – Alpha component definition.
- is_volume_backed(self: pyvcad.pyvcad.Vec4Attribute) bool#
Returns True if this attribute samples a VDB volume.
- set_expression(self: pyvcad.pyvcad.Vec4Attribute, r_expression: str, g_expression: str, b_expression: str, a_expression: str) None#
Sets the math expressions for the attribute.
- Parameters:
r_expression (str) – Expression for the red component.
g_expression (str) – Expression for the green component.
b_expression (str) – Expression for the blue component.
a_expression (str) – Expression for the alpha component.
- Raises:
RuntimeError – If a source is already set or an expression fails to compile.
- set_function(self: pyvcad.pyvcad.Vec4Attribute, r_function: object, g_function: object, b_function: object, a_function: object) None#
Sets numba.cfunc callbacks for each component of the attribute.
- Parameters:
r_function (numba.cfunc) – Red component callback with signature float64(float64, float64, float64, float64).
g_function (numba.cfunc) – Green component callback with signature float64(float64, float64, float64, float64).
b_function (numba.cfunc) – Blue component callback with signature float64(float64, float64, float64, float64).
a_function (numba.cfunc) – Alpha component callback with signature float64(float64, float64, float64, float64).
- Raises:
RuntimeError – If a source is already set.
- set_value(self: pyvcad.pyvcad.Vec4Attribute, r: SupportsFloat | SupportsIndex, g: SupportsFloat | SupportsIndex, b: SupportsFloat | SupportsIndex, a: SupportsFloat | SupportsIndex) None#
Sets constant values for the attribute (no spatial grading).
- Parameters:
r (float) – Value for the red component.
g (float) – Value for the green component.
b (float) – Value for the blue component.
a (float) – Value for the alpha component.
- Raises:
RuntimeError – If a source is already set.
- set_volume(self: pyvcad.pyvcad.Vec4Attribute, volume: VDBVolume<openvdb::v13_2::Grid<openvdb::v13_2::tree::Tree<openvdb::v13_2::tree::RootNode<openvdb::v13_2::tree::InternalNode<openvdb::v13_2::tree::InternalNode<openvdb::v13_2::tree::LeafNode<openvdb::v13_2::math::Vec4<float>, 3u>, 4u>, 5u>>>>>) None#
Sets the attribute to be sampled from a VDB volume.
- Parameters:
volume (Vec4sVolume) – A Vec4s VDB volume to sample.
- Raises:
RuntimeError – If a source is already set or volume is None.
- volume_type_name(self: pyvcad.pyvcad.Vec4Attribute) str#
Returns the backing volume type name for diagrams (an empty string when not volume-backed).
- class pyvcad.VolumeFractionsAttribute#
An attribute that stores a set of volume fraction functions for different materials. It can be sampled to get the fractions for each material.
Sampled fractions are returned exactly as the definitions evaluate; they are not clamped or normalized to sum to 1. Each material may be added only once.
Example
>>> import pyvcad as pv >>> fractions = pv.VolumeFractionsAttribute([("0.25", 1), (0.75, 2)]) >>> fractions.sample(0.0, 0.0, 0.0, 0.0)[2] 0.75
- __init__(*args, **kwargs)#
Overloaded function.
__init__(self: pyvcad.pyvcad.VolumeFractionsAttribute) -> None
Default constructor. The attribute holds no materials until some are added.
__init__(self: pyvcad.pyvcad.VolumeFractionsAttribute, entries: collections.abc.Sequence) -> None
Constructor that takes a list of 2-item entries containing a definition and material id.
- Parameters:
entries (sequence) – A sequence of (definition, material_id) pairs where each definition is a float, expression string, FloatAttribute field, or numba.cfunc callback with signature float64(float64, float64, float64, float64).
- Raises:
ValueError – If a material id appears twice.
Example
>>> blend = pv.FloatAttribute("x").normalize(0.0, 40.0).ease("smoothstep") >>> fractions = pv.VolumeFractionsAttribute([(blend, red), (1.0 - blend, blue)])
__init__(self: pyvcad.pyvcad.VolumeFractionsAttribute, values: collections.abc.Sequence, materials: collections.abc.Sequence) -> None
Constructor that takes parallel lists of definitions and material ids.
- Parameters:
values (sequence) – A sequence of float values, expression strings, FloatAttribute fields, or numba.cfunc callbacks.
materials (sequence) – A sequence of material ids aligned with values.
- Raises:
ValueError – If the lengths differ or a material id appears twice.
- add_attribute(self: pyvcad.pyvcad.VolumeFractionsAttribute, attribute: pyvcad.pyvcad.FloatAttribute, material: SupportsInt | SupportsIndex) None#
Adds a scalar field as the volume fraction of a material.
- Parameters:
attribute (FloatAttribute) – Any scalar field, for example a ramp shaped with ease().
material (int) – The material id.
- Raises:
ValueError – If attribute is None or the material is already in use.
- add_expression(*args, **kwargs)#
Overloaded function.
add_expression(self: pyvcad.pyvcad.VolumeFractionsAttribute, expression: str, material: typing.SupportsInt | typing.SupportsIndex) -> None
Adds a math expression for a material.
- Parameters:
expression (str) – Expression in x, y, z, rho, phic, r, theta, phis and d (signed distance).
material (int) – The material id.
- Raises:
ValueError – If the material is already in use.
RuntimeError – If the expression fails to compile.
add_expression(self: pyvcad.pyvcad.VolumeFractionsAttribute, expression_material_pair: tuple[str, typing.SupportsInt | typing.SupportsIndex]) -> None
Adds an expression/material pair.
- Parameters:
expression_material_pair (tuple[str, int]) – The expression and its material id.
- Raises:
ValueError – If the material is already in use.
RuntimeError – If the expression fails to compile.
- add_function(*args, **kwargs)#
Overloaded function.
add_function(self: pyvcad.pyvcad.VolumeFractionsAttribute, function: object, material: typing.SupportsInt | typing.SupportsIndex) -> None
Adds a numba.cfunc callback for a material.
- Parameters:
function (numba.cfunc) – Callback with signature float64(float64, float64, float64, float64).
material (int) – The material id.
- Raises:
ValueError – If the material is already in use.
add_function(self: pyvcad.pyvcad.VolumeFractionsAttribute, function_material_pair: object) -> None
Adds a numba.cfunc callback and material pair.
- Parameters:
function_material_pair (tuple[numba.cfunc, int]) – The callback and its material id.
- Raises:
ValueError – If the material is already in use.
- add_value(self: pyvcad.pyvcad.VolumeFractionsAttribute, value: SupportsFloat | SupportsIndex, material: SupportsInt | SupportsIndex) None#
Adds a constant value for a material.
- Parameters:
value (float) – The constant volume fraction.
material (int) – The material id.
- Raises:
ValueError – If the material is already in use.
- static get_value(attribute_samples: AttributeSamples) object#
Extracts the volume fraction map from sampled attributes.
- Parameters:
attribute_samples (AttributeSamples) – Samples returned by Node.sample().
- Returns:
Material ID to volume fraction.
- Return type:
dict[int, float]
- Raises:
KeyError – If the samples have no volume_fractions entry.
- class pyvcad.DerivedFloatAttribute#
An immutable named expression over scalar attribute dependencies.
- __init__(self: pyvcad.pyvcad.DerivedFloatAttribute, expression: str, inputs: dict) None#
Construct a named multi-input scalar expression. The expression uses keys from inputs, which maps names to FloatAttribute objects or numeric constants.
- class pyvcad.DistanceFieldAttribute#
A scalar attribute giving the distance in millimetres to another body (any node), evaluated natively so it can drive grading through map_range(), clamp(), and other modifiers without a Python callback. The body is cloned and the clone is prepared with voxel_size and bandwidth; the caller’s node is not modified. Values are signed (negative inside the body) unless signed=False. The field is accurate within the body’s bounding box expanded by bandwidth; beyond it a lower bound (box distance plus bandwidth) is returned, so choose a bandwidth at least as large as the distances your grading uses.
- __init__(self: pyvcad.pyvcad.DistanceFieldAttribute, body: pyvcad.pyvcad.Node, voxel_size: SupportsFloat | SupportsIndex = 0.5, bandwidth: SupportsFloat | SupportsIndex = 10.0, signed: bool = True) None#
Construct a distance field to a body.
- Parameters:
body (Node) – Node to measure distance to.
voxel_size (float) – Voxel size in mm used to prepare the body (mesh SDF resolution).
bandwidth (float) – Distance in mm around the body’s box where the field is evaluated.
signed (bool) – True for signed distance (negative inside), False for unsigned.
Example
>>> distance = pv.DistanceFieldAttribute(head, bandwidth=30.0) >>> radius = distance.map_range(0.0, 30.0, 1.2, 0.5)
- property bandwidth#
Distance in mm around the body’s box where the field is evaluated.
- property body#
The prepared private clone of the body that is evaluated.
- property signed#
Whether the distance is signed.
- class pyvcad.CoordinateFieldAttribute#
A scalar field that reads one named coordinate of a curve or a curve-based node.
Examples are the distance to a curve, the arc length along it, the angle around a tube, the height in an extrusion, or where a point pulls back to under a Warp. The field is defined everywhere in space. Get one from Curve.distance_field(), Curve.parameter_field(), Curve.length_field(), or the coordinate_field(name) method of Tube, Extrude, Revolve, Sweep or Warp, and use it like any FloatAttribute: set it on a node, map it with map_range(), or pass it as a geometry parameter.
Example
>>> import pyvcad as pv >>> path = pv.BSplineCurve.interpolate([(0, 0, 0), (20, 10, 0), (40, 0, 0)]) >>> near_path = path.distance_field().map_range(0.0, 10.0, 1000.0, 100.0, clamp=True)
- property name#
The coordinate name.
- class pyvcad.AttributeSamples#
A collection of attribute samples returned by a tree sample.
Acts as a key-value store mapping attribute names to their evaluated values.
Example
>>> import pyvcad as pv >>> samples = pv.AttributeSamples() >>> samples.set_sample('density', 0.5) >>> samples.get_sample('density') 0.5
- __init__(self: pyvcad.pyvcad.AttributeSamples) None#
Constructs an empty AttributeSamples container.
- get_sample(self: pyvcad.pyvcad.AttributeSamples, name: str) object#
Returns the sampled value for the given attribute name.
- get_type(self: pyvcad.pyvcad.AttributeSamples, name: str) pyvcad.pyvcad.Attribute.ReturnType#
Returns the ReturnType enum of the sample (e.g. pv.Attribute.ReturnType.dbl).
- Parameters:
name (str) – The attribute name.
- Returns:
The value type, or ReturnType.none if name is absent.
- Return type:
- has_sample(self: pyvcad.pyvcad.AttributeSamples, name: str) bool#
Checks if the sample contains an attribute with the given name.
- Parameters:
name (str) – The attribute name.
- Returns:
True if a value is stored under name.
- Return type:
bool
- set_sample(self: pyvcad.pyvcad.AttributeSamples, name: str, value: object) None#
Sets the sampled value for the given attribute name, replacing any existing value.
Attributes attached to a mapped lattice (MappedGraphLattice, MappedFaceLattice,
MappedImplicitLattice and MappedStructureCollection) can be sampled in one of several
coordinate frames. Their set_attribute methods take the name of an AttributeCoordinates
value as the coordinates string (default "node").
- class pyvcad.AttributeCoordinates#
Coordinate values supplied as x, y, and z to a mapped attribute.
Members:
node : Existing consuming-node Cartesian coordinates.
map : Normalized CellMap coordinates in the range zero to one.
logical : CellMap logical coordinates measured in cell units.
cell_index : Integer CellMap cell indices.
cell : Repeating unit-cell coordinates in the range zero to one.
- cell = <AttributeCoordinates.cell: 4>#
- cell_index = <AttributeCoordinates.cell_index: 3>#
- logical = <AttributeCoordinates.logical: 2>#
- map = <AttributeCoordinates.map: 1>#
- AttributeCoordinates.name -> str
- node = <AttributeCoordinates.node: 0>#
- property value#
Fields: make, change, use#
An attribute is a field: a value at every point. There is one field system, and every tool below
is either a way to make a field, an operation that changes one into a new field, or a place
that uses one. Each field source has one spelling, a method on FloatAttribute (one number per
point) or Vec3Attribute (three numbers per point); the classes below are what those methods
return.
Make: a constant, an expression string, a numba function, a volume (
FloatAttribute(volume)), simulation results (UnstructuredFieldDataset), andFloatAttribute.distance_to(body),.surface_angle(body),.curvature(body),.between(first, second),.noise(...),.from_points(points, values);Vec3Attribute.surface_normal(body),.noise(...),.from_points(points, vectors).Change:
+ - * /,clamp,normalize,map_range,ease,transfer;Vec3Attribute.dot,.angle,.magnitude,.component. Each returns a new field.Use: grade material with
node.set_attribute(name, field)orVolumeFractionsAttribute([(field, material), ...]); drive geometry by passing a field wherever an operator takes a size (offset, shell thickness, blend radius, twist rate) or a vector (Warp,Warp.displace).Convert (a separate, later stage): the converters further down work on named values after a subtree has been sampled and its parts merged, inside an
AttributeModifiernode, for example modulus to printer volume fractions. Shape fields with the operations above; use converters only for that last step.
Shaping fields#
Every FloatAttribute has methods that return a new, shaped field: arithmetic operators,
clamp, normalize, map_range, and two shaping curves. ease clamps a field to
[0, 1] and passes it through an easing curve (Easing); transfer maps it through a curve
drawn through control points, straight or smooth. The result is an ordinary attribute, so it can
grade material (VolumeFractionsAttribute takes fields directly) or drive geometry.
import pyvcad as pv
ramp = pv.FloatAttribute("z").normalize(0.0, 40.0)
soft = ramp.ease("smootherstep")
stiffness = ramp.transfer([(0.0, 1.0), (0.5, 2.0), (1.0, 8.0)], interpolation="smooth")
fractions = pv.VolumeFractionsAttribute([(soft, 1), (1.0 - soft, 2)])
- class pyvcad.Easing#
Shaping curves for FloatAttribute.ease(). Each maps [0, 1] onto [0, 1] and never decreases: linear (t), smoothstep (3t^2 - 2t^3), smootherstep (6t^5 - 15t^4 + 10t^3), power (t^p), sine ((1 - cos(pi t)) / 2) and exponential ((e^(kt) - 1) / (e^k - 1)).
Members:
linear
smoothstep
smootherstep
power
sine
exponential
- exponential = <Easing.exponential: 5>#
- linear = <Easing.linear: 0>#
- Easing.name -> str
- power = <Easing.power: 3>#
- sine = <Easing.sine: 4>#
- smootherstep = <Easing.smootherstep: 2>#
- smoothstep = <Easing.smoothstep: 1>#
- property value#
Noise#
Native noise fields for organic variation. FloatAttribute.noise(...) (a NoiseFloatAttribute)
is simplex (gradient) noise in [-1, 1] or a cellular distance (round cells, or the walls between
them), with fractal octaves; Vec3Attribute.noise(...) (a NoiseVec3Attribute) gives three
unrelated components, for displacement. They are deterministic: the same seed gives the same field on
every platform and in every thread. They know their range and slope, so they can drive geometry
directly.
import pyvcad as pv
bumps = pv.FloatAttribute.noise("simplex", seed=2, frequency=0.08, octaves=4)
rough = pv.Offset(bumps.map_range(-1.0, 1.0, 0.0, 3.0), pv.Sphere(pv.Vec3(0, 0, 0), 20.0))
web = pv.FloatAttribute.noise("cellular_f2_minus_f1", frequency=0.12)
- class pyvcad.NoiseType#
The base noise functions of NoiseFloatAttribute and NoiseVec3Attribute: simplex (smooth gradient noise in [-1, 1]) and the cellular distances cellular_f1, cellular_f2 and cellular_f2_minus_f1.
Members:
simplex
cellular_f1
cellular_f2
cellular_f2_minus_f1
- cellular_f1 = <NoiseType.cellular_f1: 1>#
- cellular_f2 = <NoiseType.cellular_f2: 2>#
- cellular_f2_minus_f1 = <NoiseType.cellular_f2_minus_f1: 3>#
- NoiseType.name -> str
- simplex = <NoiseType.simplex: 0>#
- property value#
- class pyvcad.NoiseFloatAttribute#
A scalar noise field: simplex (gradient) noise or cellular distances, with fractal octaves.
The field is native and stateless, so it evaluates in parallel, and the same seed gives the same values on every platform. It knows its range ([-1, 1] for simplex) and a bound on its slope, so it can drive geometry (offsets, shell thickness, blend radii) without ScalarParameter hints. Shape it like any FloatAttribute: map_range(), ease(), transfer(). Usually built with pv.FloatAttribute.noise(…).
- __init__(self: pyvcad.pyvcad.NoiseFloatAttribute, type: object = 'simplex', seed: SupportsInt | SupportsIndex = 0, frequency: SupportsFloat | SupportsIndex = 0.1, octaves: SupportsInt | SupportsIndex = 1, lacunarity: SupportsFloat | SupportsIndex = 2.0, gain: SupportsFloat | SupportsIndex = 0.5) None#
Construct a scalar noise field.
- Parameters:
type (str | NoiseType) – “simplex” (smooth gradient noise in [-1, 1]), “cellular_f1” (distance to the nearest random feature point: round cells), “cellular_f2” (distance to the second nearest) or “cellular_f2_minus_f1” (0 on the walls between cells: a Voronoi web). Cellular values are in cell units, typically 0 to about 1.2.
seed (int) – Any integer; different seeds give unrelated fields, the same seed the same field everywhere.
frequency (float) – Features per mm of the first octave; 0.1 gives features about 10 mm across.
octaves (int) – Number of octaves of detail, 1 to 16. Each octave adds finer detail.
lacunarity (float) – Frequency multiplier from one octave to the next.
gain (float) – Weight multiplier from one octave to the next. The octaves are averaged with these weights, so the range does not grow with more octaves.
Example
>>> bumps = pv.NoiseFloatAttribute("simplex", seed=3, frequency=0.08, octaves=3) >>> thickness = bumps.map_range(-1.0, 1.0, 0.8, 2.0) >>> cells = pv.NoiseFloatAttribute("cellular_f2_minus_f1", frequency=0.15)
- property frequency#
Features per mm of the first octave.
- property gain#
Weight multiplier between octaves.
- property lacunarity#
Frequency multiplier between octaves.
- property octaves#
Number of octaves.
- property seed#
The seed, reduced to 32 bits.
- property type#
The base noise function.
- class pyvcad.NoiseVec3Attribute#
A vector noise field: three unrelated noise fields with the same settings, one per component.
Each component has the range of the scalar noise (simplex: [-1, 1]). Use it to displace material (pv.Warp.displace) or to perturb directions; scale it with * to set the amplitude in mm. Usually built with pv.Vec3Attribute.noise(…).
- __init__(self: pyvcad.pyvcad.NoiseVec3Attribute, type: object = 'simplex', seed: SupportsInt | SupportsIndex = 0, frequency: SupportsFloat | SupportsIndex = 0.1, octaves: SupportsInt | SupportsIndex = 1, lacunarity: SupportsFloat | SupportsIndex = 2.0, gain: SupportsFloat | SupportsIndex = 0.5) None#
Construct a vector noise field.
- Parameters:
type (str | NoiseType) – “simplex” (smooth gradient noise in [-1, 1]), “cellular_f1” (distance to the nearest random feature point: round cells), “cellular_f2” (distance to the second nearest) or “cellular_f2_minus_f1” (0 on the walls between cells: a Voronoi web). Cellular values are in cell units, typically 0 to about 1.2.
seed (int) – Any integer; different seeds give unrelated fields, the same seed the same field everywhere.
frequency (float) – Features per mm of the first octave; 0.1 gives features about 10 mm across.
octaves (int) – Number of octaves of detail, 1 to 16. Each octave adds finer detail.
lacunarity (float) – Frequency multiplier from one octave to the next.
gain (float) – Weight multiplier from one octave to the next. The octaves are averaged with these weights, so the range does not grow with more octaves.
Example
>>> wobble = pv.NoiseVec3Attribute(seed=1, frequency=0.05, octaves=2) * 1.5 >>> rough = pv.Warp.displace(wobble, body)
- property frequency#
Features per mm of the first octave.
- property octaves#
Number of octaves.
- property seed#
The seed, reduced to 32 bits.
- property type#
The base noise function.
Fields from other bodies#
Fields measured from other geometry, next to FloatAttribute.distance_to(body) (a
DistanceFieldAttribute):
Vec3Attribute.surface_normal(body)(aNormalFieldAttribute): the body’s unit surface normal, extended through space (each point takes the normal of its closest surface point).Vec3Attribute.angle(other)turns it into an angle field.FloatAttribute.surface_angle(body, direction): the angle between the surface normal and a direction, for example the build direction: 0 on skin facing it, 180 on overhangs facing away.FloatAttribute.curvature(body, kind)(aCurvatureAttribute): the surface’s curvature in 1/mm:"mean"(positive on convex skin, negative in hollows),"gaussian"(negative on saddles) or"maximum"(1 / the tightest bend radius; sharp edges read high, so it shows where a fillet may be needed).FloatAttribute.between(first, second): 0 at the first body, 1 at the second, graded by the distances to both.FloatAttribute.inverse_distance_weight(distances, index): the normalized inverse-distance weight of one of several distance fields (seeds or bodies).betweenis its two-body case.
import pyvcad as pv
part = pv.Sphere(pv.Vec3(0, 0, 0), 20.0)
overhang = pv.FloatAttribute.surface_angle(part).normalize(110.0, 150.0).ease("smoothstep")
blend = pv.FloatAttribute.between(pv.Sphere(pv.Vec3(-30, 0, 0), 6.0), part, bandwidth=40.0)
- class pyvcad.NormalFieldAttribute#
A vector field: the unit surface normal of another body (any node), extended through space.
On the surface it is the outward normal; off the surface it is the normal of the closest surface point (the gradient of the body’s signed distance, by central differences with a step of half the voxel size). It is the zero vector where the normal is undefined, for example at a sphere’s centre. The body is cloned and prepared like a DistanceFieldAttribute; your node is not modified. Use it to grade by surface orientation (angle() or dot() with a direction), or scale it to move material along the normals (pv.Warp.displace). Usually built with pv.Vec3Attribute.surface_normal(body).
- __init__(self: pyvcad.pyvcad.NormalFieldAttribute, body: pyvcad.pyvcad.Node, voxel_size: SupportsFloat | SupportsIndex = 0.5, bandwidth: SupportsFloat | SupportsIndex = 10.0) None#
Construct the normal field of a body.
- Parameters:
body (Node) – The node whose normals are measured.
voxel_size (float) – Voxel size in mm used to prepare the body; the gradient step is half of it.
bandwidth (float) – Distance in mm around the body’s box where its field is evaluated.
Example
>>> normals = pv.NormalFieldAttribute(part, bandwidth=5.0) >>> facing_up = normals.dot(pv.Vec3Attribute(0.0, 0.0, 1.0))
- property distance#
The signed distance field of the body whose gradient is taken.
- property step#
The central-difference step in mm.
- class pyvcad.CurvatureAttribute#
A scalar field: the curvature of another body’s surface (any node), in 1/mm.
Computed from the gradient and Hessian of the body’s signed distance by central differences with a step of half the voxel size. On the surface it is the surface’s curvature; off it, the curvature of the level set through the point. The body is cloned and prepared like a DistanceFieldAttribute; your node is not modified. Kinds: mean (1/R on a sphere, positive on convex skin, negative in hollows), gaussian (1/R^2 on a sphere, 0 on cylinders, negative on saddles) and maximum (largest absolute principal curvature, 1 / tightest bend radius; a sharp edge reads about 1 / step). Usually built with pv.FloatAttribute.curvature(body, kind).
- class Kind#
Which curvature a CurvatureAttribute reports.
Members:
mean
gaussian
maximum
- __init__(self: pyvcad.pyvcad.CurvatureAttribute.Kind, value: SupportsInt | SupportsIndex) None#
- gaussian = <Kind.gaussian: 1>#
- maximum = <Kind.maximum: 2>#
- mean = <Kind.mean: 0>#
- CurvatureAttribute.Kind.name -> str
- property value#
- __init__(self: pyvcad.pyvcad.CurvatureAttribute, body: pyvcad.pyvcad.Node, kind: object = 'mean', voxel_size: SupportsFloat | SupportsIndex = 0.5, bandwidth: SupportsFloat | SupportsIndex = 10.0) None#
Construct the curvature field of a body.
- Parameters:
body (Node) – The node whose surface is measured.
kind (str | CurvatureAttribute.Kind) – “mean”, “gaussian” or “maximum”.
voxel_size (float) – Voxel size in mm used to prepare the body; the difference step is half of it.
bandwidth (float) – Distance in mm around the body’s box where its field is evaluated.
Example
>>> bend = pv.CurvatureAttribute(part, "maximum", voxel_size=0.2)
- property kind#
The curvature kind.
- property step#
The central-difference step in mm.
Fields from scattered points#
Values known only at scattered points (measurements, sensor readings, simulation results exported
as points) become a field defined everywhere with FloatAttribute.from_points(points, values) or
Vec3Attribute.from_points(points, vectors), from NumPy arrays. The points are indexed by a k-d
tree. Three methods fill the space between them:
"nearest": the value of the nearest point."idw"(default): a weighted average of the nearest points; exact at the points, continuous, and always within the range of the data, so it can drive geometry without hints."rbf": a smooth surface through every point.kernel="thin_plate_spline"is global (up to 2,500 points; fitting is a dense solve, about a second for 2,000 points, and each sample visits every point).kernel="wendland"reaches onlyradiusfrom each point, so it scales to many points; away from the data it returns to the mean value.smoothingfits noisy data loosely.
import numpy as np
import pyvcad as pv
sensors = np.array([[0, 0, 0], [40, 0, 0], [0, 30, 0], [40, 30, 0], [20, 15, 5]], dtype=float)
readings = np.array([1.0, 3.0, 2.0, 5.0, 2.5])
smooth = pv.FloatAttribute.from_points(sensors, readings, method="rbf")
bounded = pv.FloatAttribute.from_points(sensors, readings, method="idw", neighbors=4)
- class pyvcad.ScatteredFloatAttribute#
A scalar field from values known at scattered points: measurements, sensor readings, or simulation results exported as points. The field is defined everywhere and evaluated natively in parallel; the points are indexed by a k-d tree. Build it from NumPy arrays with this constructor or pv.FloatAttribute.from_points(). With method “nearest” or “idw” it knows its range (the data range), so it can drive geometry directly.
- __init__(self: pyvcad.pyvcad.ScatteredFloatAttribute, points: Annotated[numpy.typing.ArrayLike, numpy.float64], values: Annotated[numpy.typing.ArrayLike, numpy.float64], method: str = 'idw', neighbors: SupportsInt | SupportsIndex = 8, power: SupportsFloat | SupportsIndex = 2.0, kernel: str = 'thin_plate_spline', radius: object = None, smoothing: SupportsFloat | SupportsIndex = 0.0) None#
Construct a scalar field from values at scattered points.
- Parameters:
points (numpy.ndarray) – (N, 3) positions in mm.
values (numpy.ndarray) – (N,) values, one per point.
method (str) – How the values fill the space between the points. “nearest” takes the value of the nearest point. “idw” averages the nearest points, closer ones weighing more: exact at the points, continuous, and always within the range of the data. “rbf” fits a smooth radial-basis-function surface through every point.
neighbors (int) – idw: how many nearest points are averaged.
power (float) – idw: how fast a point’s weight falls with distance.
kernel (str) – rbf: “thin_plate_spline” (smooth and global; at most 2,500 points; each sample visits every point) or “wendland” (compact: each point reaches only radius, so it scales to many points; away from the data it returns to the mean value).
radius (float | None) – rbf with wendland: the reach of each point in mm. None uses three times the median spacing between points.
smoothing (float) – rbf: 0 passes exactly through every value; larger values fit noisy data loosely (and allow repeated points).
Example
>>> sensors = np.array([[0, 0, 0], [40, 0, 0], [0, 30, 0], [40, 30, 10]], dtype=float) >>> readings = np.array([1.0, 3.0, 2.0, 5.0]) >>> modulus = pv.FloatAttribute.from_points(sensors, readings, method="rbf")
- property method#
“nearest”, “idw” or “rbf”.
- Type:
The interpolation method
- property point_count#
The number of points.
- property radius#
The reach of each point in mm for the wendland kernel, else None.
- class pyvcad.ScatteredVec3Attribute#
A vector field from vectors known at scattered points, for example measured displacements; each component is interpolated with the same weights. See ScatteredFloatAttribute.
- __init__(self: pyvcad.pyvcad.ScatteredVec3Attribute, points: Annotated[numpy.typing.ArrayLike, numpy.float64], vectors: Annotated[numpy.typing.ArrayLike, numpy.float64], method: str = 'idw', neighbors: SupportsInt | SupportsIndex = 8, power: SupportsFloat | SupportsIndex = 2.0, kernel: str = 'thin_plate_spline', radius: object = None, smoothing: SupportsFloat | SupportsIndex = 0.0) None#
Construct a vector field from vectors at scattered points.
- Parameters:
points (numpy.ndarray) – (N, 3) positions in mm.
vectors (numpy.ndarray) – (N, 3) vectors, one per point.
method (str) – How the values fill the space between the points. “nearest” takes the value of the nearest point. “idw” averages the nearest points, closer ones weighing more: exact at the points, continuous, and always within the range of the data. “rbf” fits a smooth radial-basis-function surface through every point.
neighbors (int) – idw: how many nearest points are averaged.
power (float) – idw: how fast a point’s weight falls with distance.
kernel (str) – rbf: “thin_plate_spline” (smooth and global; at most 2,500 points; each sample visits every point) or “wendland” (compact: each point reaches only radius, so it scales to many points; away from the data it returns to the mean value).
radius (float | None) – rbf with wendland: the reach of each point in mm. None uses three times the median spacing between points.
smoothing (float) – rbf: 0 passes exactly through every value; larger values fit noisy data loosely (and allow repeated points).
Example
>>> displacement = pv.Vec3Attribute.from_points(nodes, offsets, method="idw") >>> moved = pv.Warp.displace(displacement, part)
- property method#
“nearest”, “idw” or “rbf”.
- Type:
The interpolation method
- property point_count#
The number of points.
Field-valued geometry parameters#
Some operators take geometry parameters that may vary in space, such as an offset distance or a
blend radius. Every such parameter accepts the same inputs: a float, any FloatAttribute,
a numba.cfunc with signature float64(float64, float64, float64, float64), or a plain Python
callable f(x, y, z, d), which is compiled with numba. Wrap a field in ScalarParameter only
to attach hints: the range it stays in (used to size bounding boxes) and a bound on its slope.
A field that knows its range or slope by construction reports it itself (value_bounds() and
lipschitz_bound()): constants, clamped, eased and transferred fields, noise, and arithmetic on
such fields. Then no ScalarParameter is needed.
import pyvcad as pv
thickness = pv.FloatAttribute("1 + 0.05 * z")
parameter = pv.ScalarParameter(thickness, minimum=0.5, maximum=3.0, lipschitz=0.05)
- class pyvcad.ScalarParameter#
A geometry parameter that is a constant or a spatially varying scalar field.
Operators whose parameters may vary in space (for example an offset distance or a blend radius) accept any of: a float, any FloatAttribute, a numba.cfunc with signature float64(float64, float64, float64, float64), or a plain Python callable f(x, y, z, d), which is compiled with numba. Pass a ScalarParameter only when you want to attach hints to a field:
minimum / maximum: the range the field stays in. Operators use it to size their bounding boxes; some require it for fields.
lipschitz: an upper bound L on the field’s slope: between any two points the field changes by at most L times their distance. Operators that subtract a field from a distance use it to keep a safe distance bound.
Constants always know their bounds, and their slope is zero.
Example
>>> import pyvcad as pv >>> thickness = pv.FloatAttribute('1 + 0.1 * x') >>> parameter = pv.ScalarParameter(thickness, minimum=0.5, maximum=2.0, lipschitz=0.1)
- __init__(self: pyvcad.pyvcad.ScalarParameter, value: object, minimum: object = None, maximum: object = None, lipschitz: object = None) None#
Construct a parameter from a constant or a field, with optional hints.
- Parameters:
value (float | FloatAttribute | ScalarParameter | numba.cfunc | callable) – The constant or field.
minimum (float | None) – Smallest value the field takes. Give with maximum.
maximum (float | None) – Largest value the field takes. Give with minimum.
lipschitz (float | None) – Upper bound on the field’s slope (value change per unit length).
Example
>>> import pyvcad as pv >>> radius = pv.ScalarParameter(lambda x, y, z, d: 1.0 + 0.05 * x, minimum=0.5, maximum=1.5)
- property attribute#
The parameter as a FloatAttribute; a constant is wrapped in a new FloatAttribute.
- property bounds#
The (minimum, maximum) range, or None when unknown. Constants always know it.
- property constant#
The constant value. Raises for a field.
- property is_constant#
True when the parameter is a constant (including a FloatAttribute built from a float).
- property lipschitz#
The slope bound, or None when unknown. Constants report 0.
- value(self: pyvcad.pyvcad.ScalarParameter, x: SupportsFloat | SupportsIndex, y: SupportsFloat | SupportsIndex, z: SupportsFloat | SupportsIndex, d: SupportsFloat | SupportsIndex = 0.0) float#
Evaluate the parameter at a point.
- Parameters:
x (float) – The x-coordinate.
y (float) – The y-coordinate.
z (float) – The z-coordinate.
d (float) – The signed distance passed to the field.
Example
>>> pv.ScalarParameter(2.0).value(0.0, 0.0, 0.0) 2.0
- pyvcad.as_float_attribute(value: object) FloatAttribute#
Convert any scalar input to a FloatAttribute.
This is the conversion every field-valued parameter uses. A FloatAttribute is returned unchanged; a number becomes a constant; a ScalarParameter gives its attribute; a numba.cfunc is wrapped; a plain callable f(x, y, z, d) is compiled with numba first.
- Parameters:
value (float | FloatAttribute | ScalarParameter | numba.cfunc | callable) – The input.
Example
>>> import pyvcad as pv >>> field = pv.as_float_attribute(lambda x, y, z, d: 0.5 + 0.01 * z)
Vector-valued parameters, such as a Warp map or a displacement, take the same kinds of inputs in
vector form: a Vec3Attribute, a Vec3sVolume, a Vec3 or three numbers, three expression
strings, three component callbacks, one numba.cfunc with signature
void(float64, float64, float64, float64, CPointer(float64)) that writes the three components into
its last argument, or a plain callable f(x, y, z, d) returning three numbers, compiled with numba.
import math
import pyvcad as pv
ripple = pv.as_vec3_attribute(lambda x, y, z, d: (x, y, z + 0.5 * math.sin(x)))
lean = pv.as_vec3_attribute(("x - 0.2 * z", "y", "z"))
- pyvcad.as_vec3_attribute(value: object) Vec3Attribute#
Convert any vector input to a Vec3Attribute.
This is the conversion every vector-field parameter uses (for example a Warp map or a displacement). A Vec3Attribute is returned unchanged; a Vec3sVolume is sampled; a Vec3 or three numbers is a constant; three expression strings are expressions (numbers may be mixed in); three numba.cfuncs or plain callables f(x, y, z, d) are the components; one numba.cfunc with signature void(float64, float64, float64, float64, CPointer(float64)) writes x’, y’, z’ into its last argument; a plain callable f(x, y, z, d) returning three numbers is compiled to that cfunc with numba. Callbacks run natively, without the GIL.
- Parameters:
value (Vec3Attribute | Vec3sVolume | Vec3 | tuple | numba.cfunc | callable) – The input.
Example
>>> import math >>> import pyvcad as pv >>> ripple = pv.as_vec3_attribute(lambda x, y, z, d: (x, y, z + 0.5 * math.sin(x))) >>> lean = pv.as_vec3_attribute(('x - 0.2 * z', 'y', 'z'))
Operators that grow material their child never had take a GrowthPolicy, which decides the
attributes of the grown material. Every node says how accurate its distance is, for its whole
subtree, with DistanceAccuracy (Node.distance_accuracy(), with Node.lipschitz_bound()
for the factor of a bound).
- class pyvcad.GrowthPolicy#
What attributes a growth operator gives material its child never had.
Growth operators (positive offsets, outward shells, thickening) create material outside their child. Inside the child they always report the child’s attributes; the policy decides the grown material.
Members:
undefined : No attributes in grown material (the default, and the historical Offset behaviour).
extend : The child’s attributes at its closest surface point, so material carries straight outward.
own : Only the operator’s own attributes.
- extend = <GrowthPolicy.extend: 1>#
- GrowthPolicy.name -> str
- own = <GrowthPolicy.own: 2>#
- undefined = <GrowthPolicy.undefined: 0>#
- property value#
- class pyvcad.DistanceAccuracy#
How faithfully a node’s value matches the true signed distance to its surface.
The surface and the sign are always meant to be right; this describes the magnitude away from the surface. Node.distance_accuracy() reports it for the node’s whole subtree, with Node.lipschitz_bound() for the factor L of a bound.
Members:
exact : A true signed distance (lipschitz_bound() is 1).
bound : Within the bandwidth, never more than lipschitz_bound() times the true distance; safe for marching, offsets and skipping empty voxels.
approximate : Close to the surface, but may over- or under-estimate farther away.
- approximate = <DistanceAccuracy.approximate: 2>#
- bound = <DistanceAccuracy.bound: 1>#
- exact = <DistanceAccuracy.exact: 0>#
- DistanceAccuracy.name -> str
- property value#
Converters#
- class pyvcad.AttributeConverterBase#
Base class for converting attribute samples to new attributes.
An AttributeModifier node calls convert() on the samples its child produces at every point inside the part. Subclass it in Python by overriding all four methods.
- __init__(self: pyvcad.pyvcad.AttributeConverterBase) None#
Constructs a new attribute converter base.
- clone(self: pyvcad.pyvcad.AttributeConverterBase) pyvcad.pyvcad.AttributeConverterBase#
Create a deep copy of this converter for thread-safe use.
- Returns:
A new independent instance.
- Return type:
- convert(self: pyvcad.pyvcad.AttributeConverterBase, samples: pyvcad.pyvcad.AttributeSamples) pyvcad.pyvcad.AttributeSamples#
Converts input samples to output samples.
- Parameters:
samples (AttributeSamples) – The input samples to convert.
- Returns:
The converted samples.
- Return type:
- output_attributes(self: pyvcad.pyvcad.AttributeConverterBase) list[str]#
Returns the list of output attribute names produced by this converter.
- Returns:
The attribute names this converter writes.
- Return type:
list[str]
- required_attributes(self: pyvcad.pyvcad.AttributeConverterBase) list[str]#
Returns the list of required input attribute names.
- Returns:
The attribute names this converter reads.
- Return type:
list[str]
- class pyvcad.LookupTableEntry#
A single entry in a lookup table.
Which fields are read depends on the converter’s mode and input count:
Single-input STEP: [input_low, input_high] is the inclusive matching window, and output_values holds one value per output attribute.
Multi-input STEP: input_ranges holds one [low, high] pair per input attribute, and output_values holds one value per input attribute.
Single-input LINEAR: input_low is the interpolation knot, and the first output value is the value at that knot.
Two-input LINEAR: input_points holds the (input 0, input 1) grid point, and output_values holds exactly one value.
- __init__(*args, **kwargs)#
Overloaded function.
__init__(self: pyvcad.pyvcad.LookupTableEntry, input_low: typing.SupportsFloat | typing.SupportsIndex, input_high: typing.SupportsFloat | typing.SupportsIndex, output_values: collections.abc.Sequence[object]) -> None
Create a multi-output entry for single-input STEP mode.
__init__(self: pyvcad.pyvcad.LookupTableEntry, input_low: typing.SupportsFloat | typing.SupportsIndex, input_high: typing.SupportsFloat | typing.SupportsIndex, output_value: object) -> None
Create a single-output entry for single-input STEP mode.
__init__(self: pyvcad.pyvcad.LookupTableEntry, input: typing.SupportsFloat | typing.SupportsIndex, output_value: object) -> None
Create a point-based entry for single-input LINEAR mode.
__init__(self: pyvcad.pyvcad.LookupTableEntry, input_points: collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], output_values: collections.abc.Sequence[object]) -> None
Create a grid-point entry for two-input LINEAR mode (exactly one output value).
__init__(self: pyvcad.pyvcad.LookupTableEntry, input_points: collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], output_value: object) -> None
Create a single-output grid-point entry for two-input LINEAR mode.
__init__(self: pyvcad.pyvcad.LookupTableEntry, input_ranges: collections.abc.Sequence[tuple[typing.SupportsFloat | typing.SupportsIndex, typing.SupportsFloat | typing.SupportsIndex]], output_values: collections.abc.Sequence[object]) -> None
Create a multi-input entry for independent STEP matching.
input_ranges: list of [low, high] pairs, one per input attribute. output_values: list of values, one per input (matched independently).
When the converter has 1 output, the output is written only if every input matched, and the matched values are assembled (Vec3 + float -> Vec4 for color_rgba; otherwise the first value is used).
- property input_high#
Inclusive upper bound of the STEP window. Unused in LINEAR mode.
- property input_low#
Lower bound of the STEP window, or the knot for single-input LINEAR mode.
- property input_points#
Per-input grid coordinates for two-input LINEAR mode.
- property input_ranges#
Per-input [low, high] windows for multi-input STEP mode.
- property is_valid#
a lookup that matches, interpolates through, or clamps to an invalid entry raises RuntimeError.
- Type:
Whether this entry holds a usable result. False marks a hole in the table
- property output_values#
The output values for this entry (float, Vec3, Vec4, or dict[int, float]).
- class pyvcad.InterpolationMode#
Interpolation mode for lookup table converters.
- Values:
STEP: Range-based threshold matching (value falls within [low, high]). LINEAR: Sorted-point lookup with linear interpolation and clamping.
Members:
STEP
LINEAR
- LINEAR = <InterpolationMode.LINEAR: 1>#
- STEP = <InterpolationMode.STEP: 0>#
- InterpolationMode.name -> str
- property value#
- class pyvcad.LookupTableConverter#
A generic lookup-table-based attribute converter.
Maps input attribute value(s) to output attribute value(s) using a lookup table. Supports STEP (range-based threshold matching) and LINEAR (sorted-point interpolation with clamping) modes.
STEP, one input: the first entry whose [input_low, input_high] contains the value wins, and its output_values set the outputs in order. No match leaves the samples unchanged.
STEP, several inputs: each input is matched independently against input_ranges. With several outputs, each matched input sets its own output. With one output, the output is written only when every input matched (all-or-nothing), and the values are assembled (Vec3 + float -> Vec4).
LINEAR needs exactly one output. With one input, entries are sorted by input_low and interpolated, clamped at the ends. With two inputs, entries give input_points, must form a complete rectilinear grid, and are bilinearly interpolated.
Inputs must be float samples. A missing input leaves the samples unchanged (in multi-input STEP it is skipped). Input samples are kept.
- Single-input STEP example (HU to Color):
>>> import pyvcad as pv >>> entries = [ ... pv.LookupTableEntry(-1000, -500, pv.Vec4(0,0,0,0)), ... pv.LookupTableEntry(-500, 0, pv.Vec4(1,0,0,0.5)), ... ] >>> conv = pv.LookupTableConverter(['hu'], ['color_rgba'], entries, pv.InterpolationMode.STEP)
- Multi-input STEP example (temperature -> RGB, density -> alpha):
>>> entries = [ ... pv.LookupTableEntry([(0, 1), (0, 0.01)], [pv.Vec3(1,1,1), 0.0]), ... pv.LookupTableEntry([(1, 10), (0.01, 0.5)], [pv.Vec3(1,0,0), 0.5]), ... ] >>> conv = pv.LookupTableConverter( ... ['temperature', 'density'], ['color_rgba'], ... entries, pv.InterpolationMode.STEP)
- Two-input LINEAR example (modulus+toughness to volume fractions):
>>> entry = pv.LookupTableEntry([10.0, 2.0], {1: 0.7, 2: 0.2, 3: 0.1}) >>> entry.is_valid = True >>> conv = pv.LookupTableConverter( ... ['modulus', 'toughness'], ['volume_fractions'], ... [entry], pv.InterpolationMode.LINEAR)
- LINEAR example (temperature to flow rate):
>>> entries = [pv.LookupTableEntry(180, 1.0), pv.LookupTableEntry(220, 0.5)] >>> conv = pv.LookupTableConverter(['temperature'], ['flow_rate'], entries, pv.InterpolationMode.LINEAR)
- __init__(self: pyvcad.pyvcad.LookupTableConverter, input_attributes: collections.abc.Sequence[str], output_attributes: collections.abc.Sequence[str], entries: collections.abc.Sequence[pyvcad.pyvcad.LookupTableEntry], mode: pyvcad.pyvcad.InterpolationMode = <InterpolationMode.STEP: 0>) None#
Create a LookupTableConverter.
- Parameters:
input_attributes (list[str]) – Names of the input attributes to read.
output_attributes (list[str]) – Names of the output attributes to produce.
entries (list[LookupTableEntry]) – The lookup table entries.
mode (InterpolationMode) – STEP or LINEAR (default: STEP).
- Raises:
RuntimeError – If there are no inputs or outputs, LINEAR mode is given other than one or two inputs and exactly one output, a two-input LINEAR table is not a complete grid, or a multi-input STEP entry has the wrong number of ranges or values.
- class pyvcad.ExpressionConverter#
An attribute converter that evaluates mathematical expressions.
Input attribute names are used directly as variable names in the expression strings. For example, if input_attributes = [‘temperature’], then the expression ‘20 * temperature + 100’ will read the ‘temperature’ attribute sample and compute the result.
Each output attribute has its own expression string.
Inputs must be scalar (float) samples. If any input is missing at a point, the samples pass through unchanged. Otherwise each output is added or replaced and the inputs are kept. Expressions are compiled on the first convert() call, so a bad expression raises there rather than in the constructor.
- Example (single output):
>>> import pyvcad as pv >>> conv = pv.ExpressionConverter( ... input_attributes=['temperature'], ... output_attributes=['flow_rate'], ... expressions=['20 * temperature + 100'])
- Example (multiple outputs):
>>> conv = pv.ExpressionConverter( ... input_attributes=['hu'], ... output_attributes=['modulus', 'toughness'], ... expressions=['hu * 1000 + 500', '0.5 * hu + 10'])
- __init__(self: pyvcad.pyvcad.ExpressionConverter, input_attributes: collections.abc.Sequence[str], output_attributes: collections.abc.Sequence[str], expressions: collections.abc.Sequence[str]) None#
Create an ExpressionConverter.
- Parameters:
input_attributes (list[str]) – Names of the input attributes (used as variable names).
output_attributes (list[str]) – Names of the output attributes to produce.
expressions (list[str]) – Math expression strings, one per output attribute.
- Raises:
RuntimeError – If there are no inputs or outputs, or the output and expression counts differ.
- class pyvcad.VolumeFractionsExpressionConverter#
An attribute converter that evaluates math expressions into a volume-fraction map.
Input attribute names are used directly as variables inside each expression. The material IDs and expressions are aligned by index, and the converter writes one volume-fraction entry per material to DefaultAttributes.VOLUME_FRACTIONS.
Inputs must be scalar (float) samples. If any input is missing at a point, the samples pass through unchanged. The fractions are written exactly as the expressions evaluate: they are not clamped or normalized to sum to 1. Expressions are compiled on the first convert() call.
Example
>>> import pyvcad as pv >>> conv = pv.VolumeFractionsExpressionConverter( ... input_attributes=['shore_hardness'], ... materials=[1, 2], ... expressions=['shore_hardness / 100.0', '1.0 - shore_hardness / 100.0'])
- __init__(self: pyvcad.pyvcad.VolumeFractionsExpressionConverter, input_attributes: collections.abc.Sequence[str], materials: collections.abc.Sequence[SupportsInt | SupportsIndex], expressions: collections.abc.Sequence[str]) None#
Create a VolumeFractionsExpressionConverter.
- Parameters:
input_attributes (list[str]) – Scalar input attributes used as variables.
materials (list[int]) – Material IDs aligned with expressions.
expressions (list[str]) – Math expression strings, one per material.
- Raises:
RuntimeError – If there are no inputs or materials, or the material and expression counts differ.
- class pyvcad.Vec3ToScalarsConverter#
Splits a Vec3 attribute into three named float attributes (X, Y, Z).
Samples without the input pass through unchanged; the input sample is kept.
- __init__(self: pyvcad.pyvcad.Vec3ToScalarsConverter, input_attribute: str, x_attribute: str, y_attribute: str, z_attribute: str) None#
Create a Vec3-to-scalars converter.
- Parameters:
input_attribute (str) – Name of the source Vec3 attribute.
x_attribute (str) – Name of the output float attribute for X.
y_attribute (str) – Name of the output float attribute for Y.
z_attribute (str) – Name of the output float attribute for Z.
- Raises:
RuntimeError – If a name is empty or two names are equal.
Example
>>> import pyvcad as pv >>> conv = pv.Vec3ToScalarsConverter('color_rgb', 'r', 'g', 'b') >>> node = pv.AttributeModifier(conv, child)
- input_attribute(self: pyvcad.pyvcad.Vec3ToScalarsConverter) str#
Returns the name of the source Vec3 attribute.
- Returns:
The attribute name.
- Return type:
str
- x_attribute(self: pyvcad.pyvcad.Vec3ToScalarsConverter) str#
Returns the name of the output float attribute for the X component.
- Returns:
The attribute name.
- Return type:
str
- y_attribute(self: pyvcad.pyvcad.Vec3ToScalarsConverter) str#
Returns the name of the output float attribute for the Y component.
- Returns:
The attribute name.
- Return type:
str
- z_attribute(self: pyvcad.pyvcad.Vec3ToScalarsConverter) str#
Returns the name of the output float attribute for the Z component.
- Returns:
The attribute name.
- Return type:
str
- class pyvcad.Vec4ToScalarsConverter#
Splits a Vec4 attribute into four named float attributes (X, Y, Z, W).
Samples without the input pass through unchanged; the input sample is kept.
- __init__(self: pyvcad.pyvcad.Vec4ToScalarsConverter, input_attribute: str, x_attribute: str, y_attribute: str, z_attribute: str, w_attribute: str) None#
Create a Vec4-to-scalars converter.
- Parameters:
input_attribute (str) – Name of the source Vec4 attribute.
x_attribute (str) – Name of the output float attribute for X.
y_attribute (str) – Name of the output float attribute for Y.
z_attribute (str) – Name of the output float attribute for Z.
w_attribute (str) – Name of the output float attribute for W.
- Raises:
RuntimeError – If a name is empty or two names are equal.
Example
>>> import pyvcad as pv >>> conv = pv.Vec4ToScalarsConverter('color_rgba', 'r', 'g', 'b', 'a') >>> node = pv.AttributeModifier(conv, child)
- input_attribute(self: pyvcad.pyvcad.Vec4ToScalarsConverter) str#
Returns the name of the source Vec4 attribute.
- Returns:
The attribute name.
- Return type:
str
- w_attribute(self: pyvcad.pyvcad.Vec4ToScalarsConverter) str#
Returns the name of the output float attribute for the W component.
- Returns:
The attribute name.
- Return type:
str
- x_attribute(self: pyvcad.pyvcad.Vec4ToScalarsConverter) str#
Returns the name of the output float attribute for the X component.
- Returns:
The attribute name.
- Return type:
str
- y_attribute(self: pyvcad.pyvcad.Vec4ToScalarsConverter) str#
Returns the name of the output float attribute for the Y component.
- Returns:
The attribute name.
- Return type:
str
- z_attribute(self: pyvcad.pyvcad.Vec4ToScalarsConverter) str#
Returns the name of the output float attribute for the Z component.
- Returns:
The attribute name.
- Return type:
str
- class pyvcad.ScalarsToVec3Converter#
Combines three named float attributes into a Vec3 (X, Y, Z).
If any input is missing, the samples pass through unchanged. The inputs are kept.
- __init__(self: pyvcad.pyvcad.ScalarsToVec3Converter, x_attribute: str, y_attribute: str, z_attribute: str, output_attribute: str) None#
Create a scalars-to-Vec3 converter.
- Parameters:
x_attribute (str) – Name of the input float attribute for X.
y_attribute (str) – Name of the input float attribute for Y.
z_attribute (str) – Name of the input float attribute for Z.
output_attribute (str) – Name of the output Vec3 attribute.
- Raises:
RuntimeError – If a name is empty or two names are equal.
Example
>>> import pyvcad as pv >>> conv = pv.ScalarsToVec3Converter('r', 'g', 'b', 'color_rgb') >>> node = pv.AttributeModifier(conv, child)
- output_attribute(self: pyvcad.pyvcad.ScalarsToVec3Converter) str#
Returns the name of the output Vec3 attribute.
- Returns:
The attribute name.
- Return type:
str
- x_attribute(self: pyvcad.pyvcad.ScalarsToVec3Converter) str#
Returns the name of the input float attribute for the X component.
- Returns:
The attribute name.
- Return type:
str
- y_attribute(self: pyvcad.pyvcad.ScalarsToVec3Converter) str#
Returns the name of the input float attribute for the Y component.
- Returns:
The attribute name.
- Return type:
str
- z_attribute(self: pyvcad.pyvcad.ScalarsToVec3Converter) str#
Returns the name of the input float attribute for the Z component.
- Returns:
The attribute name.
- Return type:
str
- class pyvcad.ScalarsToVec4Converter#
Combines four named float attributes into a Vec4 (X, Y, Z, W).
If any input is missing, the samples pass through unchanged. The inputs are kept.
- __init__(self: pyvcad.pyvcad.ScalarsToVec4Converter, x_attribute: str, y_attribute: str, z_attribute: str, w_attribute: str, output_attribute: str) None#
Create a scalars-to-Vec4 converter.
- Parameters:
x_attribute (str) – Name of the input float attribute for X.
y_attribute (str) – Name of the input float attribute for Y.
z_attribute (str) – Name of the input float attribute for Z.
w_attribute (str) – Name of the input float attribute for W.
output_attribute (str) – Name of the output Vec4 attribute.
- Raises:
RuntimeError – If a name is empty or two names are equal.
Example
>>> import pyvcad as pv >>> conv = pv.ScalarsToVec4Converter('r', 'g', 'b', 'a', 'color_rgba') >>> node = pv.AttributeModifier(conv, child)
- output_attribute(self: pyvcad.pyvcad.ScalarsToVec4Converter) str#
Returns the name of the output Vec4 attribute.
- Returns:
The attribute name.
- Return type:
str
- w_attribute(self: pyvcad.pyvcad.ScalarsToVec4Converter) str#
Returns the name of the input float attribute for the W component.
- Returns:
The attribute name.
- Return type:
str
- x_attribute(self: pyvcad.pyvcad.ScalarsToVec4Converter) str#
Returns the name of the input float attribute for the X component.
- Returns:
The attribute name.
- Return type:
str
- y_attribute(self: pyvcad.pyvcad.ScalarsToVec4Converter) str#
Returns the name of the input float attribute for the Y component.
- Returns:
The attribute name.
- Return type:
str
- z_attribute(self: pyvcad.pyvcad.ScalarsToVec4Converter) str#
Returns the name of the input float attribute for the Z component.
- Returns:
The attribute name.
- Return type:
str
- class pyvcad.RgbToRgbaConverter#
Converts COLOR_RGB samples to COLOR_RGBA by copying RGB and setting a constant alpha.
Samples without COLOR_RGB pass through unchanged; the COLOR_RGB sample is kept.
Example
>>> import pyvcad as pv >>> converter = pv.RgbToRgbaConverter(alpha=0.5) >>> converter.alpha() 0.5
- __init__(self: pyvcad.pyvcad.RgbToRgbaConverter, alpha: SupportsFloat | SupportsIndex = 1.0) None#
Create an RGB-to-RGBA converter.
- Parameters:
alpha (float) – Constant alpha channel value assigned to COLOR_RGBA outputs.
- Raises:
RuntimeError – If alpha is not finite.
- alpha(self: pyvcad.pyvcad.RgbToRgbaConverter) float#
Returns the constant alpha value written to COLOR_RGBA.
- Returns:
The configured alpha.
- Return type:
float
- class pyvcad.RgbaToRgbConverter#
Converts COLOR_RGBA samples to COLOR_RGB by dropping the alpha channel.
The COLOR_RGBA sample is kept, and samples without it pass through unchanged.
Example
>>> import pyvcad as pv >>> converter = pv.RgbaToRgbConverter()
- __init__(self: pyvcad.pyvcad.RgbaToRgbConverter) None#
Create an RGBA-to-RGB converter.
Conflict resolvers#
Where several children of a Binary or NAry node overlap and carry the same
attribute, a resolver decides the combined value. Assign one per attribute name with
set_attribute_conflict_resolver(name, resolver). The resolvers live in the pyvcad.resolvers
submodule. See Attribute Conflict Resolution for a walkthrough.
import pyvcad as pv
union = pv.Union([pv.Sphere(pv.Vec3(-3, 0, 0), 5), pv.Sphere(pv.Vec3(3, 0, 0), 5)])
union.set_attribute_conflict_resolver(pv.DefaultAttributes.MODULUS, pv.resolvers.MaxConflictResolver())
- class pyvcad.resolvers.Vec4Mode#
How MinConflictResolver and MaxConflictResolver compare Vec3 and Vec4 values.
Members:
Magnitude : Keep the whole vector (Vec3 or Vec4) with the smallest/largest length.
PerChannel : Resolve per channel independently.
- Magnitude = <Vec4Mode.Magnitude: 1>#
- PerChannel = <Vec4Mode.PerChannel: 0>#
- Vec4Mode.name -> str
- property value#
- class pyvcad.resolvers.AttributeConflictResolver#
Base class for all attribute conflict resolvers.
A resolver combines the values of one attribute where several children of a node overlap. Assign one with Node.set_attribute_conflict_resolver().
- class pyvcad.resolvers.AverageConflictResolver#
Averages the overlapping attributes.
Volume-fraction maps are averaged per material and renormalized to sum to 1.
- __init__(self: pyvcad.pyvcad.resolvers.AverageConflictResolver) None#
- class pyvcad.resolvers.SumConflictResolver#
Sums overlapping attributes. Volume-fraction results are normalized.
- __init__(self: pyvcad.pyvcad.resolvers.SumConflictResolver) None#
- class pyvcad.resolvers.MinConflictResolver#
Takes the minimum overlapping attribute.
Scalars take the minimum; Vec3/Vec4 values follow
mode. Volume-fraction maps are first averaged, then only the material(s) with the smallest averaged fraction are kept and renormalized to sum to 1.- __init__(self: pyvcad.pyvcad.resolvers.MinConflictResolver, mode: pyvcad.pyvcad.resolvers.Vec4Mode = <Vec4Mode.PerChannel: 0>) None#
- Parameters:
mode (Vec4Mode) – How Vec3/Vec4 values are compared (default: PerChannel).
- class pyvcad.resolvers.MaxConflictResolver#
Takes the maximum overlapping attribute.
Scalars take the maximum; Vec3/Vec4 values follow
mode. Volume-fraction maps are first averaged, then only the material(s) with the largest averaged fraction are kept and renormalized to sum to 1.- __init__(self: pyvcad.pyvcad.resolvers.MaxConflictResolver, mode: pyvcad.pyvcad.resolvers.Vec4Mode = <Vec4Mode.PerChannel: 0>) None#
- Parameters:
mode (Vec4Mode) – How Vec3/Vec4 values are compared (default: PerChannel).
- class pyvcad.resolvers.CustomFloatConflictResolver#
A custom float attribute conflict resolver using a Numba cfunc callback.
- __init__(self: pyvcad.pyvcad.resolvers.CustomFloatConflictResolver, func: object) None#
- Parameters:
func – numba.cfunc with signature float64(float64, float64). Folded left to right over the values.
- class pyvcad.resolvers.CustomVec4ConflictResolver#
A custom Vec4 attribute conflict resolver using Numba cfunc callbacks for each channel.
- __init__(self: pyvcad.pyvcad.resolvers.CustomVec4ConflictResolver, r_func: object, g_func: object, b_func: object, a_func: object) None#
- Parameters:
r_func – numba.cfunc callbacks with signature float64(float64, float64),
g_func – numba.cfunc callbacks with signature float64(float64, float64),
b_func – numba.cfunc callbacks with signature float64(float64, float64),
a_func – numba.cfunc callbacks with signature float64(float64, float64),
values. (one per channel. Each is folded left to right over that channel's)
Default attribute names and types#
Use these name strings with Node.set_attribute() so compilers, renderers,
and your own code agree on which field is which. Each *_TYPE value is the
Attribute.ReturnType that matches the corresponding name.
Name strings
- pyvcad.DefaultAttributes.NONE = 'none': str#
- pyvcad.DefaultAttributes.MODULUS = 'modulus': str#
- pyvcad.DefaultAttributes.TOUGHNESS = 'toughness': str#
- pyvcad.DefaultAttributes.ELONGATION = 'elongation': str#
- pyvcad.DefaultAttributes.SHORE_HARDNESS = 'shore_hardness': str#
- pyvcad.DefaultAttributes.TEMPERATURE = 'temperature': str#
- pyvcad.DefaultAttributes.HU = 'hu': str#
- pyvcad.DefaultAttributes.VOLUME_FRACTIONS = 'volume_fractions': str#
- pyvcad.DefaultAttributes.COLOR_RGBA = 'color_rgba': str#
- pyvcad.DefaultAttributes.COLOR_RGB = 'color_rgb': str#
- pyvcad.DefaultAttributes.INTENSITY = 'intensity': str#
- pyvcad.DefaultAttributes.DENSITY = 'density': str#
- pyvcad.DefaultAttributes.POISSONS_RATIO = 'poissons_ratio': str#
- pyvcad.DefaultAttributes.INFILL_DENSITY = 'infill_density': str#
- pyvcad.DefaultAttributes.FUZZY_SKIN_POINT_DISTANCE = 'fuzzy_skin_point_distance': str#
- pyvcad.DefaultAttributes.FUZZY_SKIN_THICKNESS = 'fuzzy_skin_thickness': str#
- pyvcad.DefaultAttributes.FLOW_RATE = 'flow_rate': str#
- pyvcad.DefaultAttributes.FAN_SPEED = 'fan_speed': str#
Part-cooling fan speed in percent of full fan (0 to 100).
Slicer setting names
Per-region PrusaSlicer settings. pyvcad_compilers.PrusaSlicerProjectCompiler
reads these scalar fields and writes them as per-volume settings in the project file.
- pyvcad.DefaultAttributes.BRIDGE_SPEED = 'bridge_speed': str#
- pyvcad.DefaultAttributes.EXTERNAL_PERIMETER_EXTRUSION_WIDTH = 'external_perimeter_extrusion_width': str#
- pyvcad.DefaultAttributes.EXTERNAL_PERIMETER_SPEED = 'external_perimeter_speed': str#
- pyvcad.DefaultAttributes.EXTRUSION_WIDTH = 'extrusion_width': str#
- pyvcad.DefaultAttributes.GAP_FILL_SPEED = 'gap_fill_speed': str#
- pyvcad.DefaultAttributes.INFILL_EXTRUSION_WIDTH = 'infill_extrusion_width': str#
- pyvcad.DefaultAttributes.INFILL_SPEED = 'infill_speed': str#
- pyvcad.DefaultAttributes.IRONING_FLOWRATE = 'ironing_flowrate': str#
- pyvcad.DefaultAttributes.IRONING_SPEED = 'ironing_speed': str#
- pyvcad.DefaultAttributes.LAYER_HEIGHT = 'layer_height': str#
- pyvcad.DefaultAttributes.PERIMETER_EXTRUSION_WIDTH = 'perimeter_extrusion_width': str#
- pyvcad.DefaultAttributes.PERIMETER_SPEED = 'perimeter_speed': str#
- pyvcad.DefaultAttributes.PERIMETERS = 'perimeters': str#
- pyvcad.DefaultAttributes.TOP_SOLID_LAYERS = 'top_solid_layers': str#
Slicer number of solid layers under a top surface (stored as a float, rounded when exported).
- pyvcad.DefaultAttributes.BOTTOM_SOLID_LAYERS = 'bottom_solid_layers': str#
Slicer number of solid layers over a bottom surface (stored as a float, rounded when exported).
- pyvcad.DefaultAttributes.TOP_SOLID_MIN_THICKNESS = 'top_solid_min_thickness': str#
Slicer least thickness of the solid layers under a top surface in mm.
- pyvcad.DefaultAttributes.BOTTOM_SOLID_MIN_THICKNESS = 'bottom_solid_min_thickness': str#
Slicer least thickness of the solid layers over a bottom surface in mm.
- pyvcad.DefaultAttributes.SMALL_PERIMETER_SPEED = 'small_perimeter_speed': str#
- pyvcad.DefaultAttributes.SOLID_INFILL_EXTRUSION_WIDTH = 'solid_infill_extrusion_width': str#
- pyvcad.DefaultAttributes.SOLID_INFILL_SPEED = 'solid_infill_speed': str#
- pyvcad.DefaultAttributes.SUPPORT_MATERIAL_EXTRUSION_WIDTH = 'support_material_extrusion_width': str#
- pyvcad.DefaultAttributes.TOP_INFILL_EXTRUSION_WIDTH = 'top_infill_extrusion_width': str#
- pyvcad.DefaultAttributes.TOP_SOLID_INFILL_SPEED = 'top_solid_infill_speed': str#
Return-type helpers
- pyvcad.DefaultAttributes.NONE_TYPE = Attribute.ReturnType.none: Attribute.ReturnType#
- pyvcad.DefaultAttributes.MODULUS_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.TOUGHNESS_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.TOUGHNSS_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
Deprecated misspelled alias of
TOUGHNESS_TYPE, kept so existing code still works.
- pyvcad.DefaultAttributes.ELONGATION_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.SHORE_HARDNESS_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.TEMPERATURE_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.HU_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.VOLUME_FRACTIONS_TYPE = Attribute.ReturnType.vfm_ptr: Attribute.ReturnType#
- pyvcad.DefaultAttributes.COLOR_RGBA_TYPE = Attribute.ReturnType.vec4: Attribute.ReturnType#
- pyvcad.DefaultAttributes.COLOR_RGB_TYPE = Attribute.ReturnType.vec3: Attribute.ReturnType#
- pyvcad.DefaultAttributes.INTENSITY_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.DENSITY_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.POISSONS_RATIO_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.INFILL_DENSITY_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.FUZZY_SKIN_POINT_DISTANCE_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.FUZZY_SKIN_THICKNESS_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.FLOW_RATE_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.FAN_SPEED_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.BRIDGE_SPEED_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.EXTERNAL_PERIMETER_EXTRUSION_WIDTH_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.EXTERNAL_PERIMETER_SPEED_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.EXTRUSION_WIDTH_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.GAP_FILL_SPEED_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.INFILL_EXTRUSION_WIDTH_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.INFILL_SPEED_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.IRONING_FLOWRATE_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.IRONING_SPEED_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.LAYER_HEIGHT_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.PERIMETER_EXTRUSION_WIDTH_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.PERIMETER_SPEED_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.PERIMETERS_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.TOP_SOLID_LAYERS_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.BOTTOM_SOLID_LAYERS_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.TOP_SOLID_MIN_THICKNESS_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.BOTTOM_SOLID_MIN_THICKNESS_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.SMALL_PERIMETER_SPEED_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.SOLID_INFILL_EXTRUSION_WIDTH_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.SOLID_INFILL_SPEED_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.SUPPORT_MATERIAL_EXTRUSION_WIDTH_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.TOP_INFILL_EXTRUSION_WIDTH_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
- pyvcad.DefaultAttributes.TOP_SOLID_INFILL_SPEED_TYPE = Attribute.ReturnType.dbl: Attribute.ReturnType#
Functions
- pyvcad.DefaultAttributes.get_return_type_by_name(name: str) pyvcad.pyvcad.Attribute.ReturnType#
Get the return type enum for a given attribute name.
- Parameters:
name (str) – Attribute name.
- Returns:
Corresponding return type enum, or
Attribute.ReturnType.noneif the name is not a default attribute.- Return type: