Modify Example M2: Custom order parameter calculatio

Hello,
I want to modify the example M2 on python scripting such that, instead of squared_deviations, the order parameter is defined based on the structure type for the neighbor atoms. Therefore, I wanted to add the CommonNeighborAnalysis modifier on the data before the neigh_finder command. So, I added:

selection=data.modifiers.append(CommonNeighborAnalysisModifier(3.5))    

But it gives the following error :
‘ovito.plugins.PyScript.DataCollection’ object has no attribute ‘modifiers’

I appreciate your help how I should add ovito’s default modifier to a new modifier I develop by python scripting.
Best,
Sepi

Hello Sepi,
Your question has already been answered here: https://www.ovito.org/forum/topic/modify-example-m2-custom-order-parameter-calculations/.