Shape types

final class scadpy.d2.shape.types.Shape(*args, **kwargs)

Bases: Assembly[Polygon]

A 2D assembly of Polygon parts.

Shape is the central 2D modeling object in ScadPy. It wraps one or more colored Shapely polygons and exposes a fluent API for boolean operations, geometric transforms, topology queries, and 2D→3D extrusions.

Use the primitives (circle(), rectangle(), square(), …) or importers (Shape.from_dxf(), Shape.from_svg()) to create shapes; do not instantiate this class directly.

Attributes:
are_vertices_convex

For each vertex in the shape, return whether it is convex.

See are_shape_vertices_convex() for parameter documentation.

>>> from scadpy import polygon
>>> # arrow: 5 convex vertices (tip and sides)
>>> # + 2 concave vertices (the tail notch)
>>> arrow = polygon(
...     [(0, 1), (3, 0), (5, 2), (3, 4),
...      (0, 3), (1, 2.5), (1, 1.5)]
... )
>>> arrow.are_vertices_convex.tolist()
[True, True, True, True, True, False, False]
bounding_box

Return the axis-aligned bounding box of the shape as a rectangle.

See get_shape_bounding_box() for parameter documentation.

>>> from shapely.geometry import Polygon
>>> from scadpy import Shape
>>> polygon = Polygon([(0, 0), (2, 0), (2, 2), (0, 2)])
>>> Shape.from_geometry(polygon).bounding_box.bounds
array([0., 0., 2., 2.])
bounds

Return the axis-aligned bounding box of the shape.

See get_shape_bounds() for parameter documentation.

>>> from shapely.geometry import Polygon
>>> from scadpy import Shape
>>> polygon = Polygon([(0, 0), (2, 0), (2, 2), (0, 2)])
>>> Shape.from_geometry(polygon).bounds
array([0., 0., 2., 2.])
centroid

Return the geometric centroid of the shape, weighted by part area.

See get_shape_centroid() for parameter documentation.

>>> from shapely.geometry import Polygon
>>> from scadpy import Shape
>>> polygon = Polygon([(0, 0), (2, 0), (2, 2), (0, 2)])
>>> Shape.from_geometry(polygon).centroid
array([1., 1.])
directed_edge_directions

For each directed edge in the shape, return its unit direction vector.

See get_shape_directed_edge_directions() for parameter documentation.

>>> from scadpy import square
>>> # unit square: 4 edges → 8 directed edges,
>>> # forward then backward interleaved
>>> square(1).directed_edge_directions.round(4)
array([[ 1.,  0.],
       [-1.,  0.],
       [ 0.,  1.],
       [ 0., -1.],
       [-1.,  0.],
       [ 1.,  0.],
       [ 0., -1.],
       [ 0.,  1.]])
directed_edge_to_edge

For each directed edge in the shape, return the index of its parent undirected edge.

See get_shape_directed_edge_to_edge() for parameter documentation.

>>> from scadpy import polygon, square
>>> # triangle: 3 edges → 6 directed edges
>>> triangle = polygon([(0, 0), (1, 0), (0.5, 1)])
>>> triangle.directed_edge_to_edge
array([0, 0, 1, 1, 2, 2])
>>> # square: 4 edges → 8 directed edges
>>> square(1).directed_edge_to_edge
array([0, 0, 1, 1, 2, 2, 3, 3])
directed_edge_to_vertex

For each directed edge in the shape, return the indices of its start and end vertices.

See get_shape_directed_edge_to_vertex() for parameter documentation.

>>> from scadpy import polygon, square
>>> # triangle: 3 edges → 6 directed edges
>>> # (forward/backward interleaved)
>>> triangle = polygon([(0, 0), (1, 0), (0.5, 1)])
>>> triangle.directed_edge_to_vertex
array([[0, 1],
       [1, 0],
       [1, 2],
       [2, 1],
       [2, 0],
       [0, 2]])
>>> # square: 4 edges → 8 directed edges
>>> square(1).directed_edge_to_vertex.shape
(8, 2)
edge_lengths

For each edge in the shape, return its length.

See get_shape_edge_lengths() for parameter documentation.

>>> from scadpy import square
>>> square(2).edge_lengths
array([2., 2., 2., 2.])
edge_midpoints

For each edge in the shape, return the midpoint between its two vertices.

See get_shape_edge_midpoints() for parameter documentation.

>>> from scadpy import square
>>> square(2).edge_midpoints
array([[ 0., -1.],
       [ 1.,  0.],
       [ 0.,  1.],
       [-1.,  0.]])
edge_normals

For each edge in the shape, return its outward unit normal.

See get_shape_edge_normals() for parameter documentation.

>>> from scadpy import square
>>> # square(2) centered at origin: 4 edges,
>>> # each normal points outward
>>> square(2).edge_normals.round(4)
array([[ 0., -1.],
       [ 1., -0.],
       [ 0.,  1.],
       [-1., -0.]])
edge_to_vertex

For each edge in the shape, return the indices of its start and end vertices.

See get_shape_edge_to_vertex() for parameter documentation.

>>> from scadpy import polygon, square
>>> # triangle: 3 vertices, 3 edges
>>> triangle = polygon([(0, 0), (1, 0), (0.5, 1)])
>>> triangle.edge_to_vertex
array([[0, 1],
       [1, 2],
       [2, 0]])
>>> # square: 4 vertices, 4 edges
>>> square(1).edge_to_vertex.shape
(4, 2)
is_empty

Return whether the shape has no vertices.

