It looks like you're new here. If you want to get involved, click one of these buttons!
Hello!
I'm trying to code a path in Python given around 4 points.
https://www.klayout.de/forum/discussion/2056/drawing-path-or-polygon
I used the discussion above as someone had tried implementing this in Ruby and received a reply with a successful code.
I transferred it into Python, but it seems to not work. Can anyone see something that I can't and could possibly help?
TIA!
layout_view = pya.Application.instance().main_window().current_view()
cell_view = layout_view.active_cellview()
layout = cell_view.layout()
viewed_cell = cell_view.cell()
layer = layout.layer(4, 0)
point1 = pya.DPoint(0.0, 0.0)
point2 = pya.DPoint(15.0, 15.0)
point3 = pya.DPoint(30.0, 30.0)
point4 = pya.DPoint(45.0, 45.0)
viewed_cell.shapes(layer).insert(pya.DPath([point1, point2, point3, point4], 1.0))
Comments
Hi bmebu
I've tried the code, and it works fine after a small tweak
After this you should have a path in your layout, but you might still not able to see anything.
in that this case you need to right click on layer tool box and select "add another layer enteries" in popup menu
and you'll see layer "4/0" shows up and so as the path you added.
Very good. Thanks for this post!
You can insert this statement to make sure the new layer is shown:
Kind regards,
Matthias