How can I append my pipeline in Ovito?
I tried to append DislocationAnalysisModifier with Selected atom:

from ovito.io import import_file 
from ovito.modifiers import SelectTypeModifier, CommonNeighborAnalysisModifier, PolyhedralTemplateMatchingModifier, DislocationAnalysisModifier 
from ovito.data import DislocationNetwork 

pipeline = import_file("./0.dat") 
# Insert a CNA modifier to determine the structural type of each atom: 

# Apply the SelectTypeModifier to select all atoms of FCC and HCP type: pipeline.modifiers.append(SelectTypeModifier(
   operate_on = "particles", 
   property = "Structure Type", 
   types = { PolyhedralTemplateMatchingModifier.Type.FCC,
             PolyhedralTemplateMatchingModifier.Type.HCP } 
# Extract dislocation lines from a crystal with FCC:

      only_selected = True)) 

data = pipeline.compute() 

total_line_length = data.attributes['DislocationAnalysis.total_line_length'] 

cell_volume = data.attributes['DislocationAnalysis.cell_volume'] 

print("Dislocation density: %f" % (total_line_length / cell_volume)) 

And the output was:

Traceback (most recent call last): 
File "nn.py", line 20, in <module> only_selected = True)) 
AttributeError: Object type DislocationAnalysisModifier does not have an attribute named 'only_selected'. 
ERROR: The Python script 'nn.py' has exited with an error. 

I just want to know how to append "only_selected" in DislocationAnalysisModifier?

Using Ovito 3.0.0-dev155, with Python 3.9.13.

  • $\begingroup$ What version of ovito do you have installed? I don't know much about the package, but the line you have seems consistent with the current documentation, so maybe you are using an old version. $\endgroup$
    – Tyberius
    Nov 24, 2022 at 19:26
  • $\begingroup$ I use Ovito 3.0.0-dev155, with Python 3.9.13 $\endgroup$
    – yoongwan
    Nov 25, 2022 at 5:30

1 Answer 1


While it seems like other modifiers can accept this argument, from the ovito python docs, it looks like only_selected needs to be specified as a property.

Try changing that line to something like:

DAM = DislocationAnalysisModifier()
DAM.only_selected = True

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .