[Tutor] Importing an existing plot and manipulating it !
ram rokr
ramrokstheweb at gmail.com
Tue Dec 2 09:53:11 CET 2014
Hello people,
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
the like).
My approach was to create a new layout and try to import the existing plot
and then try to manipulate it:
import math
import numpy as np
import pya
ly = pya.Layout("L10")
# create the top cell
top_cell = ly.create_cell("TOP")
# finding the PCell declaration object ...
class
Dec:
# locating the earlier script to get the parameters for the polygon
def __init__(self):
self.lib = pya.Library.library_by_name("MyLib") #
PCell is a file that contains the polygon with all the parameters of
interesrt.
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 ...
Dec()
# transformation
class Position:
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)
top_cell(insert, pcell_inst)
# write the layout
ly.write("done.gds")
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.
Regards,
Ram.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20141202/07098d73/attachment-0001.html>
More information about the Tutor
mailing list