See is_shape_empty() for parameter documentation.

>>> from shapely.geometry import Polygon
>>> from scadpy import Shape
>>> Shape.from_parts([]).is_empty
True
>>> polygon = Polygon([(0, 0), (2, 0), (2, 2), (0, 2)])
>>> Shape.from_geometry(polygon).is_empty
False
part_colors

Shortcut for get_assembly_part_colors().

See get_assembly_part_colors() for full documentation.

ring_to_part

For each ring in the shape, return its part index.

See get_shape_ring_to_part() for parameter documentation.

>>> from scadpy import square
>>> # square with a hole (2 rings in part 0)
>>> # unioned with a separate square (1 ring in part 1)
>>> shape = (square(2) - square(1)) | square(1).translate([5, 0])
>>> shape.ring_to_part
array([0, 0, 1])
ring_types

For each ring in the shape, return its type (‘exterior’ or ‘interior’).

See get_shape_ring_types() for parameter documentation.

>>> from scadpy import square
>>> # square with a hole (exterior + interior)
>>> # unioned with a separate square (exterior only)
>>> shape = (square(2) - square(1)) | square(1).translate([5, 0])
>>> shape.ring_types
array(['exterior', 'interior', 'exterior'], dtype=object)
vertex_angles

For each vertex in the shape, return its interior angle in degrees.

See get_shape_vertex_angles() for parameter documentation.

>>> from scadpy import polygon
>>> # arrow: 5 convex vertices + 2 concave vertices,
>>> # all with different angles
>>> arrow = polygon(
...     [(0, 1), (3, 0), (5, 2), (3, 4),
...      (0, 3), (1, 2.5), (1, 1.5)]
... )
>>> arrow.vertex_angles.round(2).tolist()
[135.0, 63.43, 90.0, 63.43, 135.0, 63.43, 63.43]
vertex_coordinates

For each vertex in the shape, return its coordinates.

See get_shape_vertex_coordinates() for parameter documentation.

>>> from shapely.geometry import Polygon
>>> from scadpy import Shape
>>> polygon = Polygon([(0, 0), (2, 0), (2, 2), (0, 2)])
>>> Shape.from_geometry(polygon).vertex_coordinates
array([[0., 0.],
       [2., 0.],
       [2., 2.],
       [0., 2.]])
vertex_normals

For each vertex in the shape, return its outward unit normal.

See get_shape_vertex_normals() for parameter documentation.

>>> from scadpy import polygon
>>> # arrow: 5 convex vertices (normals point outward)
>>> # + 2 concave vertices (normals point inward,
>>> # into the tail notch — x component is positive)
>>> arrow = polygon(
...     [(0, 1), (3, 0), (5, 2), (3, 4),
...      (0, 3), (1, 2.5), (1, 1.5)]
... )
>>> arrow.vertex_normals.round(4)
array([[-0.9975, -0.0709],
       [ 0.2298, -0.9732],
       [ 1.    ,  0.    ],
       [ 0.2298,  0.9732],
       [-0.9975,  0.0709],
       [ 0.8507,  0.5257],
       [ 0.8507, -0.5257]])
vertex_to_incoming_directed_edge

For each vertex in the shape, return the index of its incoming directed edge.

See get_shape_vertex_to_incoming_directed_edge() for parameter documentation.

>>> from scadpy import polygon
>>> # triangle: vertices (2,0,1), (0,1,2), (1,2,0)
>>> # incoming: 2→0, 0→1, 1→2
>>> triangle = polygon([(0, 0), (1, 0), (0.5, 1)])
>>> triangle.vertex_to_incoming_directed_edge
array([4, 0, 2])
vertex_to_neighbor_vertex

For each vertex in the shape, return its two neighbor vertex indices (prev, next).

See get_shape_vertex_to_neighbor_vertex() for parameter documentation.

>>> from scadpy import polygon
>>> triangle = polygon([(0, 0), (1, 0), (0.5, 1)])
>>> triangle.vertex_to_neighbor_vertex
array([[2, 1],
       [0, 2],
       [1, 0]])
vertex_to_outgoing_directed_edge

For each vertex in the shape, return the index of its outgoing directed edge.

See get_shape_vertex_to_outgoing_directed_edge() for parameter documentation.

>>> from scadpy import polygon
>>> # triangle: vertices (2,0,1), (0,1,2), (1,2,0)
>>> # outgoing: 0→1, 1→2, 2→0
>>> triangle = polygon([(0, 0), (1, 0), (0.5, 1)])
>>> triangle.vertex_to_outgoing_directed_edge
array([0, 2, 4])
vertex_to_part

For each vertex in the shape, return its part index.

See get_shape_vertex_to_part() for parameter documentation.

>>> from shapely.geometry import Polygon
>>> from scadpy import Shape
>>> p1 = Polygon([(0, 0), (2, 0), (2, 2), (0, 2)])
>>> p2 = Polygon([(10, 10), (12, 10), (12, 12), (10, 12)])
>>> Shape.from_geometries([p1, p2]).vertex_to_part
array([0, 0, 0, 0, 1, 1, 1, 1])
vertex_to_ring

For each vertex in the shape, return the index of the ring it belongs to.

See get_shape_vertex_to_ring() for parameter documentation.

>>> from scadpy import polygon, square
>>> # two separate triangles: 3 vertices in ring 0, 3 in ring 1
>>> shape = (
...     polygon([(0, 0), (1, 0), (0.5, 1)])
...     | polygon([(5, 0), (6, 0), (5.5, 1)])
... )
>>> shape.vertex_to_ring
array([0, 0, 0, 1, 1, 1])
>>> # square with a hole: 4 exterior vertices in ring 0,
>>> # 4 interior vertices in ring 1
>>> (square(4) - square(2)).vertex_to_ring
array([0, 0, 0, 0, 1, 1, 1, 1])

Methods

chamfer(size[, vertex_filter, epsilon])

Chamfer the vertices of this shape.

color(color)

Set the color of all parts in this shape.

concat(shapes)

Concatenate this shape with others (no boolean merge).

convexify()

Compute the convex hull of each part of this shape.

dimensions()

Return the number of spatial dimensions: always 2.

exclude(shapes)

Compute the symmetric difference of this shape with others.

fill()

Fill holes in this shape.

fillet(size[, vertex_filter, segment_count, ...])

Fillet the vertices of this shape.

from_dxf(source)

Load a 2D shape from a DXF file or URL.

from_geometries(geometries)

Map a sequence of polygons to a shape.

from_geometry(geometry)

Map a single polygon to a shape.

from_parts(parts)

Map a sequence of parts to a shape, repairing and orienting each polygon.

from_svg(source)

Load a 2D shape from an SVG file or URL.

grow(distance)

Grow this shape outward by a given distance.

intersect(shapes)

Intersect this shape with others.

linear_cut(axis[, pivot])

Cut this shape with a half-plane.

linear_extrude(height[, ...])

Extrude this shape linearly along the Z-axis.

linear_pattern(counts, steps)

Repeat this shape in a linear or grid pattern.

linear_slice(thickness, direction[, pivot])

Slice this shape with a linear band.

mirror(normal[, pivot])

Mirror this shape.

path_extrude(path[, fillet_segments, ...])

Sweep this shape along a 3D path.

pull(distance[, pivot, vertex_filter])

Move vertices of this shape toward a pivot point.

push(distance[, pivot, vertex_filter])

Move vertices of this shape away from a pivot point.

radial_extrude(axis[, start, end, pivot, ...])

Extrude this shape radially around an axis.

radial_pattern(count[, angle, pivot])

Repeat this shape in a radial pattern around the origin.

radial_slice([start, end, pivot])

Slice this shape to keep only a radial sector.

recoordinate(vertex_coordinates)

Rebuild this shape with new vertex coordinates.

resize(size[, auto, pivot, vertex_filter])

Resize this shape to target dimensions.

rotate(angle[, pivot, vertex_filter])

Rotate this shape.

scale(scale[, pivot, vertex_filter])

Scale this shape.

shrink(distance)

Shrink this shape inward by a given distance.

subtract(other)

Subtract a shape from this shape.

to_dxf()

Export a shape to a DXF string.

to_dxf_file(path)

Save a shape as a DXF file.

to_html([background_color, foreground_color])

Render a shape as an SVG HTML object.

to_html_file(path[, background_color, ...])

Save a shape as an HTML file.

to_screen([background_color, foreground_color])

Display a shape in a Qt-based window.

to_svg()

Export a shape to an SVG string.

to_svg_file(path)

Save a shape as an SVG file.

translate(translation[, vertex_filter])

Translate this shape.

unify(shapes)

Unite this shape with others.

Examples

>>> from scadpy import circle, square
>>> s = square(4) - circle(1)
>>> s.is_empty
False
classmethod dimensions()

Return the number of spatial dimensions: always 2.

Returns:
int

Always 2.

Examples

>>> from scadpy import Shape
>>> Shape.dimensions()
2
property vertex_coordinates

For each vertex in the shape, return its coordinates.

See get_shape_vertex_coordinates() for parameter documentation.

Examples

>>> from shapely.geometry import Polygon
>>> from scadpy import Shape
>>> polygon = Polygon([(0, 0), (2, 0), (2, 2), (0, 2)])
>>> Shape.from_geometry(polygon).vertex_coordinates
array([[0., 0.],
       [2., 0.],
       [2., 2.],
       [0., 2.]])
property vertex_to_part

For each vertex in the shape, return its part index.

See get_shape_vertex_to_part() for parameter documentation.

Examples

>>> from shapely.geometry import Polygon
>>> from scadpy import Shape
>>> p1 = Polygon([(0, 0), (2, 0), (2, 2), (0, 2)])
>>> p2 = Polygon([(10, 10), (12, 10), (12, 12), (10, 12)])
>>> Shape.from_geometries([p1, p2]).vertex_to_part
array([0, 0, 0, 0, 1, 1, 1, 1])
recoordinate(vertex_coordinates)

Rebuild this shape with new vertex coordinates.

Shortcut for recoordinate_shape(). See recoordinate_shape() for full documentation.

property is_empty

Return whether the shape has no vertices.

See is_shape_empty() for parameter documentation.

Examples

>>> from shapely.geometry import Polygon
>>> from scadpy import Shape
>>> Shape.from_parts([]).is_empty
True
>>> polygon = Polygon([(0, 0), (2, 0), (2, 2), (0, 2)])
>>> Shape.from_geometry(polygon).is_empty
False
property bounds

Return the axis-aligned bounding box of the shape.

See get_shape_bounds() for parameter documentation.

Examples

>>> from shapely.geometry import Polygon
>>> from scadpy import Shape
>>> polygon = Polygon([(0, 0), (2, 0), (2, 2), (0, 2)])
>>> Shape.from_geometry(polygon).bounds
array([0., 0., 2., 2.])
property bounding_box

