construction.PolygonProfile

construction.PolygonProfile(vertices, plane=None, name='profile', free=True)

Closed polygon profile in a sketch plane — a construction-tree node.

Vertices are :class:Vector2 parameters in plane coordinates. Raw arrays are wrapped as free parameters named {name}_v{i} — sketch vertices are editable until constrained, which mirrors CAD sketch semantics. Existing Vector2 parameters are used as-is (free unnamed ones get an auto-generated name so extraction works).

Parameters

Name Type Description Default
vertices Ordered vertex list — Vector2 parameters or raw (2,) arrays. Either winding; the polygon must be simple (non-self-intersecting). required
plane SketchPlane | None The sketch plane; defaults to the world XY plane. None
name str Prefix for auto-generated vertex parameter names. 'profile'
free bool Whether raw vertices become free parameters. True keeps the CAD sketch semantics — a vertex is editable until constrained — and is the default. The generated outlines (:meth:circle, :meth:regular, :meth:rounded_rect) pass False: a computed vertex is a consequence of the shape’s dimensions, not a freedom of its own, and freeing dozens of them would swamp the design space. Existing Vector2 parameters keep whatever they already declare. True

Methods

Name Description
circle A closed circular outline, approximated by segments edges.
edges_world Closed edge loop in world space, shape (N+1, 3) — for overlay drawing.
regular A regular polygon inscribed in a circle of radius.
rounded_rect A rectangle with rounded corners — the flange outline of most parts.
vertex_array Current vertex values stacked as (N, 2) in plane coordinates.
world_vertices Current vertex positions in world space, shape (N, 3).

circle

construction.PolygonProfile.circle(
    radius,
    center=(0.0, 0.0),
    segments=32,
    **kwargs,
)

A closed circular outline, approximated by segments edges.

Parameters

Name Type Description Default
radius Circle radius, as a number (see the note above on why a Scalar here does not stay live). required
center Circle centre in plane coordinates. (0.0, 0.0)
segments int Number of edges; 32 reads as round at typical scales. 32
**kwargs Passed to :class:PolygonProfile — plane, name, and free. {}

Returns

Name Type Description
PolygonProfile The profile, wound counter-clockwise.

edges_world

construction.PolygonProfile.edges_world()

Closed edge loop in world space, shape (N+1, 3) — for overlay drawing.

regular

construction.PolygonProfile.regular(
    sides,
    radius,
    center=(0.0, 0.0),
    start_angle=0.0,
    **kwargs,
)

A regular polygon inscribed in a circle of radius.

Parameters

Name Type Description Default
sides int Number of sides; at least 3. required
radius Circumscribed radius — the distance to each vertex, not to the flats. required
center Polygon centre in plane coordinates. (0.0, 0.0)
start_angle float Angle of the first vertex, in degrees from the plane’s x axis. Use it to put a flat, rather than a corner, where a wrench or a mating part needs one. 0.0
**kwargs Passed to :class:PolygonProfile. {}

Returns

Name Type Description
PolygonProfile The profile, wound counter-clockwise.

Raises

Name Type Description
ValueError If sides is less than 3.

rounded_rect

construction.PolygonProfile.rounded_rect(
    width,
    height,
    radius,
    center=(0.0, 0.0),
    segments=6,
    **kwargs,
)

A rectangle with rounded corners — the flange outline of most parts.

This is the honest way to get a rounded corner in a profile: the corner is traced as polygon vertices before the solid exists, so the round survives extrusion exactly and costs nothing at evaluation time. It is unrelated to the smooth-boolean blends used as fillets between solids, which round an intersection rather than an edge.

Parameters

Name Type Description Default
width Full width along the plane’s x axis. required
height Full height along the plane’s y axis. required
radius Corner radius; clamped to half the shorter side. required
center Rectangle centre in plane coordinates. (0.0, 0.0)
segments int Edges per corner arc. 6
**kwargs Passed to :class:PolygonProfile. {}

Returns

Name Type Description
PolygonProfile The profile, wound counter-clockwise.

Raises

Name Type Description
ValueError If width or height is not positive.

vertex_array

construction.PolygonProfile.vertex_array()

Current vertex values stacked as (N, 2) in plane coordinates.

world_vertices

construction.PolygonProfile.world_vertices()

Current vertex positions in world space, shape (N, 3).