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 -
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 -
@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!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login