Skip to content

collect_fbx_animation

CollectFbxAnimation

Bases: MayaInstancePlugin, OptionalPyblishPluginMixin

Collect Animated Rig Data for FBX Extractor.

Source code in client/ayon_maya/plugins/publish/collect_fbx_animation.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
class CollectFbxAnimation(plugin.MayaInstancePlugin,
                          OptionalPyblishPluginMixin):
    """Collect Animated Rig Data for FBX Extractor."""

    order = pyblish.api.CollectorOrder + 0.2
    label = "Collect Fbx Animation"
    families = ["animation"]
    optional = True
    input_connections = True
    up_axis = "y"

    def process(self, instance):
        if not self.is_active(instance.data):
            return
        skeleton_sets = [
            i for i in instance
            if i.endswith("skeletonAnim_SET")
        ]
        if not skeleton_sets:
            return

        instance.data["families"].append("animation.fbx")
        instance.data["animated_skeleton"] = []
        for skeleton_set in skeleton_sets:
            skeleton_content = cmds.sets(skeleton_set, query=True)
            self.log.debug(
                "Collected animated skeleton data: {}".format(
                    skeleton_content
                ))
            if skeleton_content:
                instance.data["animated_skeleton"] = skeleton_content

        attribute_values = self.get_attr_values_from_data(
            instance.data
        )

        instance.data["upAxis"] = attribute_values.get(
            "upAxis", self.up_axis)
        instance.data["inputConnections"] = attribute_values.get(
            "inputConnections", self.input_connections)

    @classmethod
    def get_attribute_defs(cls):
        defs = [
            UISeparatorDef("sep_fbx_options"),
            UILabelDef("Fbx Options"),
        ]
        defs.extend(
            super().get_attribute_defs() + [
            EnumDef("upAxis",
                    items=["y", "z"],
                    label="Up Axis",
                    default=cls.up_axis,
                    tooltip="Convert the scene's orientation in your FBX file"),
            BoolDef("inputConnections",
                    label="Input Connections",
                    default=cls.input_connections,
                    tooltip=(
                        "Whether input connections to "
                        "selected objects are to be exported."
                        ),
                    ),
            UISeparatorDef("sep_fbx_options_end")
        ])

        return defs