Пример #1
0
def addFiles():
    if not "files" in config:
        print "ERROR: No files given"
        sys.exit(2)

    if not "spec" in config:
        print "ERROR: Spec not set"
        sys.exit(2)

    e = ueAssetUtils.getElement(config["spec"])
    if e == {}:
        e = ueCreate.createElement(config["spec"])

    v = ueCreate.createVersion(config["spec"])

    config["spec"].vers = v["version"]

    files = glob.glob(config["files"])

    path = v["path"]
    name = v["file_name"]
    ext = files[0].split(".")[-1]

    if len(files) == 1:
        dest = os.path.join(path, "%s.%s" % (name, ext))
        ueFileUtils.copyFile(files[0], dest)
    else:
        for f in sorted(files):
            dest = os.path.join(path, "%s.%04d.%s" % (name, files.index(f)+1, ext))
            ueFileUtils.copyFile(f, dest)
Пример #2
0
def main():
    if "spec" not in options:
        print "ERROR: Spec not set"
        sys.exit(2)

    spec = ueSpec.Spec(options["spec"])

    edit = ueEdit.getBuild(spec)

    if options["assets"]:
        if options["print"]:
            for sequence in sorted(edit):
                print "-> %s" % sequence
                for shot in sorted(edit[sequence]):
                    print "---> %s" % shot
        elif options["create"]:
            # Get the group and check agains the data in the edit file to see if anything has changed
            spec = ueSpec.Spec(proj=os.getenv("PROJ"))
            for sequence in sorted(edit):
                print "-> Creating sequence %s ..." % sequence
                spec.grp = sequence
                ueCreate.createGroup(spec, "lib")
                for shot in sorted(edit[sequence]):
                    if shot not in ["black", "white"]:
                        print "---> Creating shot %s ..." % shot
                        spec.asst = shot
                        ueCreate.createAsset(spec,
                                             "lib",
                                             dbMeta=edit[sequence][shot])
Пример #3
0
def main():
    if "spec" not in options:
        print "ERROR: Spec not set"
        sys.exit(2)

    spec = ueSpec.Spec(options["spec"])

    edit = ueEdit.getBuild(spec)

    if options["assets"]:
        if options["print"]:
            for sequence in sorted(edit):
                print "-> %s" % sequence
                for shot in sorted(edit[sequence]):
                    print "---> %s" % shot
        elif options["create"]:
            # Get the group and check agains the data in the edit file to see if anything has changed
            spec = ueSpec.Spec(proj=os.getenv("PROJ"))
            for sequence in sorted(edit):
                print "-> Creating sequence %s ..." % sequence
                spec.grp = sequence
                ueCreate.createGroup(spec, "lib")
                for shot in sorted(edit[sequence]):
                    if shot not in ["black", "white"]:
                        print "---> Creating shot %s ..." % shot
                        spec.asst = shot
                        ueCreate.createAsset(spec, "lib", dbMeta=edit[sequence][shot])
Пример #4
0
def addFiles():
    if not "files" in config:
        print "ERROR: No files given"
        sys.exit(2)

    if not "spec" in config:
        print "ERROR: Spec not set"
        sys.exit(2)

    e = ueAssetUtils.getElement(config["spec"])
    if e == {}:
        e = ueCreate.createElement(config["spec"])

    v = ueCreate.createVersion(config["spec"])

    config["spec"].vers = v["version"]

    files = glob.glob(config["files"])

    path = v["path"]
    name = v["file_name"]
    ext = files[0].split(".")[-1]

    if len(files) == 1:
        dest = os.path.join(path, "%s.%s" % (name, ext))
        ueFileUtils.copyFile(files[0], dest)
    else:
        for f in sorted(files):
            dest = os.path.join(path,
                                "%s.%04d.%s" % (name, files.index(f) + 1, ext))
            ueFileUtils.copyFile(f, dest)
Пример #5
0
def createProject():
    if "name" not in project:
        print "ERROR: Project name not set"
        sys.exit(2)

    spec = ueSpec.Spec(project["name"])

    ueCreate.createProject(spec, dbMeta=project["dbMeta"])
Пример #6
0
def createProject():
    if "name" not in project:
        print "ERROR: Project name not set"
        sys.exit(2)

    spec = ueSpec.Spec(project["name"])

    ueCreate.createProject(spec, dbMeta=project["dbMeta"])
Пример #7
0
def createAsset():
    if "name" not in asset:
        print "ERROR: Asset name not set"
        sys.exit(2)

    if "spec" not in asset:
        print "ERROR: Spec not set"
        sys.exit(2)

    spec = ueSpec.Spec("%s:%s" % (asset["spec"], asset["name"]))

    ueCreate.createAsset(spec, asset["type"], dbMeta=asset["dbMeta"])
Пример #8
0
def createGroup():
    if "name" not in group:
        print "ERROR: Group name not set"
        sys.exit(2)

    if "spec" not in group:
        print "ERROR: Spec not set"
        sys.exit(2)

    spec = ueSpec.Spec(group["spec"], group["name"])

    ueCreate.createGroup(spec, group["type"], dbMeta=group["dbMeta"])
Пример #9
0
def main():
    spec = ueSpec.Spec(options["spec"])

    edit = ueEdit.getEdit(spec)

    if options["assets"]:
        if options["print"]:
            for sequence in edit["sequences"]:
                print "-> %s" % sequence
                for shot in edit[sequence]["shots"]:
                    print "---> %s" % shot
        elif options["create"]:
            # Get the group and check agains the data in the edit file to see if anything has changed
            spec = ueSpec.Spec(proj=os.getenv("PROJ"))
            for sequence in edit["sequences"]:
                print "-> Creating sequence %s ..." % sequence
                spec.grp = sequence
                ueCreate.createGroup(spec, "default")
                for shot in edit[sequence]["shots"]:
                    if shot not in excludedShotNames:
                        print "---> Creating shot %s ..." % shot
                        spec.asst = shot
                        ueCreate.createAsset(spec, "default", dbMeta=edit[sequence][shot])
    elif options["play"]:
        shots = []
        for sequence in edit:
            spec.grp = sequence
            for shot in edit[sequence]:
                spec.asst = shot
                spec.eltype = "storyboard"
                spec.elname = "master"
                spec.elclass = "sb"

                versions = ueAssetUtils.getVersions(spec)

                if len(versions) == 0:
                    print "Nothing"
                    shots.append(os.path.join(os.getenv("UE_PATH"), "lib", "placeholders", "edit.1-24.png"))
                else:
                    print "Something"
                    shots.append(os.path.join(versions[-1]["path"], "edit.1-24.png"))

        arguments = ""
        for path in shots:
            arguments += " %s" % (path)

        print arguments

        os.system("rv %s" % arguments)
