Polychannel

Polychannel

Bases: Shape

A polychannel is a collection of shapes that are hulled together.

It can contain PolychannelShape and BezierCurveShape objects.

The shapes are automatically validated and rounded corners are created for non-manhattan corners.

__init__

__init__(
    shapes: list[Union[PolychannelShape, BezierCurveShape]],
    show_only_shapes: bool = False,
    quiet: bool = False,
) -> None

Initialize a Polychannel object.

Parameters:

  • shapes (list[Union[PolychannelShape, BezierCurveShape]]): Shapes defining the polychannel.
  • show_only_shapes (bool): If True, only show the shapes without hulls.
  • quiet (bool): If True, suppresses informational output.

Raises:

  • ValueError: Polychannel requires at least 2 shapes or an unsupported shape type is used.

PolychannelShape

Represents a shape in a polychannel.

__init__

__init__(
    shape_type: str | None = None,
    position: tuple[int, int, int] | None = None,
    size: tuple[int, int, int] | None = None,
    rounded_cube_radius: (
        tuple[float, float, float] | None
    ) = None,
    rotation: tuple[float, float, float] | None = None,
    absolute_position: bool | None = None,
    corner_radius: float | None = None,
    corner_segments: int | None = None,
    fn: int | None = None,
    _no_validation: bool = False,
) -> None

Initialize a polychannel shape definition.

Parameters:

  • shape_type (str | None): Type of shape (e.g., "cube", "sphere", "rounded_cube").
  • position (tuple[int, int, int] | None): Position of the shape in 3D space (x, y, z).
  • size (tuple[int, int, int] | None): Size of the shape (width, height, depth).
  • rounded_cube_radius (tuple[float, float, float] | None): Radius for rounded cubes (rx, ry, rz).
  • rotation (tuple[float, float, float] | None): Rotation of the shape in degrees (rx, ry, rz).
  • absolute_position (bool | None): If True, the position is absolute; if False, it is relative to the last shape.
  • corner_radius (float | None): Radius for non-manhattan corners.
  • corner_segments (int | None): Number of segments for non-manhattan corners.
  • fn (int | None): Number of facets for rounded shapes.
  • _no_validation (bool): If True, skip validation (for internal use).

Default behaviors are as follows:

  • shape_type: Defaults to last shape's shape_type'.
  • size: Defaults to the last shape's size.
  • rounded_cube_radius: Defaults to the last shape's radius
    • cubes have a radius of 0
    • spheres have a radius of (size[0]/2, size[1]/2, size[2]/2)
  • position: Defaults to the last shape's position.
    • If absolute_position is False, it will be relative to the last shape's position.
  • rotation: Defaults to last shape's rotation ((0, 0, 0) if first shape).
  • corner_radius: Defaults the last shape's radius (0 if first shape).
  • corner_segments: Defaults to last shape's segments (10 if not specified).
  • fn: Default to manifold3D's default value (if not specified).

If the shape is the first in a polychannel, it must have a defined type, size, and position (and rounded_cube_radius if rounded_cube shape).

BezierCurveShape

Represents a Bezier curve shape in a polychannel.

__init__

__init__(
    control_points: list[tuple[int, int, int]],
    bezier_segments: int,
    shape_type: str | None = None,
    size: tuple[int, int, int] | None = None,
    position: tuple[int, int, int] | None = None,
    rounded_cube_radius: (
        tuple[float, float, float] | None
    ) = None,
    rotation: tuple[float, float, float] | None = None,
    absolute_position: bool | None = None,
    corner_radius: float | None = None,
    corner_segments: int | None = None,
    fn: int | None = None,
    _no_validation: bool = False,
) -> None

Initialize a Bezier curve shape definition.

Parameters:

  • control_points (list[tuple[int, int, int]]): List of control points defining the Bezier curve.
  • bezier_segments (int): Number of segments to divide the curve into.
  • shape_type (str | None): Type of shape (e.g., "cube", "sphere", "rounded_cube").
  • size (tuple[int, int, int] | None): Size of shape.
  • position (tuple[int, int, int] | None): Position of the shape in 3D space.
  • rounded_cube_radius (tuple[float, float, float] | None): Radius (if rounded cube).
  • rotation (tuple[float, float, float] | None): Rotation of the shape in degrees (x, y, z).
  • absolute_position (bool | None): If True, the position is absolute; if False, it is relative to the last shape.
  • corner_radius (float | None): Radius for non-manhattan corners.
  • corner_segments (int | None): Number of segments for non-manhattan corners.
  • fn (int | None): Number of facets for rounded shapes.
  • _no_validation (bool): If True, skip validation (for internal use).

Default behaviors are as follows:

  • shape_type: Defaults to last shape's shape_type'.
  • size: Defaults to the last shape's size.
  • rounded_cube_radius: Defaults to the last shape's radius
    • cubes have a radius of 0
    • spheres have a radius of (size[0]/2, size[1]/2, size[2]/2)
  • position: Defaults to the last shape's position.
    • If absolute_position is False, it will be relative to the last shape's position.
  • rotation: Defaults to last shape's rotation ((0, 0, 0) if first shape).
  • corner_radius: Defaults to last shape's radius (0 if first shape).
  • corner_segments: Defaults to last shape's segments (10 if not specified).
  • fn: Default to manifold3D's default value (if not specified).

Bezier curves cannot be the first shape in a polychannel!