gdsfactory.boolean

Contents

gdsfactory.boolean#

gdsfactory.boolean(A: ComponentOrReference, B: ComponentOrReference, operation: str, layer1: LayerSpec | None = None, layer2: LayerSpec | None = None, layer: LayerSpec = (1, 0)) Component[source]#

Performs boolean operations between 2 Component or Instance objects.

The operation parameter specifies the type of boolean operation to perform. Supported operations include {‘not’, ‘and’, ‘or’, ‘xor’, ‘-’, ‘&’, ‘|’, ‘^’}:

  • ‘|’ is equivalent to ‘or’

  • ‘-’ is equivalent to ‘not’

  • ‘&’ is equivalent to ‘and’

  • ‘^’ is equivalent to ‘xor’

Parameters:
  • A – Component(/Reference) or list of Component(/References).

  • B – Component(/Reference) or list of Component(/References).

  • operation – {‘not’, ‘and’, ‘or’, ‘xor’, ‘-’, ‘&’, ‘|’, ‘^’}.

  • layer1 – Specific layer to get polygons.

  • layer2 – Specific layer to get polygons.

  • layer – Specific layer to put polygon geometry on.

Returns: Component with polygon(s) of the boolean operations between

the 2 input Components performed.

import gdsfactory as gf

c = gf.Component()
c1 = c << gf.components.circle(radius=10)
c2 = c << gf.components.circle(radius=9)
c2.movex(5)

c = gf.boolean(c1, c2, operation="xor")
c.plot()

(Source code, png, hires.png, pdf)

../_images/gdsfactory-boolean-1.png