Пример #10
0
    def save(self):
        spec, dbMeta = ueCommonSave.getValues()

        # Check if the scene has been saved
        if maya.cmds.file(q=True, sn=True) == "":
            ueSave.ueSaveAs()

        sourceSpec = ueSpec.Spec(
            maya.cmds.fileInfo("ueproj", query=True)[0],
            maya.cmds.fileInfo("uegrp", query=True)[0],
            maya.cmds.fileInfo("ueasst", query=True)[0],
            maya.cmds.fileInfo("ueclass", query=True)[0],
            maya.cmds.fileInfo("uetype", query=True)[0],
            maya.cmds.fileInfo("uename", query=True)[0],
            int(maya.cmds.fileInfo("uevers", query=True)[0]))
        destSpec = spec

        # Create the element(s)/version(s) to render into
        dbMeta = {}
        if len(self.renderOpts[1]) > 1:
            dbMeta["passes"] = ",".join(self.renderOpts[1])
        dbMeta["comment"] = "Render from %s" % str(sourceSpec)

        e = ueAssetUtils.getElement(destSpec)
        if e == {}:
            e = ueCreate.createElement(destSpec, dbMeta=dbMeta)

        # If we're rendering into the last existing version, delete it
        if not renderOpts[2]["newVersion"]:
            versions = ueAssetUtils.getVersions(destSpec)
            destSpec.vers = len(versions)
            ueDestroy.destroyVersion(destSpec)

        if renderOpts[2]["clearLastVersion"]:
            print "deleting files"

        # Create a new version
        v = ueCreate.createVersion(destSpec, dbMeta=dbMeta)

        destSpec.vers = v["version"]

        path = v["path"]
        name = v["file_name"]

        # Set up the render globals
        maya.cmds.setAttr("defaultRenderGlobals.extensionPadding", 4)
        maya.cmds.setAttr("defaultRenderGlobals.putFrameBeforeExt", 1)
        if len(self.renderOpts[1]) == 1:
            p = os.path.join(
                path.replace(
                    os.path.join(os.getenv("ASST_ROOT"), "render") + "/", ""),
                name)
            maya.cmds.setAttr("defaultRenderGlobals.imageFilePrefix",
                              p,
                              type="string")
        else:
            p = os.path.join(path.replace(os.path.join(os.getenv("ASST_ROOT"), "render")+\
                                          "/", ""), "<RenderPass", name+"_<RenderPass>")
            p = os.path.join("<RenderPass", name + "_<RenderPass>")
            maya.cmds.setAttr("defaultRenderGlobals.imageFilePrefix",
                              p,
                              type="string")

        dbMeta = {}
        dbMeta["comment"] = "Auto-save of render %s" % str(destSpec)

        ueMayaUtils.saveUtility(sourceSpec, dbMeta=dbMeta)
        ueMayaUtils.saveUtility(sourceSpec)

        if self.renderOpts[0] == 0:
            print "Rendering %s ..." % str(destSpec)
            maya.mel.eval("mayaBatchRender")
        elif self.renderOpts[0] == 1:
            print "Spooling %s ..." % str(destSpec)
        elif self.renderOpts[0] == 2:
            print "Spooling to cloud currently not avaliable"

        self.close()
