0
$\begingroup$

I am creating a shape with bmesh (for performance reasons, I am using bmesh rather than primitive_cube_add) and want to assign a rigidbody to it, however I get error: RuntimeError: Operator bpy.ops.rigidbody.shape_change.poll() failed, context is incorrect. What am I doing wrong ?

unkapla = bmesh.new()

bmesh.ops.create_cube(unkapla)
me = bpy.data.meshes.new("Cube Bmesh")
unkapla.to_mesh(me)
ob = bpy.data.objects.new("Cube", me)
bpy.context.collection.objects.link(ob)
bpy.context.view_layer.objects.active = ob
bpy.ops.rigidbody.objects_add(type='ACTIVE')
bpy.ops.rigidbody.shape_change(type='BOX') --> Error
$\endgroup$
2
  • 1
    $\begingroup$ Missing "select_set(True)". $\endgroup$
    – tetii
    Commented Nov 26, 2022 at 1:35
  • $\begingroup$ Thanks a lot, that made it $\endgroup$ Commented Nov 26, 2022 at 9:59

0

You must log in to answer this question.

Browse other questions tagged .