[Tutor] Importing an existing plot and manipulating it !
ramrokstheweb at gmail.com
Tue Dec 2 09:53:11 CET 2014
I'm a beginner with Python and I'm new to the mailing list.
It's nice to know that there is a mailing list with people/tutors who can
help me learn Python.
So, my difficulty now is that, I already have a script that
plots a polygon. But now I'm trying to script a Python class that would
enable me to import parameters(or the plot itself) from the previous script
and control it too (like specifying parameters: spacing, width, height or
My approach was to create a new layout and try to import the existing plot
and then try to manipulate it:
import numpy as np
ly = pya.Layout("L10")
# create the top cell
top_cell = ly.create_cell("TOP")
# finding the PCell declaration object ...
# locating the earlier script to get the parameters for the polygon
self.lib = pya.Library.library_by_name("MyLib") #
PCell is a file that contains the polygon with all the parameters of
if self.lib == None:
raise Exception("Unknown lib 'MyLib'")
#I'm trying to get parameters from this file/plot to make more.
self.pcell_decl = lib.layout().pcell_declaration("CanaryCell");
if pcell_decl == None:
raise Exception("Unknown PCell 'CanaryCell'")
# instantiating that cell ...
def __init__(self, xpos, ypos, t):
self.xpos = 0
self.ypos = 0
self.t = pya.Trans(pya.Trans.r0(), -1000 + xpos, -1000 + ypos)
# insert into "top_cell" (must be provided by the caller)
class top_cell (Dec, Position):
def __init__(self, insert, pcell_inst):
top_cell = pya.CellView.active().cell
self.a = pya.Point(x1,0)
self.b = pya.Point(0,y1)
self.na = 5
self.nb = 7
pcell_inst = top_cell.insert(pya.CellInstArray(pcell_decl, t, a, b, na, nb))
Position(xpos, ypos, t)
# write the layout
How could you advise me to aprroach this problem accomplish this? I've time
constrains and that's a big problem ! Thanks.
P.S: Yes, the script looks weird. Because I've to use Klayout with python
integration. Since I'm new to both I'm having a hard time. If somebody can
enlighten me about how to do this in Python, maybe I can comprehend and
work it out with KLayout.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor