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