-
Notifications
You must be signed in to change notification settings - Fork 18
pytha.analyze_part_section
Computes the cross-section of a part cut by a plane and returns it as 2D outline loops.
Cuts a part (or several) with a plane and returns the resulting cross-section as one or more closed loops, without creating any geometry. The outer contour and any holes are returned as loops of the same section, so holes are inner loops rather than separate contours. The cutting plane is defined the same way as for cut_element: a point on the plane (origin) and the plane normal (axis). The input parts are left unchanged.
Note: To create a part from the cross-section instead of returning coordinates, use create_part_section instead.
pytha.analyze_part_section(part, origin, axis)| Parameter | Type | Description |
|---|---|---|
part |
element_handle or {...}
|
A single part handle or a table of handles. A group is cut as its member parts. |
origin |
{x,y,z} |
A point the cutting plane passes through. |
axis |
{x,y,z} |
Normal vector of the cutting plane. |
| Type | Description |
|---|---|
loops |
A list of loops. Each loop is a list of {u,v} points in the cutting plane. If the plane does not cut the part 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.
- The returned coordinates are 2D
u/vcoordinates in the cutting plane. - Inner contours (holes) are returned as separate loops of the same section.
- The function does not create geometry and does not modify the input parts. The result can be passed to
create_polygon_exto build a face from it. - When several parts are cut, the loops of all sections are returned together in one flat list.
- The order in which loops are returned is not guaranteed.
Read the cross-section of a part at the horizontal plane through z = 500:
local loops = pytha.analyze_part_section(part, {0, 0, 500}, {0, 0, 1})
print(#loops .. " loop(s)")
for i, loop in ipairs(loops) do
print("loop " .. i .. " has " .. #loop .. " points")
endMinimum PYTHA Version: V27
pytha, Part Tools Functions, element handles, create_part_section, analyze_part_silhouette, cut_element, create_polygon_ex