Beispiel #1
0
    def process(self, instance):

        parent_dir = self.staging_dir(instance)
        hierarchy_filename = "{}.abc".format(instance.name)
        hierarchy_path = os.path.join(parent_dir, hierarchy_filename)
        json_filename = "{}.json".format(instance.name)
        json_path = os.path.join(parent_dir, json_filename)

        self.log.info("Dumping scene data for debugging ..")
        with open(json_path, "w") as filepath:
            json.dump(instance.data["scenedata"], filepath, ensure_ascii=False)

        self.log.info("Extracting point cache ..")
        cmds.select(instance.data["hierarchy"])

        # Run basic alembic exporter
        extract_alembic(file=hierarchy_path,
                        startFrame=1.0,
                        endFrame=1.0,
                        **{"step": 1.0,
                           "attr": ["cbId"],
                           "writeVisibility": True,
                           "writeCreases": True,
                           "uvWrite": True,
                           "selection": True})

        instance.data["files"] = [json_filename, hierarchy_filename]

        # Remove data
        instance.data.pop("scenedata", None)

        cmds.select(clear=True)
Beispiel #2
0
    def process(self, instance):

        staging_dir = self.staging_dir(instance)
        hierarchy_filename = "{}.abc".format(instance.name)
        hierarchy_path = os.path.join(staging_dir, hierarchy_filename)
        json_filename = "{}.json".format(instance.name)
        json_path = os.path.join(staging_dir, json_filename)

        self.log.info("Dumping scene data for debugging ..")
        with open(json_path, "w") as filepath:
            json.dump(instance.data["scenedata"], filepath, ensure_ascii=False)

        self.log.info("Extracting point cache ..")
        cmds.select(instance.data["hierarchy"])

        # Run basic alembic exporter
        extract_alembic(file=hierarchy_path,
                        startFrame=1.0,
                        endFrame=1.0,
                        **{
                            "step": 1.0,
                            "attr": ["cbId"],
                            "writeVisibility": True,
                            "writeCreases": True,
                            "uvWrite": True,
                            "selection": True
                        })

        if "representations" not in instance.data:
            instance.data["representations"] = []

        representation_abc = {
            'name': 'abc',
            'ext': 'abc',
            'files': hierarchy_filename,
            "stagingDir": staging_dir
        }
        instance.data["representations"].append(representation_abc)

        representation_json = {
            'name': 'json',
            'ext': 'json',
            'files': json_filename,
            "stagingDir": staging_dir
        }
        instance.data["representations"].append(representation_json)
        # Remove data
        instance.data.pop("scenedata", None)

        cmds.select(clear=True)
Beispiel #3
0
    def process(self, instance):

        nodes = instance[:]

        # Collect the start and end including handles
        start = float(instance.data.get("frameStartHandle", 1))
        end = float(instance.data.get("frameEndHandle", 1))

        attrs = instance.data.get("attr", "").split(";")
        attrs = [value for value in attrs if value.strip()]
        attrs += ["cbId"]

        attr_prefixes = instance.data.get("attrPrefix", "").split(";")
        attr_prefixes = [value for value in attr_prefixes if value.strip()]

        # Get extra export arguments
        writeColorSets = instance.data.get("writeColorSets", False)

        self.log.info("Extracting pointcache..")
        dirname = self.staging_dir(instance)

        parent_dir = self.staging_dir(instance)
        filename = "{name}.abc".format(**instance.data)
        path = os.path.join(parent_dir, filename)

        options = {
            "step": instance.data.get("step", 1.0),
            "attr": attrs,
            "attrPrefix": attr_prefixes,
            "writeVisibility": True,
            "writeCreases": True,
            "writeColorSets": writeColorSets,
            "uvWrite": True,
            "selection": True,
            "worldSpace": instance.data.get("worldSpace", True)
        }

        if not instance.data.get("includeParentHierarchy", True):
            # Set the root nodes if we don't want to include parents
            # The roots are to be considered the ones that are the actual
            # direct members of the set
            options["root"] = instance.data.get("setMembers")

        if int(cmds.about(version=True)) >= 2017:
            # Since Maya 2017 alembic supports multiple uv sets - write them.
            options["writeUVSets"] = True

        with avalon.maya.suspended_refresh():
            with avalon.maya.maintained_selection():
                cmds.select(nodes, noExpand=True)
                extract_alembic(file=path,
                                startFrame=start,
                                endFrame=end,
                                **options)

        if "representations" not in instance.data:
            instance.data["representations"] = []

        representation = {
            'name': 'abc',
            'ext': 'abc',
            'files': filename,
            "stagingDir": dirname
        }
        instance.data["representations"].append(representation)

        self.log.info("Extracted {} to {}".format(instance, dirname))
Beispiel #4
0
    def process(self, instance):

        # Collect the out set nodes
        out_sets = [node for node in instance if node.endswith("out_SET")]
        if len(out_sets) != 1:
            raise RuntimeError("Couldn't find exactly one out_SET: "
                               "{0}".format(out_sets))
        out_set = out_sets[0]
        roots = cmds.sets(out_set, query=True)

        # Include all descendants
        nodes = roots + cmds.listRelatives(roots,
                                           allDescendents=True,
                                           fullPath=True) or []

        # Collect the start and end including handles
        start = instance.data["frameStart"]
        end = instance.data["frameEnd"]
        handles = instance.data.get("handles", 0)
        if handles:
            start -= handles
            end += handles

        self.log.info("Extracting animation..")
        dirname = self.staging_dir(instance)

        parent_dir = self.staging_dir(instance)
        filename = "{name}.abc".format(**instance.data)
        path = os.path.join(parent_dir, filename)

        options = {
            "step": instance.data.get("step", 1.0),
            "attr": ["cbId"],
            "writeVisibility": True,
            "writeCreases": True,
            "uvWrite": True,
            "selection": True,
            "worldSpace": instance.data.get("worldSpace", True),
            "writeColorSets": instance.data.get("writeColorSets", False)
        }

        if not instance.data.get("includeParentHierarchy", True):
            # Set the root nodes if we don't want to include parents
            # The roots are to be considered the ones that are the actual
            # direct members of the set
            options["root"] = roots

        if int(cmds.about(version=True)) >= 2017:
            # Since Maya 2017 alembic supports multiple uv sets - write them.
            options["writeUVSets"] = True

        with avalon.maya.suspended_refresh():
            with avalon.maya.maintained_selection():
                cmds.select(nodes, noExpand=True)
                extract_alembic(file=path,
                                startFrame=start,
                                endFrame=end,
                                **options)

        if "representations" not in instance.data:
            instance.data["representations"] = []

        representation = {
            'name': 'abc',
            'ext': 'abc',
            'files': filename,
            "stagingDir": dirname,
        }
        instance.data["representations"].append(representation)

        self.log.info("Extracted {} to {}".format(instance, dirname))