0
$\begingroup$

I parented a rigid body to another rigid body. The parent rigid body is keyframed. I want to remove the parent and any lingering keyframing from that parent. Programatically, I tried to remove the parenting from the child rigid body. It works perfectly in viewport, but not at all when scripting.

What I've tried goes something like this:

    if bpy.context.scene.frame_current == 50: 
       bpy.data.objects['ChildObj'].select = True
       bpy.ops.objects.parent_clear(type='CLEAR')
       bpy.data.objects['ChildObj'].select = False
        

Another thing that may contribute is that the parent rigid body is a compound parent.

In my case, the issue is happening from line 118-122. The file is here

$\endgroup$
5
  • $\begingroup$ I believe this method of selecting objects is deprecated since V2.80. Which version are you using ? $\endgroup$
    – Gorgious
    Mar 1, 2022 at 11:43
  • 1
    $\begingroup$ The current way to remove the parent is to simply set it to none, ie bpy.data.objects['ChildObj'].parent = None You don't need to select or deselect it. $\endgroup$ Mar 1, 2022 at 21:18
  • $\begingroup$ This worked for me on 3.0.0 , thank you! $\endgroup$
    – Thomas0100
    Mar 1, 2022 at 22:49
  • $\begingroup$ @MartyFouts, if I wanted to clear but keep transform, how would that work programatically, thanks in advance! $\endgroup$
    – Thomas0100
    Mar 1, 2022 at 23:12
  • $\begingroup$ Ah, see this answer basically, you need to apply the transform manually. $\endgroup$ Mar 1, 2022 at 23:22

0

You must log in to answer this question.

Browse other questions tagged .