Rounding Corners

Hello,

I am using python to draw my layout, and for some reason I do not manage to use the round corners function. Please help!
At first I was using Box but it appears that it does not inherit the Round Corners from Polygon, so I changed it..

Here's the relevant code I'm using, an example for a single box-polygon:

layout = pya.Layout()
top = layout.create_cell("TOP")
Layer1 = layout.layer(1, 0)

def CreateRect(x1,y1,x2,y2):
BL = pya.Point(x1,y1)
BR = pya.Point(x2,y1)
TR = pya.Point(x2,y2)
TL = pya.Point(x1,y2)
RECT= pya.Polygon([BL,BR,TR,TL])
return RECT

rec = CreateRect (-30,-30,30,30)
top.shapes(Layer1).insert(rec.round_corners(10,1,100))

layout.write("test.gds")

When I run this code, I get the same result as if I just use insert(rec), without the round corners. Note that in the GUI, after that is done, I can go edit>selection>Round Corners> 10 / 1 / 100 and it works perfectly. Any chance you know why this doesn't work through python?

Comments

  • Hi,

    first thing is that your coordinates are pretty small. With the integer types (Polygon, Point, ...), the coordinates are in database units (typically 1nm) and arithmetic is in integers. You have given an inner radius of 10 and an outer radius of 1. as 1 is the smallest possible radius, if will eventually just notch your corners a little, but that's it.

    If you want micrometer units, use the floating-point types (DPoint, DPolygon, ...). You'll see rounded edges with a 1µm radius on the corners then.

    Matthias

  • Dear Matthias,

    It seems that DPolygon does not have the function round_corners. Could you explain how to use this function there? The rounding that currently happen with Polygon really do need better resolution...

    Thank you!
    Shoval.

  • If you need a better resolution, use a smaller DBU. If the curve gets fuzzy, use less points.

    DPolygon is just an intermediate container - finally you'll always need to turn it back into integer, because that is what the layout DB accepts. So even if it had round_corners that wouldn't be helpful.

    Matthias

  • Dear Matthias,

    That is the solution that I used, indeed, dbu changed to 0.1um instead of 1um. But doing that means that you have to manually change all the numbers in your script to 10* (for example, if previously you hade a 50x50 box, now it is 500x500). Is there no easier way to fix this? Changing the dbu also made the file significantly larger and with longer reload times.

    The smallest part in my layout is 5um, and so, a 1um resolution is just fine for me if we don't count the round_corner thing..

    Thanks,
    Shoval.

  • Hi Shoval,

    changing the DBU requires changes of the values, that's right. But a well-made script should use variables. If you hardcode the values in many places it will be difficult to maintain the script anyway.

    Typical DBU values are much smaller than micrometers. GDS is usually written with nm resolution (DBU = 0.001).

    The file size of DBU will not change with DBU. OASIS, CIF and DXF may get a little larger, but that's it. If you see a file growing much bigger with a smaller DBU that's probably because more points are resolved. So that's eventually what you want to achieve.

    Matthias

Sign In or Register to comment.