2
$\begingroup$

there I am trying to find a way to Unlink the animation data of two linked objects ,

Let's Describe the problem: Right now I use a script with this data to create a linked copy of an object.

import bpy

# Phase : Duplicate Linked
# Duplicating the object while being linhked
for obj in bpy.context.selected_objects:
    obj2 = obj.copy()
    obj2.data = obj.data

    #link to scene
    bpy.context.scene_collection.objects.link(obj2)

It's script just for explaination what I am doing,

My Problem is here Unlinking the object:

Phase : Removing Duplicate Linked

# Unlinking the Linked duplicate

for obj in bpy.context.selected_objects: 
    obj.data = obj.data


# It doesn't unlink the object keyframes

#so obj2's keyframes/animation are still linked to original source of the object we made 
#duplicate from

I know we can make the object animation single data, by F3-> Relations -> Make Single User-> Animation data

But I would like to know How to do it using Python?, I tried Accessing obj.animation_data, but it's read only.

Here is a similar post but they don't use Python to make single animation data there: Unlinking animation data from objects

$\endgroup$

1 Answer 1

2
$\begingroup$

Actually I found it,

Just go into the animation_data and actions and copy it # Unlinking the Linked duplicate

for obj in bpy.context.selected_objects: 
    obj.data = obj.data
    if obj.animation_data:
       obj.animation_data.action = obj.animation_data.action.copy()
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .