Deleting Entities by Name
-
Hello,
Does anyone know how to delete entities within a model using the Python API. In the example below, I'm trying to delete all entities named "electrode" but the delete doesn't remove them from the UI. I confirmed that the if statement is indeed working.
Thanks.
entities = model.AllEntities() for i in range(len(entities)): name = entities[i].Name if "electrode" in name.casefold(): entities[i].Delete
-
@ebarkoch
The issue in your code is in the last line of the code. You should write entities[i].Delete(). Also please check the indented blocks.The code should be:
entities = model.AllEntities() for i in range(len(entities)): name = entities[i].Name if "electrode" in name.casefold(): entities[i].Delete()
All the best,
Antonino -
@AntoninoMC thanks, that worked perfect!