It looks like you're new here. If you want to get involved, click one of these buttons!

Hi,

I am trying to size a polygon, like what in "Edit->Selection->Size Shapes" for a polygon, but in Pcell? I have no idea about this.

The scalling function seems no function for this polygon,as it seems only work function for instantiate.

https://klayout.de/doc/about/transformations.html

The shape which need to size 0.1um is scripted by :

```
for i in range(len(x)):
pts.append(Point.from_dpoint(DPoint(x[i], y[i])))
# t = Trans(Trans.R0, x, 0)
# polygon = Polygon(pts,t)
polygon = Polygon(pts)
shapes(LayerSi901).insert(polygon)
```

Anyone who know how to size 0.1um for this polygon?

Thank you in advance!

## Comments

You can cast the polygon into a Region using the constructor for Region which takes a polygon https://www.klayout.de/doc/code/class_Region.html

This would be something like

`sized_region = Region(polygon)`

. You can then call the "size" function on the region`sized_region.size(100)`

. Note that you will need to scale the size to database units by dividing by your database unit. This can be obtained through the Layout.dbu parameter as detailed in the documentation: https://www.klayout.de/doc/code/class_Layout.html#method43Actually, I just noticed that the Polygon class has a "size" function, so it is as simple as

@Daaan Yes, polygon.size is there - but beware that it may generate strange "ears" and inner circuits. In order to remove them you'll need to merge the polygon which potentially generates multiple polygons or sometimes even eliminates all of them. So there is no single-polygon-to-single-polygon size function.

The Region class you mentioned is actually my preferred solution as it takes care of handling the size including the merge. It can handle a change in the number of polygons as it's actually a set of them.

Kind regards,

Matthias

@Daaan ,@Matthias,

Thank you for your answer. Both two methods can generate sized shape for a polygon.

As what Matthias said, the following way will apppear "ears", it acturally come up with some sharp points.

The first method as what you suggest works well.

But I have another question, how to characterize a polygon when the 4 coordination of a polygon point are known, What is its grammar？

I tried those three method，they shows "No overload with matching arguments in Region.new in PCellDeclaration.produce\n .......".

If you know, could you tell me? It is difficult for me to get specific rules of writing polygon from this page.

Thank you very much.

Your "polygon1" is not a Polygon type, it is an array of 'DPoints'. You must call the constructor for the Polygon, which takes an array of points. Something like the below (untested!) should work:

I'm not sure if the DPoint array will work or if it must be strictly a Point array. In which case you may have to use something like:

A "Region" is a collection of shapes and tends to be my preference when working with complex shapes. Regions can be combined (boolean), sized, smoothed, etc. Note that the Region can take a Polygon as a parameter for creation. You may then resize the Region, and pass that to the insert() function of your cell. I hope that is reasonably clear?

@Daaan,

Thank you for your detailed reply. I got it.

Both methods (DPoint,Point) constructing polygon works well.

Beside, I find that both "polygon" and "region" can all be insert in shape.

Thank you again for your respond.

@Daaan Yes, thanks for mentioning this. Region only works with integer-type objects. So that's Point, Polygon, Vector, Box, ... everything is in multiples of DBU.

Matthias