# Problems When using DRC script

edited April 12

Hi guys,
I have a polygon like a trapezoid+ a rectangle, and the length of one egde in rectangle is 1um, I want to check if th angle between the edges of this edge is 90 degree . So I wrote this DRC script:

``````report("w")
layer1 = input(2,2).flatten
test1 = layer1.drc(length==0.1.um).with_angle(89.degree,91.degree)
test1.output("start/end","90deg")
``````

but the script didn't recognize the edge I want, Anyone could help me ? Thanks a lot!
The gds file of this polygon is attached

• edited April 12

Hi @Default,

thanks for the test case.

So to rephrase the problem: you want to find edges connected to an edge with length 1.0µm and forming angles other than 90 degree with that edge.

So like these corners:

Right?

In order to find that, you will need to first detect corners with an angle of != 90 degree and then find the ones that are connected to an edge with length 1.0µm:

``````report("w")

layer22 = input(2, 2)

edges_with_length_1um = layer22.drc(length == 1.0.um)

# NOTE: we need to use booleans to filter out
# corners with 90 degree left turn and 90 degree right turn
corners_not_90degree = layer22.corners(as_boxes) -
layer22.corners(90.0, as_boxes) -
layer22.corners(-90.0, as_boxes)

errors = corners_not_90degree.interacting(edges_with_length_1um)

errors.output("not 90deg")
``````

This renders the three corners (error markers are red):

Matthias

• Hi Matthias,
Thanks for your reply. Actully I need to find edges connected to an edge with length 1.0µm and forming angles = 90 degree with that edge. So I change your DRC code.

``````report("w")
layer22 = input(2, 2)
edges_with_length_1um = layer22.drc(length == 1.um)
corners_90degree = layer22.corners(90.degree, as_boxes)
errors = corners_90degree.interacting(edges_with_length_1um)
errors.output("90deg")
``````

I applied this code to the GDS I upload, but it still can't find the corner i want.
My klayout version is 0.29.0@MacOS
Could you help me with this question? Thanks a lot.

• Hi @Default ,

I hope this is the output you want.

``````report("w")
layer22 = input(2, 2)
edges_with_length_1um = layer22.drc(length == 1.um)
corners_90degree = layer22.corners(+90.degree, as_boxes) +
layer22.corners(-90.degree, as_boxes)
errors = corners_90degree.interacting(edges_with_length_1um)
errors.output("90deg")
``````

to be continued...

• edited April 15

cont.

Why `-90 degree`?

• cont.

``````# https://www.klayout.de/forum/discussion/2490/problems-when-using-drc-script
#
# File: Forum2490/Kazzz2.drc
#
# While traveling along the edges clock-wise, at each right angle,
#   Turn Right => -90.degree
#   Trun Left  => +90.degree

report("w")
layer22 = input(2, 2)

corners_RT90 = layer22.corners(-90.degree, as_boxes)
corners_LT90 = layer22.corners(+90.degree, as_boxes)

corners_RT90.output("RightTurn90")
corners_LT90.output("LeftTurn90")
``````

Regards,
Kazzz-S

• Wow ... with cars!

I actually consider adding an option to "corners" so that you can say "take angle left or right", i.e. "corners(90.degree, both)". That may make thing easier. Right now, you need to check both 90 and -90 degree.

Best regards,

Matthias

• @sekigawa
@Matthias
I see! Thanks for your generous help!