It looks like you're new here. If you want to get involved, click one of these buttons!
Hi, i am new to KLayout python scripting. Given a layer and sublayer I want to extract all polygons, flatten it and store it in CSV format. Is this possible? Also i want to know how to get started with python scripting? I say few examples posted here but don't know it's full potential, what are functionality available. Where can I learn this?
Comments
Hi!
You could access polygons from
Layout.begin_shapes()
. Current layout object is accessible fromCellView.active().layout()
. See also scripting documentation.Not Python but here is some Ruby, might be of help
Thanks for the reply @EugeneZelenko and @tagger5896 . But this script is for printing layer and datatype. But my concern is to extract polygons in a specific layer.
Layout.begin_shapes()
returnsRecursiveShapeIterator
object that hasshape
property. SeeShape
documentation to learn how to access polygon properties.Thanks again @EugeneZelenko . I think this is the way to do it
Very good, that's exactly how to do it
A remark of mine: in addition to "is_polygon" you may also allow "is_box" and "is_path" (like
if iter.shape().is_polygon() or iter.shape().is_box() ...
). These types can be converted to a polygon too.Thanks to everyone for this discussion!
Best regards,
Matthias
@Matthias
Thanks. Is there by any chance we can include sublayer(datatype) also
layout.begin_shapes(c, layer)
. something like this in python instead of DRCinp = input(13, 0)
outp = polygon_layer
inp.data.each do |p|
outp.data.insert(p)
end
outp.output(1006, 0)
Thanks
Vandhana
Hi, Vandhana!
layer
parameter is index that could be found withLayout.find_layer()
. There are several variants of latter that allow to specifylayer
anddatatype
.Hi Eugene,
Sorry. I misunderstood. Instead of layer index, I thought
layer
was layer number. Thanks for explaining It's of great help.Very good
Yes, layer is the logical index. It's not related to GDS layer - a layout can have unnamed layers and layers with names only (e.g. from CIF). The layer index is a generic identifier. Think of it as a layer handle.
Matthias