fabex.utilities.polygon_utils

fabex.utilities.polygon_utils#

Functions#

polygon_boolean(context, boolean_type)

Perform a boolean operation on selected polygons.

polygon_convex_hull(context)

Generate the convex hull of a polygon from the given context.

Module Contents#

polygon_boolean(context, boolean_type)[source]#

Perform a boolean operation on selected polygons.

This function takes the active object and applies a specified boolean operation (UNION, DIFFERENCE, or INTERSECT) with respect to other selected objects in the Blender context. It first converts the polygons of the active object and the selected objects into a Shapely MultiPolygon. Depending on the boolean type specified, it performs the corresponding boolean operation and then converts the result back into a Blender curve.

Parameters:
  • context (bpy.context) – The Blender context containing scene and object data.

  • boolean_type (str) – The type of boolean operation to perform. Must be one of ‘UNION’, ‘DIFFERENCE’, or ‘INTERSECT’.

Returns:

A dictionary indicating the operation result, typically {‘FINISHED’}.

Return type:

dict

polygon_convex_hull(context)[source]#

Generate the convex hull of a polygon from the given context.

This function duplicates the current object, joins it, and converts it into a 3D mesh. It then extracts the X and Y coordinates of the vertices to create a MultiPoint data structure using Shapely. Finally, it computes the convex hull of these points and converts the result back into a curve named ‘ConvexHull’. Temporary objects created during this process are deleted to maintain a clean workspace.

Parameters:

context – The context in which the operation is performed, typically related to Blender’s current state.

Returns:

A dictionary indicating the operation’s completion status.

Return type:

dict