Skip to content

create_action

Create an animation asset.

CreateAction

Bases: BlenderCreator

Action output for character rig

Source code in client/ayon_blender/plugins/create/create_action.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class CreateAction(plugin.BlenderCreator):
    """Action output for character rig"""

    identifier = "io.ayon.creators.blender.action"
    label = "Action"
    description = __doc__
    product_type = "action"
    icon = "male"

    def create(
        self, product_name: str, instance_data: dict, pre_create_data: dict
    ):
        # Run parent create method
        collection = super().create(
            product_name, instance_data, pre_create_data
        )
        if pre_create_data.get("use_selection"):
            for obj in lib.get_selection():
                if (
                    obj.animation_data is not None
                    and obj.animation_data.action is not None
                    and obj.animation_data.action.name != product_name
                ):

                    empty_obj = bpy.data.objects.new(name=product_name,
                                                     object_data=None)
                    empty_obj.animation_data_create()
                    empty_obj.animation_data.action = obj.animation_data.action
                    empty_obj.animation_data.action.name = product_name
                    obj.animation_data.action.name = product_name

                if isinstance(obj, bpy.types.Object):
                    collection.objects.link(obj)


        return collection