Пример #11
0
Файл: Render.py Проект: hdd/ue
def runRender(renderOpts):
    root = nuke.root()

    if root.name() == "Root":
        ueNukeSave.ueSaveAs()

    sourceSpec = ueSpec.Spec(root.knob("ueproj").value(),
                             root.knob("uegrp").value(),
                             root.knob("ueasst").value(),
                             root.knob("ueclass").value(),
                             root.knob("uetype").value(),
                             root.knob("uename").value(),
                             root.knob("uevers").value())

    writeNodes = []
    frameRanges = []
    for i, writeNode in enumerate(renderOpts[1]):
        n = nuke.toNode(writeNode)

        destSpec = ueSpec.Spec(n.knob("proj").value(),
                               n.knob("grp").value(),
                               n.knob("asst").value(),
                               n.knob("elclass").value(),
                               n.knob("eltype").value(),
                               n.knob("elname").value())

        # Create the element(s)/version(s) to render into
        dbMeta = {}

        e = ueAssetUtils.getElement(destSpec)
        if e == {}:
            e = ueCreate.createElement(destSpec, dbMeta=dbMeta)

        # If we're rendering into the last existing version, delete it
        if not renderOpts[2]["newVersion"]:
            versions = ueAssetUtils.getVersions(destSpec)
            destSpec.vers = len(versions)
            ueDestroy.destroyVersion(destSpec)

        if renderOpts[2]["clearLastVersion"]:
            nuke.tprint("deleting files")

        # Create a new version
        dbMeta["comment"] = "Render from %s" % str(sourceSpec)
        v = ueCreate.createVersion(destSpec, dbMeta=dbMeta)

        destSpec.vers = v["version"]

        path = v["path"]
        name = v["file_name"]

        # Set up the write nodes with the correct paths
        p = os.path.join(path, name+".%04d."+n.knob("file_type").value())
        n.knob("file").setValue(p)

        # Get the frame range from the ueWrite gizmo, else default to
        # the scripts asset settings
        first = nuke.root().knob("first_frame").value()
        last = nuke.root().knob("last_frame").value()
        if n.knob("use_limit").value():
            first = n.knob("first").value()
            last = n.knob("last").value()

        writeNodes.append(n)
        if i == 0:
            frameRanges.append((int(first), int(last), 1))
        else:
            frameRanges.append((int(first), int(first), 1))

    dbMeta = {}
    dbMeta["comment"] = "Auto-save of render %s" % str(destSpec)

    ueNukeUtils.saveUtility(sourceSpec, dbMeta=dbMeta)
    ueNukeUtils.saveUtility(sourceSpec)

    # Render
    # 0 = Standard nuke "interactive" render
    # 1 = DrQueue render farm (os.system is a little weird, but it's
    #     so you don't have to compile it's python module for nuke)
    # 2 = Cloud render farm, maybe sometime in the future
    if renderOpts[0] == 0:
        nuke.tprint("Rendering %s ..." % str(destSpec))
        # execute() takes a string for the node name, executeMultiple() takes a tuple of node objects
        if len(writeNodes) == 1:
            nuke.execute(writeNodes[0].name(), frameRanges[0][0], frameRanges[0][1], frameRanges[0][2])
        else:
            nuke.executeMultiple(tuple(writeNodes), tuple(frameRanges))
    elif renderOpts[0] == 1:
        nuke.tprint("Spooling %s ..." % str(destSpec))
        sourceSpec.vers = sourceSpec.vers-1
        options = {}
        options["writeNode"] = []
        for render in renderOpts[1]:
            n = nuke.toNode(render)
            options["writeNode"].append(n.name())
        p = os.path.join(os.getenv("UE_PATH"), "src", "ueRender", "Spool.py")
        os.system("python %s %s %s nuke %i %i '%s'" % (p, str(sourceSpec), str(destSpec),
                                                       int(first), int(last),
                                                       json.dumps(options)))
    elif renderOpts[0] == 2:
        nuke.tprint("Spooling to cloud currently not avaliable")
