Hello,
In 2.79 this would get me an array with location of particles on selected objects:
import bpy
for psys in bpy.context.active_object.particle_systems:
par_loc = [0,0,0]*len(psys.particles) #create array to store postions
psys.particles.foreach_get("location", par_loc) #fill the par_loc array with particle positions
print(par_loc)
In 2.80 this no longer works, it just returns an empty array. I’ve checked the 2.80 api and found no reason why this should’t work. (https://docs.blender.org/api/blender2.8/bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection)
Would anyone know what could I be doing wrong? is there any other way to access particle attributes in 2.80 which works for you?
Thanks a lot!
Awesome thanks! the solution there seems to fix this
this works in 2.80:
import bpy
ob = bpy.context.active_object
eval_ob = bpy.context.depsgraph.objects.get(ob.name, None)
for psys in eval_ob.particle_systems:
par_loc = [0,0,0]*len(psys.particles) #create array to store postions
psys.particles.foreach_get("location", par_loc) #fill the par_loc array with particle positions
print(par_loc)