PCell instance hovering by code

edited June 2019 in Python scripting

Hi,

I found this thread and I was trying to re-create the instance hovering effect, similar to the one from the button that creates the pcell instances.

The code I have so far is this:

import pya

cellview = pya.CellView().active()
view     = cellview.view()
layout   = cellview.layout()
top_cell = layout.top_cell()

myLayer = pya.LayerInfo( 23, 5, 'myLayer')
layout.layer(myLayer)
pya.LayoutView().current().add_missing_layers()

pcell = layout.create_cell("CIRCLE", "Basic", {"layer" : myLayer, "actual_radius" : 100.0, "npoints" : 128 } )
trans = pya.Trans(pya.Trans.R0, 0, 0)
#top_cell.insert(pya.CellInstArray(pcell.cell_index(), trans))

view.max_hier()

Without the last insert command I can drag-n-drop the pcell from the "Cells" view, but I was wondering If there is a way to bring the pcell to the cursor.

Also, I was unable to find a way (or a similar thread), after the 'insert' command, to zoom-fit by code up to the newly created pcell. Is there any way for that?
I think this thread may lead to what I want to do.

Thanks,
Chris

Comments

  • I dont know how to get the position of the mouse, but to select the view region in micron coordinates use layout.zoom_box

  • Caputring mouse position is discussed here.

  • edited June 2019

    Hi jheinsoo,

    Thanks for the answer, I think that you are right for the the zoom-fitting! I guess I never saw these methods. I will try to combine selecting the newly created pcell and then zoom-fit with the "zoom_fit_sel" method. I'll give feedback in that. Thank you!

    I don't want to capture the position of the cursor, I want to re-produce the pcell hovering effect before placing an instance at the layout with plain code, if that is possible. From a previous discussion with Matthias I understood that several features that are implemented as "plugins" are not accessible via standard methods.

    Chris

  • Hi Chris,

    At the risk of repeating myself: I don't know if it is feasible to implement such a feature in Python. The Python API is not equivalent to the internal API. It's provided for certain applications such a scripted layout generation, layout analysis, layout formation, report generation etc. It is not built for reproducing the features of the UI. The Plugin class provides a way to add some UI functionality, but on an intentionally simplistic level.

    Specifically and unlike some other tools, the UI is not implementated in Python, but in C++. That's where you need to go to if you're planning to implement really interactive features.

    Matthias

  • edited June 2019

    Hi Matthias,

    Thank you for your answer, I was hoping that may exist a way to trigger an internal method of this plugin, or anything external, with the pcell information (pcell name, library, parameters dictionary) generated by code, without I have to use the parameters UI to parameterising it, and be able to hover the pcell and place it at will.

    Chris

  • Hi,

    The answer of the OP question is answered by Matthias in this post.

    Chris

Sign In or Register to comment.