Return the axis-aligned bounding box of the shape as a rectangle.

See get_shape_bounding_box() for parameter documentation.

Examples

>>> from shapely.geometry import Polygon
>>> from scadpy import Shape
>>> polygon = Polygon([(0, 0), (2, 0), (2, 2), (0, 2)])
>>> Shape.from_geometry(polygon).bounding_box.bounds
array([0., 0., 2., 2.])
property centroid

Return the geometric centroid of the shape, weighted by part area.

See get_shape_centroid() for parameter documentation.

Examples

>>> from shapely.geometry import Polygon
>>> from scadpy import Shape
>>> polygon = Polygon([(0, 0), (2, 0), (2, 2), (0, 2)])
>>> Shape.from_geometry(polygon).centroid
array([1., 1.])
__or__(other)

Unite two shapes. Shortcut for unify_shape().

__and__(other)

Intersect two shapes. Shortcut for intersect_shape().

__sub__(other)

Subtract a shape from this shape. Shortcut for subtract_shape().

concat(shapes)

Concatenate this shape with others (no boolean merge).

See concat_shape() for parameter documentation.

Examples

>>> from scadpy import square, circle
>>> square(4).concat([circle(2).translate([3, 2])])
2026-04-06T19:27:22.541271 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:22.700261 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
unify(shapes)

Unite this shape with others.

See unify_shape() for parameter documentation.

Examples

>>> from scadpy import square, circle
>>> square(4).unify([circle(2).translate([2, 0])])
2026-04-06T19:27:22.849058 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:22.986772 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
intersect(shapes)

Intersect this shape with others.

See intersect_shape() for parameter documentation.

Examples

>>> from scadpy import square, circle
>>> square(4).intersect([circle(2).translate([1, 1])])
2026-04-06T19:27:23.119555 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:23.239435 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
subtract(other)

Subtract a shape from this shape.

See subtract_shape() for parameter documentation.

Examples

>>> from scadpy import square, circle
>>> square(4).subtract(circle(1))
2026-04-06T19:27:23.359542 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:23.477684 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
exclude(shapes)

Compute the symmetric difference of this shape with others.

See exclude_shape() for parameter documentation.

Examples

>>> from scadpy import square, circle
>>> square(4).exclude([circle(2).translate([1, 1])])
2026-04-06T19:27:23.610209 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:23.743025 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
property part_colors

Shortcut for get_assembly_part_colors().

See get_assembly_part_colors() for full documentation.

property ring_to_part

For each ring in the shape, return its part index.

See get_shape_ring_to_part() for parameter documentation.

Examples

>>> from scadpy import square
>>> # square with a hole (2 rings in part 0)
>>> # unioned with a separate square (1 ring in part 1)
>>> shape = (square(2) - square(1)) | square(1).translate([5, 0])
>>> shape.ring_to_part
array([0, 0, 1])
property ring_types

For each ring in the shape, return its type (‘exterior’ or ‘interior’).

See get_shape_ring_types() for parameter documentation.

Examples

>>> from scadpy import square
>>> # square with a hole (exterior + interior)
>>> # unioned with a separate square (exterior only)
>>> shape = (square(2) - square(1)) | square(1).translate([5, 0])
>>> shape.ring_types
array(['exterior', 'interior', 'exterior'], dtype=object)
property vertex_to_ring

For each vertex in the shape, return the index of the ring it belongs to.

See get_shape_vertex_to_ring() for parameter documentation.

Examples

>>> from scadpy import polygon, square
>>> # two separate triangles: 3 vertices in ring 0, 3 in ring 1
>>> shape = (
...     polygon([(0, 0), (1, 0), (0.5, 1)])
...     | polygon([(5, 0), (6, 0), (5.5, 1)])
... )
>>> shape.vertex_to_ring
array([0, 0, 0, 1, 1, 1])
>>> # square with a hole: 4 exterior vertices in ring 0,
>>> # 4 interior vertices in ring 1
>>> (square(4) - square(2)).vertex_to_ring
array([0, 0, 0, 0, 1, 1, 1, 1])
property vertex_to_neighbor_vertex

For each vertex in the shape, return its two neighbor vertex indices (prev, next).

See get_shape_vertex_to_neighbor_vertex() for parameter documentation.

Examples

>>> from scadpy import polygon
>>> triangle = polygon([(0, 0), (1, 0), (0.5, 1)])
>>> triangle.vertex_to_neighbor_vertex
array([[2, 1],
       [0, 2],
       [1, 0]])
property vertex_angles

For each vertex in the shape, return its interior angle in degrees.

See get_shape_vertex_angles() for parameter documentation.

Examples

>>> from scadpy import polygon
>>> # arrow: 5 convex vertices + 2 concave vertices,
>>> # all with different angles
>>> arrow = polygon(
...     [(0, 1), (3, 0), (5, 2), (3, 4),
...      (0, 3), (1, 2.5), (1, 1.5)]
... )
>>> arrow.vertex_angles.round(2).tolist()
[135.0, 63.43, 90.0, 63.43, 135.0, 63.43, 63.43]
property are_vertices_convex

For each vertex in the shape, return whether it is convex.

See are_shape_vertices_convex() for parameter documentation.

Examples

>>> from scadpy import polygon
>>> # arrow: 5 convex vertices (tip and sides)
>>> # + 2 concave vertices (the tail notch)
>>> arrow = polygon(
...     [(0, 1), (3, 0), (5, 2), (3, 4),
...      (0, 3), (1, 2.5), (1, 1.5)]
... )
>>> arrow.are_vertices_convex.tolist()
[True, True, True, True, True, False, False]
property vertex_normals

