# Is it possible to iterate through particles in python?

Is it possible to iterate through particles like vertices of a mesh, to kill some? I'm trying to remove overlapping particles of still droplets.

• I don't know how to do it, but I do know that each particle does have it's own unique Index number -- I found it in the "Particle Info" node's Index value. I hope this helps. – Thom Blair III Apr 26 '14 at 15:38
• You might also be able to figure out some more useful information from this post on the Particle Info Node – Thom Blair III Apr 26 '14 at 15:39
• I'm not sure if this is possible in the current release, but it seems like it will be in new releases (I think). – gandalf3 Apr 26 '14 at 19:29

Yes it is to some extent.

ps = obj.particle_systems[particle_sys]
particles = ps.particles

# on large objects list comprehension seems to be slower than index
# and . dotted access is also a slowing factor
for i in range(len(particles)):
# alive_state
# angular_velocity
# birth_time
# die_time
# hair_keys
# is_exist
# is_visible
pt = particles[i]
if pt.is_exist and pt.alive_state == 'ALIVE':
...
# prev_angular_velocity
# prev_location
# prev_rotation
# prev_velocity
# rotation
# size
# velocity


pt.location would give the coordinate. The Particles API seems to be slightly under-developed, but perhaps this info will help you.

• I know this is an old post, but wondering: when I do pt.is_visible, I get a warning that "is_visible" is read-only. Is this always the case, or is there something you need to do in order to be able to edit this parameter? – user61149 Aug 22 '18 at 22:45
• i'd like to think i tried .is_visible before suggesting that, but am not sure anymore. – zeffii Aug 23 '18 at 8:14
• the only property I routinely used for experimentation was pt.location "out of sight out of mind", also .size might be useful – zeffii Aug 23 '18 at 8:32
• Thanks for the quick response! I'm running into issues with setting particle parameters using Python code. I've used .location and .size to change those values for specific particles, and when I print them I see the new values I specified... but in the 3-D viewer nothing changes. Is there something I need to do for my changes to reflect in the model visualization? One thing I noticed is that changing between Object and Particle Edit mode causes the particle parameters to revert to their starting values. Many thanks in advance for any insight you might have! – user61149 Aug 23 '18 at 22:32
• unfortunately the particle API is weak sauce. One thing that you need to do is to trigger an update (to scene..i think). Rotating 3d view after passing a new value to a particle is enough to show what i mean. However in relation to doing this for many particles in a scriptable way you may want to add an event handler to trigger that update. (kind of outside of the scope of the comment section...). – zeffii Aug 27 '18 at 10:53