예제 #1
0
    def process(self, project, asset, subset, version, representation):
        # def process(self, representation):
        # project, asset, subset, version = io.parenthood(representation)

        template = project["config"]["template"]["publish"]
        data = {
            "root": api.registered_root(),
            "project": project["name"],
            "asset": asset["name"],
            "silo": asset["silo"],
            "subset": subset["name"],
            "version": version["name"],
            "representation": representation["name"].strip("."),
        }

        fname = template.format(**data)
        assert os.path.exists(fname), "%s does not exist" % fname

        namespace = maya.unique_namespace(asset["name"], suffix="_")
        name = subset["name"]

        nodes = cmds.file(fname,
                          namespace=namespace,
                          reference=True,
                          returnNewNodes=True,
                          groupReference=True,
                          groupName=namespace + ":" + name)

        # Containerising
        maya.containerise(name=name,
                          namespace=namespace,
                          nodes=nodes,
                          asset=asset,
                          subset=subset,
                          version=version,
                          representation=representation,
                          loader=type(self).__name__)

        # TODO(marcus): We are hardcoding the name "out_SET" here.
        #   Better register this keyword, so that it can be used
        #   elsewhere, such as in the Integrator plug-in,
        #   without duplication.
        output = next((node for node in nodes if node.endswith("out_SET")),
                      None)
        assert output, "No output in rig, this is a bug."

        with maya.maintained_selection():
            # Select contents of output
            cmds.select(output, noExpand=False)

            # TODO(marcus): Hardcoding the exact family here.
            #   Better separate the relationship between loading
            #   rigs and automatically assigning an instance to it.
            maya.create(name=maya.unique_name(asset["name"], suffix="_SET"),
                        family="mindbender.animation",
                        options={"useSelection": True})

        return nodes
예제 #2
0
    def process(self, project, asset, subset, version, representation):
        template = project["config"]["template"]["publish"]
        data = {
            "root": api.registered_root(),
            "project": project["name"],
            "asset": asset["name"],
            "silo": asset["silo"],
            "subset": subset["name"],
            "version": version["name"],
            "representation": representation["name"].strip("."),
        }

        fname = template.format(**data)
        assert os.path.exists(fname), "%s does not exist" % fname

        namespace = asset["name"] + "_"
        name = maya.unique_name(subset["name"])

        with maya.maintained_selection():
            nodes = cmds.file(fname,
                              namespace=namespace,
                              reference=True,
                              returnNewNodes=True)

        # Containerising
        maya.containerise(name=name,
                          namespace=namespace,
                          nodes=nodes,
                          asset=asset,
                          subset=subset,
                          version=version,
                          representation=representation,
                          loader=type(self).__name__)

        # Assign shaders
        data["representation"] = "json"
        fname = template.format(**data)

        if not os.path.isfile(fname):
            cmds.warning("Look development asset has no relationship data.")

        else:
            with open(fname) as f:
                relationships = json.load(f)

            # Append namespace to shader group identifier.
            # E.g. `blinn1SG` -> `Bruce_:blinn1SG`
            relationships = {
                "%s:%s" % (namespace, shader): relationships[shader]
                for shader in relationships
            }

            maya.apply_shaders(relationships)

        return nodes
예제 #3
0
    def process(self, project, asset, subset, version, representation):
        template = project["config"]["template"]["publish"]
        data = {
            "root": api.registered_root(),
            "project": project["name"],
            "asset": asset["name"],
            "silo": asset["silo"],
            "subset": subset["name"],
            "version": version["name"],
            "representation": representation["name"].strip("."),
        }

        fname = template.format(**data)
        assert os.path.exists(fname), "%s does not exist" % fname

        namespace = maya.unique_namespace(asset["name"], suffix="_")
        name = subset["name"]

        with maya.maintained_selection():
            nodes = cmds.file(fname,
                              namespace=namespace,
                              reference=True,
                              returnNewNodes=True,
                              groupReference=True,
                              groupName=namespace + ":" + name)

        # Containerising
        maya.containerise(name=name,
                          namespace=namespace,
                          nodes=nodes,
                          asset=asset,
                          subset=subset,
                          version=version,
                          representation=representation,
                          loader=type(self).__name__)

        # Assign default shader to meshes
        meshes = cmds.ls(nodes, type="mesh")
        cmds.sets(meshes, forceElement="initialShadingGroup")

        return nodes
예제 #4
0
    def process(self, instance):
        from maya import cmds
        from mindbender import maya

        with maya.maintained_selection():
            cmds.select(instance, replace=True)
            nodes = cmds.file(
                constructionHistory=True,
                exportSelected=True,
                preview=True,
                force=True,
            )

        self.assemblies[:] = cmds.ls(nodes, assemblies=True)

        if not self.assemblies:
            raise Exception("No assembly found.")

        if len(self.assemblies) != 1:
            self.assemblies = '"%s"' % '", "'.join(self.assemblies)
            raise Exception("Multiple assemblies found: %s" % self.assemblies)
예제 #5
0
    def process(self, project, asset, subset, version, representation):
        template = project["config"]["template"]["publish"]
        data = {
            "root": api.registered_root(),
            "project": project["name"],
            "asset": asset["name"],
            "silo": asset["silo"],
            "subset": subset["name"],
            "version": version["name"],
            "representation": representation["name"].strip("."),
        }

        fname = template.format(**data)
        assert os.path.exists(fname), "%s does not exist" % fname

        namespace = asset["name"] + "_"
        name = maya.unique_name(subset["name"])

        with maya.maintained_selection():
            nodes = cmds.file(fname,
                              namespace=namespace,
                              reference=True,
                              returnNewNodes=True,
                              groupReference=True,
                              groupName=namespace + ":" + name)

        # Containerising
        maya.containerise(name=name,
                          namespace=namespace,
                          nodes=nodes,
                          asset=asset,
                          subset=subset,
                          version=version,
                          representation=representation,
                          loader=type(self).__name__)

        return nodes