# Create a copy of Material animation data

**URL:** <https://blenderartists.org/t/create-a-copy-of-material-animation-data/1389996>\
**Category:** Python Support\
**Tags:** linked, animation\
**Created:** [July 7, 2022, 8:30pm UTC](https://blenderartists.org/t/create-a-copy-of-material-animation-data/1389996 "2022-07-07T20:30:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![drpontchartrain](https://blenderartists.org/user_avatar/blenderartists.org/drpontchartrain/32/881319_2.png) [@drpontchartrain](https://blenderartists.org/u/drpontchartrain)\
**Post date:** [July 7, 2022, 8:30pm UTC](https://blenderartists.org/t/create-a-copy-of-material-animation-data/1389996/1 "2022-07-07T20:30:51Z")

</div>

I have several objects sharing a material that is animating. I’m able to create a copies of the material and assign them to each object, but the animation data is still the same for all materials (see **.blend** , attached). How can I create a copy of the animation data associated with the material as well?

```python
import bpy

s_objs = bpy.context.selected_objects

for obj in s_objs:
    material_slots = obj.material_slots
    for mat_slot in material_slots:
        material = mat_slot.material
        new_material = material.copy()
        mat_slot.material = new_material

bpy.context.view_layer.update()

```

I also tried adding this, but `animation_data` is `None`

```python
anim_data = material.animation_data.copy()
new_material.animation_data = anim_data

```

[![](https://blenderartists.org/uploads/default/original/4X/4/2/2/4227c71ae2be0b95e41be276ef9a77e4ef9fc08e.png)](https://blend-exchange.com/b/ALkvlOyY/)

---

<div class="post-metadata">

**Author:** ![drpontchartrain](https://blenderartists.org/user_avatar/blenderartists.org/drpontchartrain/32/881319_2.png) [@drpontchartrain](https://blenderartists.org/u/drpontchartrain)\
**Post date:** [July 7, 2022, 9:17pm UTC](https://blenderartists.org/t/create-a-copy-of-material-animation-data/1389996/2 "2022-07-07T21:17:20Z")

</div>

Copying the `NodeTree`'s action seems to work:

```python
import bpy

s_objs = bpy.context.selected_objects

for obj in s_objs:
    material_slots = obj.material_slots
    for mat_slot in material_slots:
        material = mat_slot.material
        new_material = material.copy()
        new_material.node_tree.animation_data.action = material.node_tree.animation_data.action.copy()
        mat_slot.material = new_material

bpy.context.view_layer.update()

```
