Forum Navigation
You need to log in to create posts and topics.

Deletion with python scripting error

Hello everybody,

i have the following expression selection:

pipeline.modifiers.append(ExpressionSelectionModifier(expression = expression_str))

where expression_str is: expression_str = 'ParticleIndex == {}'.format(neighbor_particle_indices[i])

When I want to delete with following modifier:


I am getting:

ValueError: no signature found for builtin <instancemethod __init__ at 0x000001C002EBB558>

The correct syntax is:


This invokes the constructor of the DeleteSelectedModifier class and passes an instance of the class to the append() method. Otherwise, if you forget to write the (), you are passing the class itself to the append() method, which leads to the error. Only modifier objects can be appended to the pipeline, not modifier classes.

Thanks Alexander

Could you please let me know which version of the OVITO (or the ovito Python module) you are using?

Actually, because this is such a common mistake made by users (you can find more questions like yours in this forum), newer versions of the OVITO Python interface catch this specific kind of error and should still do the right thing intended by the user. Thus, append(DeleteSelectedModifier) will not result in a visible error but is silently translated into append(DeleteSelectedModifier()) by the internal implementation. Older OVITO versions did not provide this "fault tolerance" yet.

New for our users in China: OVITO on WeChat 

Official OVITO WeChat channel operated by Foshan Diesi Technology Co., Ltd.