0
$\begingroup$

I want to unparent an object.

I tried the following code

import bpy

selectedList = bpy.context.selected_objects
selectedList[0].removeParent()

However, the following error occurred and the parent could not be removed.

AttributeError: 'Object' object has no attribute 'removeParent'
Error: Python script fail, look in the console for now...

How can I make a selected object have no parent?

$\endgroup$
1
$\begingroup$

Solution 1:

Assume you have an object in python obj:

Try obj.parent = None

None is a keyword refer to nothing. You assign the object parent to nothing is equivalent to remove parent.

Solution 2:

Directly modified data in object without operator can lead to some problem. You can clear the parent in your blender, and in info panel you should see the python command: bpy.ops.object.parent_clear(type='CLEAR')

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.