It looks like you're new here. If you want to get involved, click one of these buttons!
Hi, I'm new to all this so mind the dumb question. I'm trying to have a library of functions in a .py file that I call freely from an .lym file.
Let's say I have,
import pya
import math
def circleMake(numPts, radius):
pts = []
numPts = 500
radius = 10000
angle = 2 * math.pi / numPts
for incAngle in range(0, numPts):
pts.append(pya.Point.from_dpoint(pya.DPoint(radius * math.cos(incAngle * angle), radius * math.sin(incAngle * angle))))
poly = pya.Polygon(pts)
top.shapes(l1).insert(poly)
layout = pya.Layout()
top = layout.create_cell("TOP"
l1 = layout.layer(1, 0)
circleMake(100, 50)
layout.write("circleTryZ26.gds")
and I try to put circleMake into a different file. It says that layout/top/etc is not defined obviously. I'm not sure what the common solution is to this problem?
Thank you for your time!
Comments
Hi,
welcome to the new style, BTW
"layout" can't be accessed from a function inside a module. But of course you can add this to the list of parameters:
In an object-oriented world you might consider using an object for this purpose:
Using an object will make you think in terms of required information, status and services. The class provides the interface by which your outside code can make use of these services.
Matthias