in order to select all particles of numeric type 1. Your version looks for a particle type named “1”, which is probably wrong.
Keep in mind that all particles types in OVITO have a numeric ID and, optionally, a name. Only if types have a name, e.g., a chemical symbol, you can select them by listing Python strings in the types set. If the particle types are unnamed, you have to list their numeric IDs (integer values).
Have a look at the code example given in the Python reference of the Cluster Analysis Modifier which demonstrates how to access the data table called “Cluster list” in the OVITO desktop application. If you have multiple instances of Cluster Analysis modifiers in your pipeline, their respective python modifiers are called “clusters”, “clusters.2”, etc.
In the software, the cluster analysis with selected particles doesnt color each cluster differently, is it a bug or not implemented?
Possibly you forgot to add a Clear Selection Modifier at the top of the pipeline? Note that in the interactive viewports of the Desktop application, particle selections are highlighted as red particles to be clearly visible at all times.
I know this, but I wanted to do the cluster analysis for each type independently and access the cluster list.
Cluster analysis with selection modifiers will only work on one type, but if i try to apply it again for the second type, it will override the previous cluster list for type one, any fix for this?
Analogous to what you would do in the desktop application, the idea is to use multiple instances of Select Type and Cluster Analysis modifiers. As explained above, several cluster tables will be generated.
Thank you, but this doesn’t work.
It’s true that each cluster modifier has detected the clusters correctly.
But in the Data Tables, if you look at particles of Type 3 (in your example), they will have cluster 0! So I think the 2nd modifier overrode the 1st modifier.
I am trying to achieve this in python, but it will have the same issue (2nd modifier overrides 1st modifier!).
I see, you’re pointing out that each time you perform cluster analysis, the Cluster identifiers assigned to the particles in the clusters begin anew from 1. To address this, one could develop a short tailored Python solution that updates those identifiers that appear in both the cluster list data.tables["clusters"] and the particle property data.particles["Cluster"].
This extent of assistance is what I can provide within the limits of free support. If you have an active OVITO Pro subscription, please reach out via email to request more in-depth guidance.