For each vertex in the shape, return its outward unit normal.

See get_shape_vertex_normals() for parameter documentation.

Examples

>>> from scadpy import polygon
>>> # arrow: 5 convex vertices (normals point outward)
>>> # + 2 concave vertices (normals point inward,
>>> # into the tail notch — x component is positive)
>>> arrow = polygon(
...     [(0, 1), (3, 0), (5, 2), (3, 4),
...      (0, 3), (1, 2.5), (1, 1.5)]
... )
>>> arrow.vertex_normals.round(4)
array([[-0.9975, -0.0709],
       [ 0.2298, -0.9732],
       [ 1.    ,  0.    ],
       [ 0.2298,  0.9732],
       [-0.9975,  0.0709],
       [ 0.8507,  0.5257],
       [ 0.8507, -0.5257]])
property vertex_to_outgoing_directed_edge

For each vertex in the shape, return the index of its outgoing directed edge.

See get_shape_vertex_to_outgoing_directed_edge() for parameter documentation.

Examples

>>> from scadpy import polygon
>>> # triangle: vertices (2,0,1), (0,1,2), (1,2,0)
>>> # outgoing: 0→1, 1→2, 2→0
>>> triangle = polygon([(0, 0), (1, 0), (0.5, 1)])
>>> triangle.vertex_to_outgoing_directed_edge
array([0, 2, 4])
property vertex_to_incoming_directed_edge

For each vertex in the shape, return the index of its incoming directed edge.

See get_shape_vertex_to_incoming_directed_edge() for parameter documentation.

Examples

>>> from scadpy import polygon
>>> # triangle: vertices (2,0,1), (0,1,2), (1,2,0)
>>> # incoming: 2→0, 0→1, 1→2
>>> triangle = polygon([(0, 0), (1, 0), (0.5, 1)])
>>> triangle.vertex_to_incoming_directed_edge
array([4, 0, 2])
property directed_edge_to_vertex

For each directed edge in the shape, return the indices of its start and end vertices.

See get_shape_directed_edge_to_vertex() for parameter documentation.

Examples

>>> from scadpy import polygon, square
>>> # triangle: 3 edges → 6 directed edges
>>> # (forward/backward interleaved)
>>> triangle = polygon([(0, 0), (1, 0), (0.5, 1)])
>>> triangle.directed_edge_to_vertex
array([[0, 1],
       [1, 0],
       [1, 2],
       [2, 1],
       [2, 0],
       [0, 2]])
>>> # square: 4 edges → 8 directed edges
>>> square(1).directed_edge_to_vertex.shape
(8, 2)
property directed_edge_to_edge

For each directed edge in the shape, return the index of its parent undirected edge.

See get_shape_directed_edge_to_edge() for parameter documentation.

Examples

>>> from scadpy import polygon, square
>>> # triangle: 3 edges → 6 directed edges
>>> triangle = polygon([(0, 0), (1, 0), (0.5, 1)])
>>> triangle.directed_edge_to_edge
array([0, 0, 1, 1, 2, 2])
>>> # square: 4 edges → 8 directed edges
>>> square(1).directed_edge_to_edge
array([0, 0, 1, 1, 2, 2, 3, 3])
property directed_edge_directions

For each directed edge in the shape, return its unit direction vector.

See get_shape_directed_edge_directions() for parameter documentation.

Examples

>>> from scadpy import square
>>> # unit square: 4 edges → 8 directed edges,
>>> # forward then backward interleaved
>>> square(1).directed_edge_directions.round(4)
array([[ 1.,  0.],
       [-1.,  0.],
       [ 0.,  1.],
       [ 0., -1.],
       [-1.,  0.],
       [ 1.,  0.],
       [ 0., -1.],
       [ 0.,  1.]])
property edge_to_vertex

For each edge in the shape, return the indices of its start and end vertices.

See get_shape_edge_to_vertex() for parameter documentation.

Examples

>>> from scadpy import polygon, square
>>> # triangle: 3 vertices, 3 edges
>>> triangle = polygon([(0, 0), (1, 0), (0.5, 1)])
>>> triangle.edge_to_vertex
array([[0, 1],
       [1, 2],
       [2, 0]])
>>> # square: 4 vertices, 4 edges
>>> square(1).edge_to_vertex.shape
(4, 2)
property edge_lengths

For each edge in the shape, return its length.

See get_shape_edge_lengths() for parameter documentation.

Examples

>>> from scadpy import square
>>> square(2).edge_lengths
array([2., 2., 2., 2.])
property edge_midpoints

For each edge in the shape, return the midpoint between its two vertices.

See get_shape_edge_midpoints() for parameter documentation.

Examples

>>> from scadpy import square
>>> square(2).edge_midpoints
array([[ 0., -1.],
       [ 1.,  0.],
       [ 0.,  1.],
       [-1.,  0.]])
property edge_normals

For each edge in the shape, return its outward unit normal.

See get_shape_edge_normals() for parameter documentation.

Examples

>>> from scadpy import square
>>> # square(2) centered at origin: 4 edges,
>>> # each normal points outward
>>> square(2).edge_normals.round(4)
array([[ 0., -1.],
       [ 1., -0.],
       [ 0.,  1.],
       [-1., -0.]])
classmethod from_parts(parts)

Map a sequence of parts to a shape, repairing and orienting each polygon.

See map_parts_to_shape() for parameter documentation.

Examples