Пример #12
0
def runRender(renderOpts):
    root = nuke.root()

    if root.name() == "Root":
        ueNukeSave.ueSaveAs()

    sourceSpec = ueSpec.Spec(
        root.knob("ueproj").value(),
        root.knob("uegrp").value(),
        root.knob("ueasst").value(),
        root.knob("ueclass").value(),
        root.knob("uetype").value(),
        root.knob("uename").value(),
        root.knob("uevers").value())

    writeNodes = []
    frameRanges = []
    for i, writeNode in enumerate(renderOpts[1]):
        n = nuke.toNode(writeNode)

        destSpec = ueSpec.Spec(
            n.knob("proj").value(),
            n.knob("grp").value(),
            n.knob("asst").value(),
            n.knob("elclass").value(),
            n.knob("eltype").value(),
            n.knob("elname").value())

        # Create the element(s)/version(s) to render into
        dbMeta = {}

        e = ueAssetUtils.getElement(destSpec)
        if e == {}:
            e = ueCreate.createElement(destSpec, dbMeta=dbMeta)

        # If we're rendering into the last existing version, delete it
        if not renderOpts[2]["newVersion"]:
            versions = ueAssetUtils.getVersions(destSpec)
            destSpec.vers = len(versions)
            ueDestroy.destroyVersion(destSpec)

        if renderOpts[2]["clearLastVersion"]:
            nuke.tprint("deleting files")

        # Create a new version
        dbMeta["comment"] = "Render from %s" % str(sourceSpec)
        v = ueCreate.createVersion(destSpec, dbMeta=dbMeta)

        destSpec.vers = v["version"]

        path = v["path"]
        name = v["file_name"]

        # Set up the write nodes with the correct paths
        p = os.path.join(path, name + ".%04d." + n.knob("file_type").value())
        n.knob("file").setValue(p)

        # Get the frame range from the ueWrite gizmo, else default to
        # the scripts asset settings
        first = nuke.root().knob("first_frame").value()
        last = nuke.root().knob("last_frame").value()
        if n.knob("use_limit").value():
            first = n.knob("first").value()
            last = n.knob("last").value()

        writeNodes.append(n)
        if i == 0:
            frameRanges.append((int(first), int(last), 1))
        else:
            frameRanges.append((int(first), int(first), 1))

    dbMeta = {}
    dbMeta["comment"] = "Auto-save of render %s" % str(destSpec)

    ueNukeUtils.saveUtility(sourceSpec, dbMeta=dbMeta)
    ueNukeUtils.saveUtility(sourceSpec)

    # Render
    # 0 = Standard nuke "interactive" render
    # 1 = DrQueue render farm (os.system is a little weird, but it's
    #     so you don't have to compile it's python module for nuke)
    # 2 = Cloud render farm, maybe sometime in the future
    if renderOpts[0] == 0:
        nuke.tprint("Rendering %s ..." % str(destSpec))
        # execute() takes a string for the node name, executeMultiple() takes a tuple of node objects
        if len(writeNodes) == 1:
            nuke.execute(writeNodes[0].name(), frameRanges[0][0],
                         frameRanges[0][1], frameRanges[0][2])
        else:
            nuke.executeMultiple(tuple(writeNodes), tuple(frameRanges))
    elif renderOpts[0] == 1:
        nuke.tprint("Spooling %s ..." % str(destSpec))
        sourceSpec.vers = sourceSpec.vers - 1
        options = {}
        options["writeNode"] = []
        for render in renderOpts[1]:
            n = nuke.toNode(render)
            options["writeNode"].append(n.name())
        p = os.path.join(os.getenv("UE_PATH"), "src", "ueRender", "Spool.py")
        os.system("python %s %s %s nuke %i %i '%s'" %
                  (p, str(sourceSpec), str(destSpec), int(first), int(last),
                   json.dumps(options)))
    elif renderOpts[0] == 2:
        nuke.tprint("Spooling to cloud currently not avaliable")
