Blender 2.8: dynamically set particle locations via python In Blender 2.7 it was possible to set particle locations dynamically as demonstrated in this answer.

In 2.8 particle data isn't up to date unless evaluating the emitter via the depsgraph as shown in this bug report.

This does provide up to date data about the number of particles and makes the individual particle location accessible, however trying to set this value does not update the view and seems to have no visible effect, although accessing the same particle location shows a change has been made.

In 2.7 we were able to force a scene redraw to fix this, any way to update the depsgraph or anything similar to manifest these changes?

Here's the code snippet I'm trying to get to work (requires adding a cube object named 'Cube' with a particle system that has a particle count of 50):

import bpy
import numpy as np
from mathutils import Vector

p = bpy.context.depsgraph.objects.get('Cube', None).particle_systems[0].particles

locations = np.random.randint(-10,10,size = (50,3))
locations = [ Vector(co) for co in locations ]

for pp, loc in zip( p, locations ):
    pp.location = loc

# None of this works
bpy.context.depsgraph.objects.update()
bpy.context.depsgraph.scene_eval.update()
bpy.context.depsgraph.scene.update()
bpy.ops.wm.redraw_timer(type='DRAW')
Object.evaluated_get()

In answering Get particle location using python came across this one.

Note this will work with instanced object or collection particles. Not those rendered as halo.

Test script, set object with ps as active.  Sets all particles on current frame to location (1, 1, 1)

import bpy
from mathutils import Matrix

context = bpy.context


dg = context.evaluated_depsgraph_get()
ob = context.object.evaluated_get(dg)

ps = ob.particle_systems.active
po = ps.settings.instance_object

for p in ps.particles:
    p.location = (1, 1, 1)