It looks like you're new here. If you want to get involved, click one of these buttons!
I have been trying to do something very simple, which I do not know why it is not working. I am trying to change some of the attributes of the object pya.Path, but when I do none of the changes actually show up in the PCell on KLayout. Printing out the object attributes should that it is setting it to the value I want, but it is no effect of the outputted PCell. Attached below is a snippet of code that should hopefully clarify my problem:
def produce_impl(self):
# fetch the parameters
w_dbu = self.w / self.layout.dbu
length_dbu = self.length / self.layout.dbu
pts_track = []
pt1 = [(-length_dbu/2,-w_dbu/2),(-length_dbu/2,w_dbu/2),\
(length_dbu/2, w_dbu/2),(length_dbu/2,-w_dbu/2)] #random points, not particularly important
for i in pt1:
pts_track.append(pya.Point.from_dpoint(pya.DPoint(i[0],i[1])))
special_path = pya.Path
special_path.end_ext = 2.5/self.layout.dbu #does not change anything in KLayout
# create the shape
self.cell.shapes(self.l_layer).insert(special_path(pts_track, w_dbu))
Comments
I should also mention that this is not just specific to the attribute "end_txt" as I have tried others. I must be doing something fundamentally wrong so any help would be much appreciated!
You're fundamentally wrong in your understanding of Python.
Here is what you do:
This does not create a path object, but gives you the Path type object.
This sets a new attribute on the type object with no further effect. You just contaminated it.
Now you call the type object which will actually create the path. Calling a type object creates a new object of the type, passing the arguments to the new object's
__init__
constructor.So setting "end_ext" of course does not have an effect.
The correct code is that:
Matthias
Thanks for the quick response Matthias! I realized quickly that this was the case and it seemed to have resolve the issue, but now that I have a more complex geometry (meandering path), this issue occurs even when calling the object in the correct order. Below is what I am referring too:
That is to say even when I use the exact same snippet of code I am using, the path shown in KLayout remains unchanged, regardless of the geometry of the path.
@nsrgorgi You can format source code using a single line with three backticks before and after the code. Without that it's hardly readable. It's the same notation GitHub Markdown uses for example. I took the liberty to edit your text.
I just checked your code and although there is some room for improvement, it correctly configures the path:
The path has round ends and the extensions are half the width of the path. So what is your expectation?
The code has some flaws, like you use "s_dbu" to configure the path width when you obviously mean "w_dbu". In general you could build the Point array directly in the loop rather than generating tuples first and then converting them into point objects. By using DPoint and DPath objects you can directly work with micrometer units and do not have to convert to DBU space by dividing by the DBU.
This "produce_impl" is my version that should fix these flaws:
Matthias