>>> from shapely.geometry import Polygon
>>> from scadpy import Shape, map_parts_to_shape
>>> from scadpy.core.part import Part
>>> Shape.from_parts(
...     [Part.from_geometry(Polygon([(0, 0), (4, 0), (4, 4), (0, 4)]))]
... )
2026-04-06T19:27:23.921382 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:24.031023 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
classmethod from_geometries(geometries)

Map a sequence of polygons to a shape.

See map_geometries_to_shape() for parameter documentation.

Examples

>>> from shapely.geometry import Polygon
>>> from scadpy import Shape, map_geometries_to_shape
>>> Shape.from_geometries(
...     [Polygon([(0, 0), (4, 0), (4, 4), (0, 4)])]
... )
2026-04-06T19:27:24.146239 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:24.257041 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
classmethod from_geometry(geometry)

Map a single polygon to a shape.

See map_geometry_to_shape() for parameter documentation.

Examples

>>> from shapely.geometry import Polygon
>>> from scadpy import Shape, map_geometry_to_shape
>>> Shape.from_geometry(
...     Polygon([(0, 0), (4, 0), (4, 4), (0, 4)])
... )
2026-04-06T19:27:24.371243 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:24.482343 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
classmethod from_svg(source)

Load a 2D shape from an SVG file or URL.

See map_svg_to_shape() for parameter documentation.

Examples

>>> from scadpy import Shape, map_svg_to_shape
>>> Shape.from_svg("https://upload.wikimedia.org/wikipedia/commons/0/04/Pentagon.svg")
2026-04-06T19:27:24.719363 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:24.917669 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
classmethod from_dxf(source)

Load a 2D shape from a DXF file or URL.

See map_dxf_to_shape() for parameter documentation.

Examples

>>> from scadpy import Shape, map_dxf_to_shape
>>> Shape.from_dxf("https://raw.githubusercontent.com/mikedh/trimesh/main/models/2D/wrench.dxf")
2026-04-06T19:27:25.148764 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:25.337803 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
translate(translation, vertex_filter=None)

Translate this shape.

See translate_shape() for parameter documentation.

Examples

>>> from scadpy import square
>>> square(4).translate([3, 2])
2026-04-06T19:27:25.496465 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:25.650834 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
scale(scale, pivot=0, vertex_filter=None)

Scale this shape.

See scale_shape() for parameter documentation.

Examples

>>> from scadpy import square
>>> square(4).scale(2, pivot=[2, 2])
2026-04-06T19:27:25.789134 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:25.903084 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
resize(size, auto=False, pivot=None, vertex_filter=None)

Resize this shape to target dimensions.

See resize_shape() for parameter documentation.

Examples

>>> from scadpy import rectangle
>>> # resize to an exact size on both axes
>>> rectangle([4, 2]).resize([6, 6])
2026-04-06T19:27:26.032672 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:26.169652 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
>>> # freeze one axis (None) to leave it unchanged
>>> rectangle([4, 2]).resize([6, None])
2026-04-06T19:27:26.309573 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:26.447576 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
>>> # scale frozen axes proportionally with auto=True
>>> rectangle([4, 2]).resize([6, None], auto=True)
2026-04-06T19:27:26.588959 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:26.728192 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
mirror(normal, pivot=0)

Mirror this shape.

See mirror_shape() for parameter documentation.

Examples

>>> from scadpy import square
>>> square(4).mirror([1, 0], pivot=[2, 0])
2026-04-06T19:27:26.857431 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:26.971343 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
pull(distance, pivot=0, vertex_filter=None)

Move vertices of this shape toward a pivot point.

See pull_shape() for parameter documentation.

Examples

>>> from scadpy import square
>>> square(4).pull(1.0, pivot=[2, 2], vertex_filter=square(4).vertex_coordinates[:, 0] < 1)
2026-04-06T19:27:27.091757 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:27.206734 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
push(distance, pivot=0, vertex_filter=None)

Move vertices of this shape away from a pivot point.

See push_shape() for parameter documentation.

Examples

>>> from scadpy import square
>>> square(4).push(1.0, pivot=[2, 2], vertex_filter=square(4).vertex_coordinates[:, 0] < 1)
2026-04-06T19:27:27.331317 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:27.457800 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
color(color)

Set the color of all parts in this shape.

See color_shape() for parameter documentation.

Examples

>>> from scadpy import square
>>> from scadpy.color.constants import RED
>>> square(4).color(RED)
2026-04-06T19:27:27.579943 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:27.690845 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
chamfer(size, vertex_filter=None, epsilon=1e-08)

Chamfer the vertices of this shape.

See chamfer_shape() for parameter documentation.

Examples

>>> from scadpy import square, polygon
>>> import numpy as np
>>> sq = square(4)
>>> l_shape = polygon(
...     [(0, 0), (4, 0), (4, 2), (2, 2), (2, 4), (0, 4)]
... )
>>> arrow = polygon(
...     [(0, 1), (3, 0), (5, 2), (3, 4),
...      (0, 3), (1, 2.5), (1, 1.5)]
... )
>>> # all vertices
>>> sq.chamfer(1.0)
2026-04-06T19:27:27.813645 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:27.941035 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
>>> # convex vertices only
>>> l_shape.chamfer(
...     0.5, vertex_filter=lambda s: s.are_vertices_convex
... )
2026-04-06T19:27:28.060812 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:28.175956 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
>>> # asymmetric: one side fills the full edge (length 2),
>>> # the other stays at 1.0
>>> l_shape.chamfer(
...     np.array([[2.0, 1.0]]),
...     vertex_filter=lambda s: ~s.are_vertices_convex,
... )
2026-04-06T19:27:28.292511 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:28.409237 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
>>> # only sharp convex vertices (angle > 100°)
>>> arrow.chamfer(
...     0.4,
...     vertex_filter=lambda s: (
...         s.are_vertices_convex & (s.vertex_angles > 100)
...     ),
... )
2026-04-06T19:27:28.533766 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:28.664479 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
>>> # oversized: clamped proportionally
>>> arrow.chamfer(
...     10, vertex_filter=lambda s: ~s.are_vertices_convex
... )
2026-04-06T19:27:28.797816 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:28.931922 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
fillet(size, vertex_filter=None, segment_count=32, epsilon=1e-08)

