Author Topic: colour atoms by index  (Read 1829 times)


  • Newbie
  • *
  • Posts: 2
colour atoms by index
« on: December 26, 2016, 09:20:56 AM »
Dear there,

    Merry Christmas! I am new to OVITO and have some questtions on it.

    Does OVITO support the coloring assigning by different atom index. e.g.,  atom 1-100 for green while atom 101-200 for red.

Is it likely to be implemented in OVITO by visualised tool?  Or have to be realized by coding scripts in Python and coupling between Python & OVITO.

   Apprecicate your help & thx in advance.

Alexander Stukowski

  • Administrator
  • Hero Member
  • *****
  • Posts: 638
Re: colour atoms by index
« Reply #1 on: December 28, 2016, 05:00:37 PM »

One way to do this is to first select a group of particles based on their indices and then use the Assign Color modifier to assign a color of your choice to the selected particles. To select the particles, first use the Expression Select modifier with an expression like this:

     ParticleIndex>100 && ParticleIndex<=200

These steps can be repeated to assign colors to more ranges of particles.


  • Newbie
  • *
  • Posts: 1
Re: colour atoms by index
« Reply #2 on: January 04, 2017, 11:09:51 AM »
It's also possible by assigning all the colors in one go using the Compute Property modifiers. Set the Output property to Color, and the expressions to something like

Code: [Select]
(ParticleIndex >= 0 && ParticleIndex < 100) ? 0 : ((ParticleIndex >= 100 && ParticleIndex < 200) ? 0.5 : 1)
which would set the first 100 atoms to black, the next 100 atoms to gray, and all the rest of the atoms to white. With many ranges it can get a bit complicated, but one advantage is that you can easily save it as a Custom modifier (I don't think it's possible to save a group of modifiers?)