It looks like you're new here. If you want to get involved, click one of these buttons!
I am attempting to create a script to produce a trace around each polygon in a layer and output it onto another layer. I use these traces with boolean operations to resize fill zones for fabrication. I expected this to be easy but I am running into issues generating a list of dpoints for each polygon.
My current code looks like:
import pya
layout_view = pya.Application.instance().main_window().current_view()
cell_view = layout_view.active_cellview()
layout = cell_view.layout()
viewed_cell = cell_view.cell
trace_width = 2.0
metal_layer = layout.layer(1, 0)
trace_layer = layout.layer(3, 0)
polygon_vertices = []
for shape_obj in viewed_cell.each_shape(metal_layer):
polygon_vertices = shape_obj.each_dpoint
viewed_cell.shapes(trace_layer).insert(pya.DPath(polygon_vertices, trace_width))
polygon_vertices = []
Clearly I am misunderstanding how each_dpoint works. I currently don't have to worry about the polygons containing holes if that matters, though I would like to know how I should adapt if they do.
Thanks,
Zach
Comments
Hi @zlnelson,
I think this is easier in DRC language.
My approach would be that:
Matthias
Hi zlnelson,
as your case, do you have any concern for that around trace must be a "path" type or "polygon" type is fine?
Hi zlnelson,
If traced by path is required, then you can tryout this example.
each_point
type functions works like a python generator, you'll need to loop through them and collect all items into a list object before assigning to aDPath
.And
each_dpoint
only works when yourShape
object is aPath
, which might not suits your need, if your are tring to trace polygons.Use
shape.each_dpoint_hull
instead to get vertices from the out line of an object