Using Blender 2.82a, I am trying to advance an animation and then select an object or mesh that has been updated. I am using something similar to the old scene.update() (pre-2.8) as described in the Blender Wiki here and this question here. However, I am not sure how to properly select the object. Here is a minimal working example. I make a cloth above the starting cube. I advance several frames. Then, I use evaluated_get to get the updated cloth.

But now I'm trying to select it using select_set so that I can then make it the child of an armature (using code in this answer). If you run this Python script:

import bpy

# Add collision modifier to starting cube to support cloth.
cube_obj = bpy.data.objects['Cube']

# Make cloth at a height above the cube.
bpy.ops.mesh.primitive_plane_add(location=(0, 0, 2.0))
cloth = bpy.context.object

# Advance some frames to apply physics.
scene = bpy.context.scene
for f in range(1, 10):

# Get updated cloth.
depsgraph = bpy.context.evaluated_depsgraph_get()
cloth_upd = cloth.evaluated_get(depsgraph)

# At this point, bpy.context.selected_objects = [bpy.data.objects['Plane']]
# Now try to select the _updated_ cloth, but this does not work. I do this because
# I will make an armature later, which is the parent of this updated cloth.

I get the error:

RuntimeError: Error: Object 'Plane' can't be selected because it is not in View Layer 'View Layer'!

When I print the cloth and cloth_upd, both result in <bpy_struct, Object("Plane")>, suggesting that they are of the same class. Does anyone know how to properly select the updated mesh or adjust the layer?

  • $\begingroup$ Thanks Ray for the better tags! Still getting used to them here. :) $\endgroup$ Commented Jun 11, 2020 at 12:32
  • 1
    $\begingroup$ i) since it was last added will already be selected ii) as mentioned before adding a grid removes need to editmode toggle and subdivide a plane to get same result iii) why select the (already selected) updated object? $\endgroup$
    – batFINGER
    Commented Jun 11, 2020 at 12:33
  • $\begingroup$ Hi @batFINGER Thanks for clarity regarding (i) and (ii). I am doing this because if I use the original cloth and try to pin vertices, then the vertices will be pinned as if they were from frame 0 (and not a later frame after physics/animation is applied). This is a limitation that I have been trying to wrap my head around for two weeks. :) I put in a more extensive example here: blender.stackexchange.com/questions/180199/… . Do you feel like this approach makes sense or am I missing something obvious? $\endgroup$ Commented Jun 11, 2020 at 13:01
  • $\begingroup$ There is no need to use an operator to set the object parent, see comment below linked answer Can simply ob.parent = parent and set parent inverse matrices if need be. removing the need to select. Similarly would never use the add modifiers op. Think of an evaluated object as a "virtual entity" for that frame If you print(repr(ob)) instead will see one as bpy.data.objects["Foo"] one as "Evaluated Object Foo" I doubt whether $\endgroup$
    – batFINGER
    Commented Jun 11, 2020 at 14:31
  • $\begingroup$ changing the relations of an evaluated object is going to work, or work as you expect. $\endgroup$
    – batFINGER
    Commented Jun 11, 2020 at 14:32


You must log in to answer this question.

Browse other questions tagged .