Пример #13
0
Файл: Render.py Проект: hdd/ue
    def save(self):
        spec, dbMeta = ueCommonSave.getValues()

        # Check if the scene has been saved       
        if maya.cmds.file(q=True, sn=True) == "":
            ueSave.ueSaveAs()

        sourceSpec = ueSpec.Spec(maya.cmds.fileInfo("ueproj", query=True)[0],
                                 maya.cmds.fileInfo("uegrp", query=True)[0],
                                 maya.cmds.fileInfo("ueasst", query=True)[0],
                                 maya.cmds.fileInfo("ueclass", query=True)[0],
                                 maya.cmds.fileInfo("uetype", query=True)[0],
                                 maya.cmds.fileInfo("uename", query=True)[0],
                                 int(maya.cmds.fileInfo("uevers", query=True)[0]))
        destSpec = spec

        # Create the element(s)/version(s) to render into
        dbMeta = {}
        if len(self.renderOpts[1]) > 1:
            dbMeta["passes"] = ",".join(self.renderOpts[1])
        dbMeta["comment"] = "Render from %s" % str(sourceSpec)

        e = ueAssetUtils.getElement(destSpec)
        if e == {}:
            e = ueCreate.createElement(destSpec, dbMeta=dbMeta)

        # If we're rendering into the last existing version, delete it
        if not renderOpts[2]["newVersion"]:
            versions = ueAssetUtils.getVersions(destSpec)
            destSpec.vers = len(versions)
            ueDestroy.destroyVersion(destSpec)

        if renderOpts[2]["clearLastVersion"]:
            print "deleting files"

        # Create a new version
        v = ueCreate.createVersion(destSpec, dbMeta=dbMeta)

        destSpec.vers = v["version"]

        path = v["path"]
        name = v["file_name"]

        # Set up the render globals
        maya.cmds.setAttr("defaultRenderGlobals.extensionPadding", 4)
        maya.cmds.setAttr("defaultRenderGlobals.putFrameBeforeExt", 1)
        if len(self.renderOpts[1]) == 1:
            p = os.path.join(path.replace(os.path.join(os.getenv("ASST_ROOT"), "render")+"/", ""), name)
            maya.cmds.setAttr("defaultRenderGlobals.imageFilePrefix", p, type="string")
        else:
            p = os.path.join(path.replace(os.path.join(os.getenv("ASST_ROOT"), "render")+\
                                          "/", ""), "<RenderPass", name+"_<RenderPass>")
            p = os.path.join("<RenderPass", name+"_<RenderPass>")
            maya.cmds.setAttr("defaultRenderGlobals.imageFilePrefix", p, type="string")

        dbMeta = {}
        dbMeta["comment"] = "Auto-save of render %s" % str(destSpec)

        ueMayaUtils.saveUtility(sourceSpec, dbMeta=dbMeta)
        ueMayaUtils.saveUtility(sourceSpec)

        if self.renderOpts[0] == 0:
            print "Rendering %s ..." % str(destSpec)
            maya.mel.eval("mayaBatchRender")
        elif self.renderOpts[0] == 1:
            print "Spooling %s ..." % str(destSpec)
        elif self.renderOpts[0] == 2:
            print "Spooling to cloud currently not avaliable"

        self.close()
Пример #14
0
def saveUtility(spec, dbMeta={}, fileType="ma", export=False, animated=False):
    fi = ueMaya.parseFileInfo(maya.cmds.fileInfo(query=True))

    e = ueAssetUtils.getElement(spec)
    if e == {}:
        e = ueCreate.createElement(spec, dbMeta=dbMeta)

    v = ueCreate.createVersion(spec, dbMeta=dbMeta)

    spec.vers = v["version"]

    maPath = v["path"]
    maName = v["file_name"]

    # Load plugins needed for export
    if fileType == "obj":
        maya.cmds.loadPlugin("objExport.so")
    elif fileType == "fbx":
        maya.cmds.loadPlugin("fbxmaya.so")

    # Export or save
    f = os.path.join(maPath, maName + "." + fileType)
    if export:
        if fileType == "fbx":
            maya.mel.eval("FBXExport -s -f \"" + f + "\";")
        else:
            if animated:
                start = int(maya.cmds.playbackOptions(query=True,
                                                      minTime=True))
                end = int(maya.cmds.playbackOptions(query=True, maxTime=True))
                for i in range(start, end + 1):
                    maya.cmds.currentTime(i, edit=True)
                    f = os.path.join(maPath,
                                     "%s.%04d.%s" % (maName, i, fileType))
                    maya.cmds.file(f,
                                   exportSelected=True,
                                   options=__fileTypes__[fileType][1],
                                   type=__fileTypes__[fileType][0])
            else:
                maya.cmds.file(f,
                               exportSelected=True,
                               options=__fileTypes__[fileType][1],
                               type=__fileTypes__[fileType][0])
    else:
        maya.cmds.fileInfo("ueproj", spec.proj)
        maya.cmds.fileInfo("uegrp", spec.grp)
        maya.cmds.fileInfo("ueasst", spec.asst)
        maya.cmds.fileInfo("ueclass", spec.elclass)
        maya.cmds.fileInfo("uetype", spec.eltype)
        maya.cmds.fileInfo("uename", spec.elname)
        maya.cmds.fileInfo("uevers", spec.vers)
        maya.cmds.fileInfo("version_path", maPath)

        maya.cmds.file(rename=f)
        maya.cmds.file(save=True, type=__fileTypes__[fileType][0])

