Skip to content

pytha.analyze_part_silhouette

fabian-flassig edited this page Jul 31, 2026 · 1 revision

Computes the silhouette (outline) of a part and returns it as 2D outline loops.

Projects a part onto a plane and returns its outline as one or more closed loops, without creating any geometry. The silhouette is the outer contour of the part as seen along the projection direction, including any inner contours (holes). The projection direction is the w-axis of the coordinate frame and the outline is returned in its u/v plane. Without an origin and axes the part is viewed along the global z-axis (top view).

Note: To create a part from the outline instead of returning coordinates, use create_silhouette instead.

pytha.analyze_part_silhouette(part [,origin [,options]])
Parameter Type Description
part element_handle Element handle of the part to project. A group or a table of handles projects each contained part.
origin {x,y,z} Optional: origin of the projection frame.
options {...} Optional: a table that may contain the following options:
options.u_axis {x,y,z} Local coordinate u-axis of the projection frame.
options.v_axis {x,y,z} Local coordinate v-axis of the projection frame.
options.w_axis {x,y,z} Local coordinate w-axis of the projection frame; this is the direction the part is viewed along.

Return value

Type Description
loops A list of loops. Each loop is a list of {u,v} points in the projection plane. If the part has no silhouette an empty list is returned.

The outer loop is returned counter-clockwise, inner loops (holes) clockwise. For a closed loop the first point is not repeated at the end.

Notes:

  • The projection direction is the w_axis. By default (no origin and no axes) the part is viewed along the global z-axis.
  • The returned coordinates are 2D u/v coordinates in the plane of the projection frame.
  • Inner contours (holes) are returned as separate loops.
  • The function does not create geometry. The result can be passed to create_polygon_ex to build a face from it.
  • When a group or a table of handles is passed, the loops of all contained parts are returned together in one flat list.
  • The order in which loops are returned is not guaranteed.

Example:

Read the top-view silhouette of a part and report the loops:

local loops = pytha.analyze_part_silhouette(part)
print(#loops .. " loop(s)")
for i, loop in ipairs(loops) do
    print("loop " .. i .. " has " .. #loop .. " points")
end

Silhouette as seen from the side (viewed along the y-axis):

local loops = pytha.analyze_part_silhouette(part, {0, 0, 0}, { w_axis = {0, 1, 0} })

Version Support:

Minimum PYTHA Version: V27

See also:

pytha, element handles, Axes and directions, Local Coordinates, create_silhouette, analyze_polyline, create_polygon_ex

Clone this wiki locally