extract_animation.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:config 作者: mindbender-studio 项目源码 文件源码
def process(self, instance):
        import os
        import polly
        from maya import cmds
        from avalon import maya

        self.log.debug("Loading plug-in..")
        cmds.loadPlugin("AbcExport.mll", quiet=True)

        self.log.info("Extracting animation..")
        dirname = polly.format_staging_dir(
            root=instance.context.data["workspaceDir"],
            time=instance.context.data["time"],
            name=instance.data["name"])

        try:
            os.makedirs(dirname)
        except OSError:
            pass

        filename = "{name}.abc".format(**instance.data)

        out_set = next((
            node for node in instance
            if node.endswith("out_SET")
        ), None)

        if out_set:
            nodes = cmds.sets(out_set, query=True)
        else:
            # Backwards compatibility
            nodes = list(instance)

        self.log.info("nodes: %s" % str(nodes))
        with maya.suspended_refresh():
            maya.export_alembic(
                nodes=nodes,
                file=os.path.join(dirname, filename).replace("\\", "/"),

                frame_range=(instance.data["startFrame"],
                             instance.data["endFrame"]),

                # Include UVs
                write_uv=True,

                # Include Visibility
                write_visibility=True,

                # Include all attributes prefixed with this
                attribute_prefix="mb"
            )

        # Store reference for integration
        if "files" not in instance.data:
            instance.data["files"] = list()

        instance.data["files"].append(filename)
        instance.data["stagingDir"] = dirname

        self.log.info("Extracted {instance} to {dirname}".format(**locals()))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号