It looks like you're new here. If you want to get involved, click one of these buttons!
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:
current_view.delete_layer(layer)
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())?
Comments
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:
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.
Matthias
Hi, Matthias!
Thank you for help! It works!
By the word, it may be worth to do similar changes in https://github.com/klayoutmatthias/tf_import/, so imported data will be applied only to current cellview.
Eugene.
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?
Matthias
Hi, Matthias!
Yes, I meant this.
Eugene.