Fillet the vertices of this shape.

See fillet_shape() for parameter documentation.

Examples

>>> from scadpy import square, polygon
>>> import numpy as np
>>> sq = square(4)
>>> l_shape = polygon(
...     [(0, 0), (4, 0), (4, 2), (2, 2), (2, 4), (0, 4)]
... )
>>> arrow = polygon(
...     [(0, 1), (3, 0), (5, 2), (3, 4),
...      (0, 3), (1, 2.5), (1, 1.5)]
... )
>>> # all vertices
>>> sq.fillet(1.0)
2026-04-06T19:27:29.065603 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:29.184829 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
>>> # convex vertices only
>>> l_shape.fillet(
...     0.5, vertex_filter=lambda s: s.are_vertices_convex
... )
2026-04-06T19:27:29.307905 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:29.427871 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
>>> # asymmetric
>>> l_shape.fillet(
...     np.array([[2.0, 1.0]]),
...     vertex_filter=lambda s: ~s.are_vertices_convex,
... )
2026-04-06T19:27:29.545401 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:29.661353 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
>>> # only sharp convex vertices (angle > 100°)
>>> arrow.fillet(
...     0.4,
...     vertex_filter=lambda s: (
...         s.are_vertices_convex & (s.vertex_angles > 100)
...     ),
... )
2026-04-06T19:27:29.785351 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:29.917014 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
>>> # oversized: clamped proportionally
>>> arrow.fillet(
...     10, vertex_filter=lambda s: ~s.are_vertices_convex
... )
2026-04-06T19:27:30.052511 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:30.187743 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
convexify()

Compute the convex hull of each part of this shape.

See convexify_shape() for parameter documentation.

Examples

>>> from scadpy import square
>>> import numpy as np
>>> a = square(5)
>>> b = square(2).translate(10)
>>> c = square(3).translate([4, 8])
>>> (a + b + c).convexify()
2026-04-06T19:27:30.338141 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:30.727310 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
fill()

Fill holes in this shape.

See fill_shape() for parameter documentation.

Examples

>>> from scadpy import square, circle
>>> (square(10) - circle(3)).fill()
2026-04-06T19:27:30.872722 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:31.009088 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
grow(distance)

Grow this shape outward by a given distance.

See grow_shape() for parameter documentation.

Examples

>>> from scadpy import square
>>> square(10).grow(2)
2026-04-06T19:27:31.159737 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:31.319427 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
>>> # shrink with negative distance
>>> square(10).grow(-2)
2026-04-06T19:27:31.463782 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:31.594977 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
linear_cut(axis, pivot=0)

Cut this shape with a half-plane.

See linear_cut_shape() for parameter documentation.

Examples

>>> from scadpy import square, circle
>>> shape = square(6) - circle(2)
>>> # vertical cut along the Y-axis
>>> shape.linear_cut([0, 1], pivot=[-1, 0])
2026-04-06T19:27:31.748306 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:31.897598 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
>>> # diagonal cut
>>> shape.linear_cut([1, 1])
2026-04-06T19:27:32.048052 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:32.196769 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
linear_extrude(height, intermediate_sections=None, strategy=None)

Extrude this shape linearly along the Z-axis.

See linear_extrude_shape() for parameter documentation.

Examples

>>> from scadpy import square, circle
>>> # simple box
>>> square(10).linear_extrude(5)
>>> # tube from a hollow circle
>>> (circle(5) - circle(3)).linear_extrude(10)
>>> # tapered box using scale_sweep strategy
>>> from scadpy import scale_sweep
>>> square(10).linear_extrude(5, intermediate_sections=10, strategy=scale_sweep(0.5))
linear_slice(thickness, direction, pivot=0)

Slice this shape with a linear band.

See linear_slice_shape() for parameter documentation.

Examples

>>> from scadpy import square, circle
>>> shape = square(10) - circle(3)
>>> # horizontal slice through center
>>> shape.linear_slice(3, [1, 0])
2026-04-06T19:27:32.378609 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:32.520938 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
>>> # diagonal slice
>>> shape.linear_slice(2, [1, 1])
2026-04-06T19:27:32.667103 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:32.810450 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
>>> # off-center slice with pivot
>>> shape.linear_slice(2, [0, 1], pivot=[3, 0])
2026-04-06T19:27:32.959418 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:33.101454 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
radial_extrude(axis, start=0, end=360, pivot=0, segment_count=64)

Extrude this shape radially around an axis.

See radial_extrude_shape() for parameter documentation.

Examples

>>> from scadpy import circle
>>> # torus: circle profile offset from the Y-axis, revolved 360°
>>> circle(0.5).translate([2, 0]).radial_extrude([0, 1])
>>> # partial torus (270°)
>>> circle(0.5).translate([2, 0]).radial_extrude([0, 1], end=270)
path_extrude(path, fillet_segments=None, min_fillet_radius=None, intermediate_sections=None, strategy=None)

