Skip to content

pygeo.offset_polygon_ex

fabian-flassig edited this page Jul 8, 2026 · 4 revisions

Computes the parallel offset of a 2D polygon with optional holes and arc segments, and returns both the offset polygon and the mantle faces between the original and the offset boundary.

This function is located in the pygeo module.

The mantle faces are the strips of material that lie between the original polygon boundary and the offset boundary, with their ends mitered along the angle bisectors of the original corners. They are useful for constructing frames, ribbed structures or any other geometry that requires the connecting material between an inset and its source.

pygeo.offset_polygon_ex extends pygeo.offset_polygon by accepting a multi-loop input (e.g. outer boundary plus holes) and arc segment descriptions in the same format as pytha.create_polygon_ex. Arc segments are tessellated internally before the offset is computed.

Like pygeo.offset_polygon, it handles short edges, self-intersection collapse and similar degeneracies cleanly.

offset_loops, mantle_faces = pygeo.offset_polygon_ex(
    {{loop_points_1, loop_segments_1} [, {loop_points_2, loop_segments_2} [, ...]] },
    distance
)
Parameter Type Description
loop_points_i {{u,v}, ...} Coordinates of the loop points in 2D.
loop_segments_i {segment_1, segment_2, ...} Optional specification of the segments. Each segment may be a table with the following fields:
segment_i.angle number Angle of the arc, positive for counter-clockwise arcs.
segment_i.radius number Radius of the arc.
segment_i.orientation "cw" or "ccw" For radius specification: clockwise or counter-clockwise orientation.
segment_i.select_arc "small", "large" For radius specification: select the small or large arc.
segment_i.bulge number Maximum distance between the secant and the arc, positive for counter-clockwise arcs.
segment_i.segments integer Number of edge segments used for arc tessellation.
distance number Offset distance. Positive values move the contour outward, negative values move it inward.

Return values

Type Description
offset_loops {{loop_points_1} [, {loop_points_2}, ...]}
mantle_faces {{loop_points_1} [, {loop_points_2}, ...]}

Notes:

  • The function performs a purely 2D operation in the local u/v plane and does not create any elements in the project.
  • Arc segments in the input are tessellated into edges before the offset is computed; the returned loops contain only plain point coordinates. Arc, radius, angle and bulge information is not preserved in the result.
  • The result follows the loop orientation convention used elsewhere in pygeo: outer loops counter-clockwise, hole loops clockwise.
  • For a single-loop input without arc segments, prefer pygeo.offset_polygon, which additionally provides a per-mantle index back to the original edge.

Example:

local outer = {
    {0,   0},
    {200, 0},
    {200, 100},
    {0,   100},
}
local hole = {
    {50,  30},
    {150, 30},
    {150, 70},
    {50,  70},
}

local offset_loops, mantle_faces = pygeo.offset_polygon_ex(
    { { outer }, { hole } },
    -5
)

-- offset_loops contains the inset outer loop and the (expanded) hole loop.
-- mantle_faces contains all mantle strips along both the outer and the
-- hole boundary, mitered at the corners.

Version Support:

Minimum PYTHA Version: V27

See also:

pygeo, pygeo.offset_polygon, pygeo.offset_polyline_ex, pygeo.clean_polygon_2d_ex, pytha.create_polygon_ex

Clone this wiki locally