-
Notifications
You must be signed in to change notification settings - Fork 0
/
05 Olympus FOV markers sqgrid.lym
176 lines (148 loc) · 4.35 KB
/
05 Olympus FOV markers sqgrid.lym
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?xml version="1.0" encoding="utf-8"?>
<klayout-macro>
<description/>
<version/>
<category>pymacros</category>
<prolog/>
<epilog/>
<doc/>
<autorun>false</autorun>
<autorun-early>false</autorun-early>
<shortcut/>
<show-in-menu>false</show-in-menu>
<group-name/>
<menu-path/>
<interpreter>python</interpreter>
<dsl-interpreter-name/>
<text>import pya
import math
from string import ascii_uppercase
print("-----------------------------------")
#INFO: To be run after using "generate_alignment_marker_base". Requires existance of certain layers/cells.
ENSURE_ODD = True #Change rows/cols to ensure ODD alignment & then draw arrows.
# Get layout view, if no layout create one.
lv = pya.LayoutView.current()
# Get cell view, if not existing, then create one.
cv = pya.CellView.active()
layout = cv.layout()
#Select "TOP" Cell
top = layout.cell("TOP")
AM = layout.cell("Alignment Markers")
#Create cell for grid
GRD = layout.create_cell("Grid")
cv.cell = GRD #set to current selection.
# Ensure there is a layer existing
layl = []
layi = []
li = lv.begin_layers()
while not li.at_end():
node = li.current()
ly = lv.cellview(node.cellview()) #layout object
lj = node.layer_index() #layer index
layl += [ly]
layi += [lj]
li.next()
alg_layer_ind = layl[0]
alg_layer = pya.LayerInfo(1,0)
box_layer_ind = layl[1]
box_layer = pya.LayerInfo(2,0)
# Add extra layer for text
txt_layer_ind = layout.insert_layer(pya.LayerInfo().new(3,0,"text"))
txt_layer = pya.LayerInfo(3,0)
if ENSURE_ODD:
# Add layer for arrows
arr_layer_ind = layout.insert_layer(pya.LayerInfo().new(4,0,"arrows"))
arr_layer = pya.LayerInfo(4,0)
# Put layers in list:
lv.add_missing_layers()
lv.layer = txt_layer #select layer
#Writing Layer info
#Create Cell for Alignment markers.
cv.cell = GRD #set to current selection.
# Get TEXT object
lib=pya.Library.library_by_name("Basic")
txt=lib.layout().pcell_declaration("TEXT")
#Specify grid
boundx = 135e3 #um
boundy = 100e3 #um
box_pad = 5e3 #um - from boundary to boxes
box_len = 3e3 #um
#Spacing allowed for 4.5mm chips with gold pads:
#rows = math.ceil(2700e3 / boundy)
#cols = math.ceil(2700e3 / boundx)
#Spacing allowed for 1cm chips
#rows = math.ceil(10000e3 / boundy)
#cols = math.ceil(10000e3 / boundx)
#Spacing allowed for 4.5mm chips
#cols = math.ceil(4500e3 / boundx)
#rows = math.ceil(4500e3 / boundy)
#Spacing allowed for 1mm chips with gold pads:
cols = math.ceil(1000e3 / boundx)
rows = math.ceil(1000e3 / boundy)
if ENSURE_ODD:
if cols%2 == 0:
cols -= 1
if rows%2 == 0:
rows -= 1
#Write text & multiply cell
for row in range(rows):
for col in range(cols):
x = (col - 0.5 * (cols-1))*boundx
y = (-row + 0.5 * (rows-1))*boundy
#Create instances of Alignment markers
inst = pya.CellInstArray(AM.cell_index(), pya.Trans(pya.Point(x,y)))
GRD.insert(inst)
th = 5 #text height
# #TEXT
#text_ij = ascii_uppercase[row] + "%2.2i" % col #TextLabel
text_ij = "X%2.2iY%2.2i" % (col,row) #TextLabel
param = {
"layer":txt_layer,
"text":text_ij,
"mag": th
}
#Generate defaults for all other parameters
pv = txt.get_parameters()
for p in pv:
if not p.name in param.keys():
param[p.name] = p.default
#print(p.name,p.default)
#Make Cell
pvar = layout.add_pcell_variant(lib, txt.id(), param)
tx = x - 0.5*boundx + box_pad + 2*box_len
ty = y + 0.5*boundy - box_pad - box_len + 0.5*(box_len - 0.7e3*th)
t = pya.Trans(pya.Trans.R0,tx,ty) #pya.Trans(pya.Trans.R90,0,30e3)
#instantiate
pinst = GRD.insert(pya.CellInstArray(pvar, t))
# Centring Arrows
if ENSURE_ODD:
# Generate
sc = 50e3 #scale
arrow = [
pya.Point(-0.3*sc,-0.5*sc),
pya.Point(-0.3*sc,0.3*sc),
pya.Point(-0.7*sc,0.3*sc),
pya.Point(0*sc,1*sc),
pya.Point(0.7*sc,0.3*sc),
pya.Point(0.3*sc,0.3*sc),
pya.Point(0.3*sc,-0.5*sc),
pya.Point(-0.3*sc,-0.5*sc),
]
xx = boundx*(cols+1)
yy = boundy*(rows+1)
arr_t = [
pya.Trans(pya.Trans.R0,0*xx,-0.5*yy),
pya.Trans(pya.Trans.R270,-0.5*xx,0*yy),
pya.Trans(pya.Trans.R180,0*xx,0.5*yy),
pya.Trans(pya.Trans.R90,0.5*xx,0*yy)
]
parrs = []
for i in range(4):
parr = pya.Polygon(arrow)
parr = parr.transformed(arr_t[i])
GRD.shapes(arr_layer_ind).insert(parr)
parrs.append(parr)
#Properly fit area
lv.zoom_fit()
</text>
</klayout-macro>