Question when removing one atom type of a lammpsdata and then export as a new datafile

Hi,

I am using Ovito Python to do post-processing. I tried to select one atom type and delete it. After doing other operations, I then exported the system as a new lammpsdata file. The first few lines look like
# LAMMPS data file written by OVITO Pro 3.8.4

15800 atoms
5 atom types

0.7271978455 83.0218274363 xlo xhi
0.7271978455 73.0218274363 ylo yhi
0.7271978455 73.0218274363 zlo zhi

But actually, now it should be ‘4 atom types’. Yes, I can change it manually, however, I wonder if I can change it in the script and directly output an appropriate file.

Thanks a lot!

Best regards,
Fan

If you want OVITO to “forget” about a particle type that is part of the File Source, you also actively need to edit the types list, which is attached to the Particle Type Property array, e.g. like this

 for i,type in enumerate(data.particles.particle_types.types):
        if type.id == 2:
            del data.particles_.particle_types_.types[i]

More on so-called typed-properties here:
https://www.ovito.org/docs/current/reference/pipelines/data_objects/particles.html#scene-objects-particle-types
https://www.ovito.org/docs/current/python/modules/ovito_data.html#ovito.data.Property
https://www.ovito.org/docs/current/python/modules/ovito_data.html#ovito.data.ParticleType

Hi,

Thank you for your detailed instructions and information. It helps a lot.

Best regards,
Fan