Getting more information from a DRC call

Hi all!

I am just beginning with DRC in klayout, and would like to know something.

When I call the space/width function, is it possible to collect the values of the widths and spaces, say in a list of some sorts ?

I have read the documentation and found no way to do so, but it feels doable...

Thanks in advance



  • Hello,

    It is basically possible to analyse the objects returned by width/space. These are so-called edge pairs and they feature two lines which indicate the original edges violating the condition.

    So the actual space is the "distance" between these edges, but the definition of "distance" is only trivial in the case of parallel edges. In this case, there is a distance definition available.

    There is also the matter of defining the location of a measurement. I'd suggest to use the bounding box center of the edge pair, but you can also use one of the edge points.

    Here is a short code which evaluates the results of a 500nm space check on layer 68/20:

    m2 = input(68, 20)
    space_markers = do |ep|
      center =
      d = ep.first.distance(ep.second.p1)
      puts("#{center} -> D=#{d} DBU")


  • Hi !

    I have tried it out and it seems to work okay. Could you be so kind as to confirm that ep.second.p1 gets the first point of the second edge of the spacing error ? If so, is p2 the second point (I'd rather use those than center).

    Also, what happens if the edge is only composed of one point, as it seems to be the case for one of my erros ?

    Thanks a lot !


  • As mentioned, the definition of distance is not trivial.

    The simple definition above will not work if the first edge is a single point. Unfortunately there is no single function to compute a non-trivial distance. I found some code here which you may be able to port:


  • Hey Matthias,

    Thanks for another insightful answer !

    Since my layout is now more and more complex, another question came to mind :

    Is it possible to separate the space check between two edges of the same shape and two edges of different shapes ?

    Thanks in advance,


  • Yes, that is possible: the space check between the edges of the same polygon is called "notch" and the space check between two edges of different shapes is called "isolated".


  • Thanks a lot !

    You really made my internship easier, thank you for your hard work since the beginning of the klayout project!


  • You're welcome :)

    But you know, since the food chain is basically

    Intern -> Engineer who employs intern -> Manager who employs engineer -> Director -> ... -> CEO

    it's finally your CEO who actually owes me something :)


Sign In or Register to comment.