How to program drawing a path around the outline of a polygon

I am trying to write a phython script that will draw a path or polygon around the outline of a previously drawn polygon, such as the green outline in the example below. How should do this? What functions are useful? Thanks

Comments

  • This is straightforward and a little playing around will help you learn.
    Crudely:
    regA = pya.Region(pya.Box(-1, -1, 1, 1))
    regB = pya.Region(pya.Box(0.5, 0.5, 3, 3))
    path_outside = (regA.sized(0.1)+regB.sized(0.1)).merged()
    path = path_outside - regA - regB

  • edited June 2024

    My idea is the same as that of mjcich. But I tried to implement it with The KLayout Python Module.

  • Thanks to you both.

    My suggestion was to use DRC which is slightly more compact:

    ```
    drawn = input(1, 0) # substitute drawing layer
    path = drawn.sized(100.nm) - drawn # substitute width
    path.output(2, 0) # substitute output layer
    ```

    However, this solution creates a path around all features on the layer.

    Matthias
Sign In or Register to comment.