Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Deleting subset of layers

I need to delete layers related to current cellview.

I tried:

previous_cell_layer = None
active_cell_view_index = current_view.active_cellview().index()
for layer in current_view.each_layer():
if layer.cellview() < active_cell_view_index:
    previous_cell_layer = layer
elif layer.cellview() == active_cell_view_index:

but I get "Unexpected object type (expected argument of class LayerPropertiesIterator, got LayerPropertiesNodeRef) in LayoutView.delete_layer" in 0.25.9.

What is proper way to do this in Python? By the word, how to insert layer at before other layers (== begin_layers())?


  • edited June 30

    Hi Eugene,

    "each_layer" will deliver the layer properties, but in order to delete a layer you'll need a pointer to the layer (aka "iterator").

    Here is how you delete all layers with a specific cellview index (for example), you need to use an iterator like this:

    view = pya.LayoutView.current()
    cv_index_to_delete = 0
    # Gets the iterator pointing to the first entry
    it = view.begin_layers()
    while not it.at_end():
      if it.current().cellview() == cv_index_to_delete:
        # delete the layer (view)
        # otherwise advance the iterator (in the other case, this is not
        # required as the iterator will already point to the next layer
        # after delete_layer)

    The iterator will take care of the potential case of grouped layers too.

    When extending the code to "cellview less than x" note that cellview() can be -1 indicating that there is no cellview attached to a node.


  • Hi, Matthias!

    Thank you for help! It works!

    By the word, it may be worth to do similar changes in, so imported data will be applied only to current cellview.


  • Hi Eugene,

    thanks for this suggestion. You mean to delete all layers of the current cellview so that the techfile settings are only applied to them?


  • Hi, Matthias!

    Yes, I meant this.


Sign In or Register to comment.