#    if "thumbnail" in p:
#        source = os.path.join(os.getenv("ASST_ROOT"), "tmp", "ueSaveThumbs_"+str(p["thumbnail"])+".png")
#        dest = ueAssetUtils.getThumbnailPath(spec)
#        if not os.path.exists(os.path.dirname(dest)):
#            ueFileUtils.createDir(os.path.dirname(dest))
#        ueFileUtils.moveFile(source, dest)

    print "Saved %s" % spec
Пример #15
0
def saveUtility(spec, dbMeta={}, fileType="ma", export=False, animated=False):
    fi = ueMaya.parseFileInfo(maya.cmds.fileInfo(query=True))

    e = ueAssetUtils.getElement(spec)
    if e == {}:
        e = ueCreate.createElement(spec, dbMeta=dbMeta)

    v = ueCreate.createVersion(spec, dbMeta=dbMeta)

    spec.vers = v["version"]

    maPath = v["path"]
    maName = v["file_name"]

    # Load plugins needed for export
    if fileType == "obj":
        maya.cmds.loadPlugin("objExport.so")
    elif fileType == "fbx":
        maya.cmds.loadPlugin("fbxmaya.so")

    # Export or save
    f = os.path.join(maPath, maName+"."+fileType)
    if export:
        if fileType == "fbx":
            maya.mel.eval("FBXExport -s -f \""+f+"\";")
        else:
            if animated:
                start = int(maya.cmds.playbackOptions(query=True, minTime=True))
                end = int(maya.cmds.playbackOptions(query=True, maxTime=True))
                for i in range(start, end+1):
                    maya.cmds.currentTime(i, edit=True)
                    f = os.path.join(maPath, "%s.%04d.%s" % (maName, i, fileType))
                    maya.cmds.file(f, exportSelected=True,
                                   options=__fileTypes__[fileType][1],
                                   type=__fileTypes__[fileType][0])
            else:
                maya.cmds.file(f, exportSelected=True,
                               options=__fileTypes__[fileType][1],
                               type=__fileTypes__[fileType][0])
    else:
        maya.cmds.fileInfo("ueproj", spec.proj)
        maya.cmds.fileInfo("uegrp", spec.grp)
        maya.cmds.fileInfo("ueasst", spec.asst)
        maya.cmds.fileInfo("ueclass", spec.elclass)
        maya.cmds.fileInfo("uetype", spec.eltype)
        maya.cmds.fileInfo("uename", spec.elname)
        maya.cmds.fileInfo("uevers", spec.vers)
        maya.cmds.fileInfo("version_path", maPath)

        maya.cmds.file(rename=f)
        maya.cmds.file(save=True,
                       type=__fileTypes__[fileType][0])

#    if "thumbnail" in p:
#        source = os.path.join(os.getenv("ASST_ROOT"), "tmp", "ueSaveThumbs_"+str(p["thumbnail"])+".png")
#        dest = ueAssetUtils.getThumbnailPath(spec)
#        if not os.path.exists(os.path.dirname(dest)):
#            ueFileUtils.createDir(os.path.dirname(dest))
#        ueFileUtils.moveFile(source, dest)

    print "Saved %s" % spec
Пример #16
0
# Save the names of our write nodes
writeNodes = []

# For each layer
for t in filesDict:
    # Create the layer list asset
    layerFile = os.path.join(path, "%s_layerList.txt" % t)
    if os.path.exists(layerFile):
        layerFileSpec = context
        layerFileSpec.elclass = "lay"
        layerFileSpec.eltype = "layers"
        layerFileSpec.elname = t

        element = ueAssetUtils.getElement(layerFileSpec)
        if not element:
            element = ueCreate.createElement(layerFileSpec)

        version = ueCreate.createVersion(layerFileSpec)
        layerFileSpec.vers = version["version"]

        f = open(layerFile)
        layers = []
        for layer in f:
            layers.append(layer.strip())
        f.close()

        layerFileDest = os.path.join(version["path"], "%s.lay" % version["file_name"])

        f = open(layerFileDest, "w")
        f.write(json.dumps(layers))
        f.close()
