It looks like you're new here. If you want to get involved, click one of these buttons!
How to draw a circle with pcell rather than polygon points? I can realize it in klayout software by drawing a box and convert to pcell, but i don not know the which function I can use to realize directly in python.
And I wonder the different between pcell method and polygon points method.
Comments
Hello,
Here's some Ruby code to insert the "CIRCLE" pcell from the "Basic" Library... It should be easy to convert to Python...
A pcell has the advantage that it is easier to change afterwards by selecting the pcell instance and changing the properties (PCell parameters)...
Cheers,
Tomas
Adding on to Tomas - here is a link to a ruby pCell circle sample if you want to see the implementation and methods used:
https://klayout.de/doc/programming/ruby_pcells.html
Very good, thanks for the pointers
However, I wonder if there is any advantage placing a PCell. A PCell is just a very complicated way to generate layout.
The easiest way to generate a circle polygon in a Python script is using
Polygon#ellipse
(https://www.klayout.de/doc-qt5/code/class_Polygon.html#k_42). You give it a box, and this method will create a Polygon object with an ellipse (or circle for a square box) filling the box.Matthias
There is no such thing as a true circle in a Cartesian
step-grid system. It's all vectors or pixels and not the
ideal.
I always up the vertex-count on drawn circular features
using the primitive. Kinda fond of 72 as it's got so many
clean-symmetry divisors.
Thanks all! And the code above works.
I initially wanted to use pcell because the shapes got from polygons showed a difference between the diameters of their incircles and circumcircles. So I thought pcell might be a better way to go. Now I’ve figured out that, for my use case, incircle is correct.
Pcell is more complicated than I expected, I would keep using polygon method.
I agree that PCell instantiation in scripts is quite complicated or bulky, especially for ellipses/texts for which dedicated classes/methods are available. However, if you have some (custom made) PCells available you can wrap the code above in a function, and then you need only one line of code in your script to instantiate a PCell, something like:
and in the script:
create_pcell_instance("basic", "CIRCLE", { "layer" => LayerInfo.new(1, 0), "npoints" => 40, "actual_radius" => 5.0 }, [0.0, 30.0], "R0")
Cheers,
Tomas