def ueNewScriptSetup(): root = nuke.root() context = ueSpec.Context() spec = context.spec asset = ueAssetUtils.getAsset(spec) formatName = "ueProjectRes" root.knob("fps").setValue(int(asset["frameRate"])) root.knob("first_frame").setValue(int(asset["startFrame"])) root.knob("last_frame").setValue(int(asset["endFrame"])) x = int(asset["xRes"])+int(asset["xPad"]) y = int(asset["yRes"])+int(asset["yPad"]) nuke.addFormat("%i %i %s" % (x, y, formatName)) # nuke.addFormat("%i %i %i %i %i %i %d %s" % (x, y, int(config["xPad"]), int(config["yPad"]), # int(config["xRes"]), int(config["yRes"]), # float(config["aspectRatio"]), formatName)) root.knob("format").setValue(formatName) os.environ["FRAME_RATE"] = asset["frameRate"] os.environ["FIRST_FRAME"] = asset["startFrame"] os.environ["LAST_FRAME"] = asset["endFrame"]
def ueNewScriptSetup(): context = ueSpec.Context() spec = context.spec asset = ueAssetUtils.getAsset(spec) # Set up renderer - default to Mental Ray loadPlugin("Mayatomr.so") maya.cmds.setAttr("defaultRenderGlobals.currentRenderer", "mentalRay", type="string") # Set up the timeline maya.cmds.playbackOptions(animationStartTime=float(asset["startFrame"]), animationEndTime=float(asset["endFrame"]), minTime=float(asset["startFrame"]), maxTime=float(asset["endFrame"])) x = int(asset["xRes"])+int(asset["xPad"]) y = int(asset["yRes"])+int(asset["yPad"]) # Set up renderGlobals maya.cmds.setAttr("defaultRenderGlobals.outFormatControl", 0) maya.cmds.setAttr("defaultRenderGlobals.animation", 1) maya.cmds.setAttr("defaultRenderGlobals.startFrame", float(asset["startFrame"])) maya.cmds.setAttr("defaultRenderGlobals.endFrame", float(asset["endFrame"])) maya.cmds.setAttr("defaultResolution.pixelAspect", float(asset["aspectRatio"])) maya.cmds.setAttr("defaultResolution.deviceAspectRatio", float(x)/float(y)) maya.cmds.setAttr("defaultResolution.width", x) maya.cmds.setAttr("defaultResolution.height", y) os.environ["FRAME_RATE"] = asset["frameRate"] os.environ["FIRST_FRAME"] = asset["startFrame"] os.environ["LAST_FRAME"] = asset["endFrame"]
def createAsset(spec, asstType="default", dbMeta={}): asset = ueAssetUtils.getAsset(spec) if asset: return asset asset["name"] = spec.asst asset["asset_type"] = asstType asset["created_by"] = getpass.getuser() for m in dbMeta: asset[m] = dbMeta[m] ueClient.client.saveAsset(spec, asset) return ueAssetUtils.getAsset(spec)
def ueNewScriptSetup(): root = nuke.root() context = ueSpec.Context() spec = context.spec asset = ueAssetUtils.getAsset(spec) formatName = "ueProjectRes" root.knob("fps").setValue(int(asset["frameRate"])) root.knob("first_frame").setValue(int(asset["startFrame"])) root.knob("last_frame").setValue(int(asset["endFrame"])) x = int(asset["xRes"]) + int(asset["xPad"]) y = int(asset["yRes"]) + int(asset["yPad"]) nuke.addFormat("%i %i %s" % (x, y, formatName)) # nuke.addFormat("%i %i %i %i %i %i %d %s" % (x, y, int(config["xPad"]), int(config["yPad"]), # int(config["xRes"]), int(config["yRes"]), # float(config["aspectRatio"]), formatName)) root.knob("format").setValue(formatName) os.environ["FRAME_RATE"] = asset["frameRate"] os.environ["FIRST_FRAME"] = asset["startFrame"] os.environ["LAST_FRAME"] = asset["endFrame"]
def listAssets(): for asset in sorted(ueAssetUtils.getAssetsList(settings["spec"])): settings["spec"].asst = asset asset = ueAssetUtils.getAsset(settings["spec"]) printLine = asset["name"] if "paths" in settings: printLine += " -> %s" % asset["path"] print printLine
def printInfo(): if "spec" not in info: print "ERROR: Spec not set" sys.exit(2) spec = ueSpec.Spec(info["spec"]) if spec.grp == None: # Project info assetType = "project" assetInfo = ueAssetUtils.getProject(spec) elif spec.asst == None: # Group info assetType = "group" assetInfo = ueAssetUtils.getGroup(spec) elif spec.elclass == None and \ spec.eltype == None and \ spec.elname == None: # Asset info assetType = "asset" assetInfo = ueAssetUtils.getAsset(spec) elif spec.vers == None: # Element info assetType = "element" assetInfo = ueAssetUtils.getElement(spec) assetInfo = assetInfo[spec.elclass][spec.eltype][spec.elname] elif spec.elpass == None: # Version info assetType = "version" assetInfo = ueAssetUtils.getVersions(spec)[int(spec.vers)-1] else: print "ERROR: Could not identify spec as a valid element" sys.exit(2) print "Information on %s:\n%s\n" % (assetType, str(info["spec"])) for a in sorted(assetInfo): # Get a padding value so the key/value columns will be neatly aligned spacePadding = 28-len(a) # Parse the version and datetime info correctly if a == "versions": assetInfo[a] = len(assetInfo[a]) elif a in ["created_at", "updated_at"]: assetInfo[a] = ueCore.formatDatetime(str(assetInfo[a])) # Get rid of the keys with _id because they're database stuff if not re.match(".*_id$", a): print "%s:%s%s" % (a, " "*spacePadding, str(assetInfo[a])) print ""
def printInfo(): if "spec" not in info: print "ERROR: Spec not set" sys.exit(2) spec = ueSpec.Spec(info["spec"]) if spec.grp == None: # Project info assetType = "project" assetInfo = ueAssetUtils.getProject(spec) elif spec.asst == None: # Group info assetType = "group" assetInfo = ueAssetUtils.getGroup(spec) elif spec.elclass == None and \ spec.eltype == None and \ spec.elname == None: # Asset info assetType = "asset" assetInfo = ueAssetUtils.getAsset(spec) elif spec.vers == None: # Element info assetType = "element" assetInfo = ueAssetUtils.getElement(spec) assetInfo = assetInfo[spec.elclass][spec.eltype][spec.elname] elif spec.elpass == None: # Version info assetType = "version" assetInfo = ueAssetUtils.getVersions(spec)[int(spec.vers) - 1] else: print "ERROR: Could not identify spec as a valid element" sys.exit(2) print "Information on %s:\n%s\n" % (assetType, str(info["spec"])) for a in sorted(assetInfo): # Get a padding value so the key/value columns will be neatly aligned spacePadding = 28 - len(a) # Parse the version and datetime info correctly if a == "versions": assetInfo[a] = len(assetInfo[a]) elif a in ["created_at", "updated_at"]: assetInfo[a] = ueCore.formatDatetime(str(assetInfo[a])) # Get rid of the keys with _id because they're database stuff if not re.match(".*_id$", a): print "%s:%s%s" % (a, " " * spacePadding, str(assetInfo[a])) print ""
def createScript(self): job = {} if self.run == "nuke": ext = "nk" proj = ueAssetUtils.getProject(self.destSpec) asst = ueAssetUtils.getAsset(self.destSpec) versions = ueAssetUtils.getVersions(self.sourceSpec) version = versions[len(versions) - 1] p = os.path.join(version["path"], version["file_name"] + "." + ext) for f in range(self.frame_start, self.frame_end + 1): frame = {} if self.run == "nuke": frame["cmd"] = "nuke -x -V -f -X %s -F %i-%i %s" % (",".join( self.options["writeNode"]), f, f, p) frame["proj"] = self.destSpec.proj frame["grp"] = self.destSpec.grp frame["asst"] = self.destSpec.asst frame["proj_root"] = proj["path"] frame["asst_root"] = asst["path"] job[f] = frame versions = ueAssetUtils.getVersions(self.destSpec) version = versions[len(versions) - 1] p = os.path.join( asst["path"], "tmp", "drQueue", version["file_name"] + "." + str(int(time.time())) + ".dq") if not os.path.exists(os.path.dirname(p)): import ueCore.FileUtils as ueFileUtils ueFileUtils.createDir(os.path.dirname(p)) try: f = open(p, "w") f.write(json.dumps(job, sort_keys=True, indent=4)) f.close() except IOError, e: print "ERROR: Creating job script '%s' (%s)" % (p, e) sys.exit(2)
def createScript(self): job = {} if self.run == "nuke": ext = "nk" proj = ueAssetUtils.getProject(self.destSpec) asst = ueAssetUtils.getAsset(self.destSpec) versions = ueAssetUtils.getVersions(self.sourceSpec) version = versions[len(versions)-1] p = os.path.join(version["path"], version["file_name"]+"."+ext) for f in range(self.frame_start, self.frame_end+1): frame = {} if self.run == "nuke": frame["cmd"] = "nuke -x -V -f -X %s -F %i-%i %s" % (",".join(self.options["writeNode"]), f, f, p) frame["proj"] = self.destSpec.proj frame["grp"] = self.destSpec.grp frame["asst"] = self.destSpec.asst frame["proj_root"] = proj["path"] frame["asst_root"] = asst["path"] job[f] = frame versions = ueAssetUtils.getVersions(self.destSpec) version = versions[len(versions)-1] p = os.path.join(asst["path"], "tmp", "drQueue", version["file_name"]+"."+str(int(time.time()))+".dq") if not os.path.exists(os.path.dirname(p)): import ueCore.FileUtils as ueFileUtils ueFileUtils.createDir(os.path.dirname(p)) try: f = open(p, "w") f.write(json.dumps(job, sort_keys=True, indent=4)) f.close() except IOError, e: print "ERROR: Creating job script '%s' (%s)" % (p, e) sys.exit(2)
def ueNewScriptSetup(): context = ueSpec.Context() spec = context.spec asset = ueAssetUtils.getAsset(spec) # Set up renderer - default to Mental Ray loadPlugin("Mayatomr.so") maya.cmds.setAttr("defaultRenderGlobals.currentRenderer", "mentalRay", type="string") # Set up the timeline maya.cmds.playbackOptions(animationStartTime=float(asset["startFrame"]), animationEndTime=float(asset["endFrame"]), minTime=float(asset["startFrame"]), maxTime=float(asset["endFrame"])) x = int(asset["xRes"]) + int(asset["xPad"]) y = int(asset["yRes"]) + int(asset["yPad"]) # Set up renderGlobals maya.cmds.setAttr("defaultRenderGlobals.outFormatControl", 0) maya.cmds.setAttr("defaultRenderGlobals.animation", 1) maya.cmds.setAttr("defaultRenderGlobals.startFrame", float(asset["startFrame"])) maya.cmds.setAttr("defaultRenderGlobals.endFrame", float(asset["endFrame"])) maya.cmds.setAttr("defaultResolution.pixelAspect", float(asset["aspectRatio"])) maya.cmds.setAttr("defaultResolution.deviceAspectRatio", float(x) / float(y)) maya.cmds.setAttr("defaultResolution.width", x) maya.cmds.setAttr("defaultResolution.height", y) os.environ["FRAME_RATE"] = asset["frameRate"] os.environ["FIRST_FRAME"] = asset["startFrame"] os.environ["LAST_FRAME"] = asset["endFrame"]
def changeAsset(): spec = ueSpec.Spec(sys.argv[-1]) if not spec.proj in ueAssetUtils.getProjectsList(): print "ERROR: Project does not exist" sys.exit(2) if not spec.grp in ueAssetUtils.getGroupsList(spec): print "ERROR: Group does not exist" sys.exit(2) if not spec.asst in ueAssetUtils.getAssetsList(spec): print "ERROR: Asset does not exist" sys.exit(2) project = ueAssetUtils.getProject(spec) asset = ueAssetUtils.getAsset(spec) print "export PROJ=%s; " % spec.proj print "export GRP=%s; " % spec.grp print "export ASST=%s; " % spec.asst print "export PROJ_ROOT=%s; " % project["path"] print "export ASST_ROOT=%s" % asset["path"]
def printTree(): if "spec" not in info: print "ERROR: Spec not set" sys.exit(2) spec = ueSpec.Spec(info["spec"]) print "Asset tree on asset:" print spec print "|" groups = ueAssetUtils.getGroupsList(spec) lastGroup = "|" for g, group in enumerate(sorted(groups)): spec.grp = group group = ueAssetUtils.getGroup(spec) if g == len(groups) - 1: lastGroup = " " groupSpaceCount = 34 printLine = "+-+-> %s" % group["name"] printLine += (groupSpaceCount - len(printLine)) * " " if info["time"]: printLine += "%s - %s" % (str(group["startFrame"]), str(group["endFrame"])) groupSpaceCount += 10 printLine += (groupSpaceCount - len(printLine)) * " " if info["path"]: printLine += group["path"] groupSpaceCount += 30 printLine += (groupSpaceCount - len(printLine)) * " " if info["date"]: printLine += "%s, %s" % ( ueCore.formatDatetime(group["created_at"]), ueCore.formatDatetime(group["updated_at"]), ) groupSpaceCount += 38 printLine += (groupSpaceCount - len(printLine)) * " " if info["user"]: printLine += group["created_by"] print printLine assets = ueAssetUtils.getAssetsList(spec) for asset in sorted(assets): spec.asst = asset asset = ueAssetUtils.getAsset(spec) assetSpaceCount = 34 printLine = "%s +---> %s" % (lastGroup, asset["name"]) printLine += (assetSpaceCount - len(printLine)) * " " if info["time"]: printLine += "%s - %s" % (str(asset["startFrame"]), str(asset["endFrame"])) assetSpaceCount += 10 printLine += (assetSpaceCount - len(printLine)) * " " if info["path"]: printLine += group["path"] assetSpaceCount += 30 printLine += (assetSpaceCount - len(printLine)) * " " if info["date"]: printLine += "%s, %s" % ( ueCore.formatDatetime(asset["created_at"]), ueCore.formatDatetime(asset["updated_at"]), ) assetSpaceCount += 38 printLine += (assetSpaceCount - len(printLine)) * " " if info["user"]: printLine += asset["created_by"] print printLine print ""
def updateAsset(spec, asstType="default", dbMeta={}): ueClient.client.updateAsset(spec, dbMeta) return ueAssetUtils.getAsset(spec)