It looks like you're new here. If you want to get involved, click one of these buttons!
Dear Matthias:
I've set layer(85, 0) as text object for testkey description.
I wrote the macro in KLayout Version 0.25.5
But it failed to work in KLayout Version 0.27.1
It seems to drop out at the step while not si.at_end():
Did anything go wrong with my codes?
Thanks
`def ExportCoordinate():
file_path = pya.FileDialog.ask_save_file_name("Save csv file as...", "", "*.csv")
ly = pya.Application.instance().main_window().current_view().active_cellview().layout()
if file_path==None:
return
flag = False
lyInfos = ly.layer_infos()
for i in range(len(lyInfos)):
if str(lyInfos[i].layer) == "85" and str(lyInfos[i].datatype) == "0":
flag = True
input = i
break
if not flag:
pya.MessageBox.info("Alarm", "85/0 not found", pya.MessageBox.Ok)
return
si = ly.begin_shapes(ly.top_cell(), input)
with open(file_path, 'w', newline='') as csvfile:
writer = csv.writer(csvfile)
writer.writerow(['Testkey', 'X', 'Y', 'Rotation'])
while not si.at_end():
try:
dirc = str(si.shape().text.trans)[:3].strip()
except:
pass
text = si.shape().text
bbox = si.shape().bbox().transformed(si.trans())
writer.writerow([text.string, format(bbox.left * ly.dbu, '.3f'), format(bbox.bottom * ly.dbu, '.3f'), dirc])
si.next()`
Comments
What is the error message?
There is no obvious mistake here, but I can't run the script myself as it is not complete.
Matthias
Dear Matthias
No error message, but no output.
There's only one line shows
Testkey X Y Rotation
Well, the code is a bit weird.
"input" is probably not pointing to the layer you want to have.
Simply use:
The search loop isnt' correct. Layer indexes (or rather IDs) are not necessarily incremental.
Matthias
Thanks! It helps.