It looks like you're new here. If you want to get involved, click one of these buttons!
Hi Matthias,
My script creates some shapes, and I'd like to have them selected when finished (to make it obvious to the user which ones were just created).
The documentation describes how to find shapes to get their "ObjectInstPath":
http://www.klayout.de/doc/code/class_ObjectInstPath.html
But I don't see how to get this for a newly created shape.
new_wg = cell.shapes(layer).insert(wg_path)
new_wg is a <pya.Shape object at 0x11cb50bd0>.
Is there a way to construct my own ObjectInstPath, so that I can select it?
lv.object_selection = ObjectInstPath
In my case, my script starts off with a selected object (a PCell), and finishes with a newly created shape. Perhaps the "dup" method could be used, but I'm not sure if would work for mixing cells vs. shapes.
Also, is there any way to get a history of ObjectInstPath items that were added to a layout? Like a history? For example, if a script starts with nothing selected, could it automatically figure out which shape was added most recently?
Comments
Hi Lukas,
that should be possible.
First of all, "object_selection" is an array of ObjectInstPath objects.
An ObjectInstPath is - as the name applies - an instantiation path to an object. In the simple case, you refer to a shape in the top cell. You have to prepare an ObjectInstPath object with these attributes at least:
So the code should look like (not tested):
Matthias
Thank you. I got it working for shapes, but not for cells / instances.
In your ObjectInstPath documentation, http://www.klayout.de/doc/code/class_ObjectInstPath.html, you don't have cell_index= or inst=, as a settable item.
Do I need to use append_path InstElement? If so, is it just the last instance, or do I need the whole hierarchy?
I tried looking in the IDE debugger to see what an ObjectInstPath looks like, but all that is in the Local variables viewer is: cv_index, layer (Error: in the case of a selected ROUND_PATH PCell), seq, shape (Error: in the case of a selected ROUND_PATH PCell), and top. So I wasn't able to figure it out.
Here's what I tried:
For the shapes, the following worked, with the same wrapper:
Hi Lukas,
you're right, instance selections are formed by appending the instance to the path but not assigning a shape. This will implicitly make the selected object a cell instance selection:
Matthias
As above, but changing to:
The latest statement comes back as "True". But nothing appears selected. And when I Edit | Properties, I get an error:
followed by a crash.
So I created a stand-alone script. I create a blank layout, and run the script. But I get the same behaviour / error message.
Hi Lukas,
I think the proper way to write the above code is
I guess the previous code was changing the "append_path" attribute to an InstElement which basically removes the method, but does not call "append_path". I'm afraid the application is not really safe against unexpected conditions. But I wonder why internal errors crash the application ...
I have confirmed that the following code (which adds an instance of a cell "A") works:
Best regards,
Matthias
works! thank you.