Sweep this shape along a 3D path.

See path_extrude_shape() for parameter documentation.

Examples

>>> import numpy as np
>>> from scadpy import circle, reverse_sweep, rotate_sweep, scale_sweep
>>> path = np.array([
...     [0, 0, 0], [10, 0, 0], [10, 4, 0], [10, 4, 8],
...     [6, 4, 8], [6, 9, 8], [6, 9, 3], [0, 9, 3],
...     [0, 0, 3], [0, 0, 10],
... ], dtype=float)
>>> # hollow tube swept along a 3D polyline with light filleting
>>> (circle(0.5, segment_count=6) - circle(0.4, segment_count=6)).path_extrude(
...     path, fillet_segments=2,
... )
>>> # same path with scale, twist and intermediate sections
>>> (circle(0.5, segment_count=6) - circle(0.4, segment_count=6)).path_extrude(
...     path,
...     fillet_segments=32,
...     min_fillet_radius=100,
...     intermediate_sections=50,
...     strategy=[reverse_sweep(scale_sweep(3)), rotate_sweep(360)],
... )
radial_slice(start=0, end=360, pivot=0)

Slice this shape to keep only a radial sector.

See radial_slice_shape() for parameter documentation.

Examples

>>> from scadpy import square, circle
>>> shape = square(10) - circle(3)
>>> # quarter slice
>>> shape.radial_slice(0, 90)
2026-04-06T19:27:33.591227 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:33.732017 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
>>> # three-quarter slice
>>> shape.radial_slice(45, 315)
2026-04-06T19:27:33.874926 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:34.018810 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
>>> # off-center pivot
>>> shape.radial_slice(0, 180, pivot=[3, 3])
2026-04-06T19:27:34.160541 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:34.300816 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
rotate(angle, pivot=0, vertex_filter=None)

Rotate this shape.

See rotate_shape() for parameter documentation.

Examples

>>> from scadpy import square
>>> square(4).rotate(45, pivot=[2, 2])
2026-04-06T19:27:34.447013 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:34.598818 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
shrink(distance)

Shrink this shape inward by a given distance.

See shrink_shape() for parameter documentation.

Examples

>>> from scadpy import square
>>> square(10).shrink(2)
2026-04-06T19:27:34.739204 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:34.869960 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
>>> # negative distance expands outward
>>> square(10).shrink(-2)
2026-04-06T19:27:35.020055 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:35.178476 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
linear_pattern(counts, steps)

Repeat this shape in a linear or grid pattern.

See linear_pattern_shape() for parameter documentation.

Examples

>>> from scadpy import circle, x, y
>>> circle(1).linear_pattern(counts=4, steps=x(3))
2026-04-06T19:27:35.341729 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:35.492655 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
>>> circle(1).linear_pattern(counts=[3, 2], steps=[x(3), y(3)])
2026-04-06T19:27:35.642503 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:35.774661 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
radial_pattern(count, angle=360, pivot=0)

Repeat this shape in a radial pattern around the origin.

See radial_pattern_shape() for parameter documentation.

Examples

>>> from scadpy import circle
>>> circle(1).translate([3, 0]).radial_pattern(count=6)
2026-04-06T19:27:35.912672 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
2026-04-06T19:27:36.049824 image/svg+xml Matplotlib v3.10.6, https://matplotlib.org/
to_screen(background_color=[0.95, 0.95, 0.95, 1], foreground_color=[0.05, 0.05, 0.05, 1])

Display a shape in a Qt-based window.

See map_shape_to_screen() for parameter documentation.

Examples

>>> from scadpy import square
>>> square(4).to_screen()
to_html(background_color=[0.95, 0.95, 0.95, 1], foreground_color=[0.05, 0.05, 0.05, 1])

Render a shape as an SVG HTML object.

See map_shape_to_html() for parameter documentation.

Examples

>>> from IPython.core.display import HTML
>>> from scadpy import square
>>> html = square(4).to_html()
>>> isinstance(html, HTML)
True
to_html_file(path, background_color=[0.95, 0.95, 0.95, 1], foreground_color=[0.05, 0.05, 0.05, 1])

Save a shape as an HTML file.

See map_shape_to_html_file() for parameter documentation.

Examples

>>> from scadpy import square
>>> square(4).to_html_file(path="output.html")
to_svg()

Export a shape to an SVG string.

See map_shape_to_svg() for parameter documentation.

Examples

>>> from scadpy import square, circle
>>> svg = (square(4) - circle(1)).to_svg()
>>> svg.startswith("<svg")
True
to_svg_file(path)

Save a shape as an SVG file.

See map_shape_to_svg_file() for parameter documentation.

Examples

>>> from scadpy import square, circle
>>> (square(4) - circle(1)).to_svg_file(path="output.svg")
to_dxf()

Export a shape to a DXF string.

See map_shape_to_dxf() for parameter documentation.

Examples

>>> from scadpy import square, circle
>>> dxf = (square(4) - circle(1)).to_dxf()
>>> dxf.startswith("999")
True
to_dxf_file(path)

Save a shape as a DXF file.

See map_shape_to_dxf_file() for parameter documentation.

Examples

>>> from scadpy import square, circle
>>> (square(4) - circle(1)).to_dxf_file(path="output.dxf")
_abc_impl = <_abc._abc_data object>