I'm running the following simple python code with no issues as far as the .blend file with the object I'm modifying is already open.
obj = bpy.data.objects['obj']
obj = C.scene.objects.active
obj.select = True
obj.rigid_body.type = 'PASSIVE'
However, if I add a line at the beginning of my code to open the file,
bpy.ops.wm.open_mainfile(filepath=task_path+ str(x) +".blend")
it opens the file and then I get an AttributeError after obj.rigid_body.type (object has no attribute 'type'). I've already spent several days trying different things. Could anyone help me to understand this? Thanks!
bpy.ops.rigidbody.object_add()
to your script to initialize it. $\endgroup$