Пример #17
0
def saveUtility(spec, dbMeta={}):
    root = nuke.root()

    e = ueAssetUtils.getElement(spec)
    if e == {}:
        e = ueCreate.createElement(spec, dbMeta=dbMeta)

    v = ueCreate.createVersion(spec, dbMeta=dbMeta)

    spec.vers = v["version"]

    nkPath = v["path"]
    nkName = v["file_name"]
    f = os.path.join(nkPath, nkName+".nk")

    if root.knob("ueproj") == None:
        root.addKnob(nuke.String_Knob("ueproj", "project", spec.proj))
    else:
        root.knob("ueproj").setValue(spec.proj)

    if root.knob("uegrp") == None:
        root.addKnob(nuke.String_Knob("uegrp", "group", spec.grp))
    else:
        root.knob("uegrp").setValue(spec.grp)

    if root.knob("ueasst") == None:
        root.addKnob(nuke.String_Knob("ueasst", "asset", spec.asst))
    else:
        root.knob("ueasst").setValue(spec.asst)

    if root.knob("ueclass") == None:
        root.addKnob(nuke.String_Knob("ueclass", "class", spec.elclass))
    else:
        root.knob("ueclass").setValue(spec.elclass)

    if root.knob("uetype") == None:
        root.addKnob(nuke.String_Knob("uetype", "type", spec.eltype))
    else:
        root.knob("uetype").setValue(spec.eltype)

    if root.knob("uename") == None:
        root.addKnob(nuke.String_Knob("uename", "name", spec.elname))
    else:
        root.knob("uename").setValue(spec.elname)

    if root.knob("uevers") == None:
        root.addKnob(nuke.Int_Knob("uevers", "vers", spec.vers))
        # Nuke bug? Passing a value into Int_Knob doesn't actually set the value
        # on the knob. Calling setValue explicitly to get around this.
        root.knob("uevers").setValue(spec.vers)
    else:
        root.knob("uevers").setValue(spec.vers)

    if root.knob("version_path") == None:
        root.addKnob(nuke.String_Knob("version_path", "version_path", nkPath))
    else:
        root.knob("version_path").setValue(nkPath)

    nuke.scriptSaveAs(f)

    if "thumbnail" in v:
        source = os.path.join(os.getenv("ASST_ROOT"), "tmp", "ueSaveThumbs_"+str(v["thumbnail"])+".png")
        dest = os.path.join(os.getenv("PROJ_ROOT"), "var", "thumbs", spec.grp, spec.asst, nkName+".png")
        if not os.path.exists(os.path.dirname(dest)):
            ueFileUtils.createDir(os.path.dirname(dest))
        ueFileUtils.moveFile(source, dest)

    nuke.tprint("Saved %s" % spec)
Пример #18
0
# Save the names of our write nodes
writeNodes = []

# For each layer
for t in filesDict:
    # Create the layer list asset
    layerFile = os.path.join(path, "%s_layerList.txt" % t)
    if os.path.exists(layerFile):
        layerFileSpec = context
        layerFileSpec.elclass = "lay"
        layerFileSpec.eltype = "layers"
        layerFileSpec.elname = t

        element = ueAssetUtils.getElement(layerFileSpec)
        if not element:
            element = ueCreate.createElement(layerFileSpec)

        version = ueCreate.createVersion(layerFileSpec)
        layerFileSpec.vers = version["version"]

        f = open(layerFile)
        layers = []
        for layer in f:
            layers.append(layer.strip())
        f.close()

        layerFileDest = os.path.join(version["path"],
                                     "%s.lay" % version["file_name"])

        f = open(layerFileDest, "w")
        f.write(json.dumps(layers))