It looks like you're new here. If you want to get involved, click one of these buttons!
Hi all,
I am encountering an issue with the CellView::filename status. When I read a file with MainWindow::load_layout the return of pya.CellView().active().filename()
gets the filepath associated with the layout behind the cellview as described in the doc.
When I try to read a file with the following way the return of that getter is empty:
main_window = pya.Application.instance().main_window()
main_window.create_view()
layout = pya.Layout()
layout.read(filepath)
main_window.current_view().show_layout(layout, False)
...
pya.CellView().active().filename() # returns empty string
I am missing something, or if it is a bug (?), do I have alternatives to set the filepath on the layout?
Comments
I think this is not a bug but a design specification or policy.
I have tried to understand this problem as follows, but I am not sure.
I hope @Matthias will give us the correct answers.
Case-A: empty string
Case-B: non-empty string
Case-C: non-empty string
Hi @sekigawa,
Thank you for your input in this matter.
I tend to believe that this is more of a bug since the info of the loaded filepath has been used as input to
pya.Layout
object in initialization, and cannot be retrieved somehow as far as I know (please correct me if I am wrong).This is also something that concerns me, and I believe is due to the same reason (empty
CellView::filename
):Hi @crizos,
The Layout object does not store the file path. Only the CellView does. You can load a file into a Layout, but when you transfer it into the view, the file name is not known. This is also the reason why filename is not an attribute of the Layout object.
The correct way to load a layout is using
LayoutView#load_layout
. This will transfer the file path into the CellView.Matthias
Hi @Matthias,
Let's say that we have the following scenarios:
Scenario A: filename invalidation - empty string
In the above scenario I've never changed the original filepath of the layout, so I would expect that I could still retrieve it somehow.
Scenario B: filename invalidation - missing (?) filename
I believe the
filename()
should be attached at least in the initial filepath given for the loaded/showed layout, independent of how someone chose to do so. Ideally, filename() should return a list of all the filepaths used in each respective cellview.Chris
No,
Layout
does not carry the filename.Layout
is the geometry database, andfilename
is not an attribute of it. In the same way, layer colors are not attributes of theLayout
object but something that belongs toLayoutView
in that case.The object representing the file is the
CellView
, notLayout
and this is whyCellView
has thefilename
attribute, notLayout
. In the same spirit for example the file watcher, which informs KLayout about file changes, is attached to theCellView
, notLayout
.So in scenario A, you take a
Layout
, dup it and create a newLayout
. The first object does have the file name, so the new copy will not have one too. When you show the new layout, it is the same geometry, but not the same "thing" in the sense of the same file. It is something fresh and as you substitute the firstCellView
("False" for theadd_cellview
argument),cellview
will point to the new entry not having a file name.In scenario B, you also address the
Layout
object only. Again, this object does not carry the file name and loading something into it is changing the geometry, but does not modify the filename attribute of the 'CellView'. The right way to create a file-attached layout isLayoutView#load_layout
. This creates a 'CellView' associated with a specific file.There is no direct way to manipulate a
CellView
to load a specific file. You have to useLayoutView
methods to create cell views (load_layout
,show_layout
) to reload file (reload_layout
) or to close a cell view (erase_cellview
, equivalent toCellView#close
).Matthias