boolean

photonforge.boolean(operand1, operand2, operation)

Compute the boolean operation between 2 sets of polygons.

Parameters:
  • operand1 – 2D structure, Reference, Component or sequence of those. All polygons gathered in operand1 are joined before the operation.

  • operand2 – Same as operand1.

  • operation – One of "+" (union), "*" (intersection), "-" (difference), or "^" (symmetric difference).

Returns:

List of resulting polygons.

Examples

>>> horizontal = Rectangle(center=(0, 0), size=(11, 2))
>>> vertical = Rectangle(center=(0, 0), size=(2, 11))
>>> donut = Circle(5, inner_radius=3)
>>> union = boolean(donut, [horizontal, vertical], "+")
>>> len(union)
1
>>> difference = boolean(donut, [horizontal, vertical], "-")
>>> len(difference)
4