本文整理汇总了Python中ueCore.AssetUtils类的典型用法代码示例。如果您正苦于以下问题:Python AssetUtils类的具体用法?Python AssetUtils怎么用?Python AssetUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AssetUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: listAssets
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
示例2: printInfo
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 ""
示例3: createElement
def createElement(spec, dbMeta={}):
element = ueAssetUtils.getElement(spec)
if element:
return element
element["created_by"] = getpass.getuser()
for m in dbMeta:
element[m] = dbMeta[m]
ueClient.client.saveElement(spec, element)
return ueAssetUtils.getElement(spec)
示例4: createProject
def createProject(spec, dbMeta={}):
project = ueAssetUtils.getProject(spec)
if project:
return project
project["name"] = spec.proj
project["created_by"] = getpass.getuser()
for m in dbMeta:
project[m] = dbMeta[m]
ueClient.client.saveProject(spec, project)
return ueAssetUtils.getProject(spec)
示例5: createAsset
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)
示例6: createGroup
def createGroup(spec, grpType="default", dbMeta={}):
group = ueAssetUtils.getGroup(spec)
if group:
return group
group["name"] = spec.grp
group["group_type"] = grpType
group["created_by"] = getpass.getuser()
for m in dbMeta:
group[m] = dbMeta[m]
ueClient.client.saveGroup(spec, group)
return ueAssetUtils.getGroup(spec)
示例7: ueNewScriptSetup
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"]
示例8: getReadGeoPath
def getReadGeoPath():
n = nuke.thisNode()
spec = 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(),
n.knob("vers").value())
p = os.path.join(os.getenv("UE_PATH"), "lib",
"placeholders", "nuke.obj")
if not spec.proj == "" and not spec.grp == "" and \
not spec.asst == "" and not spec.elclass == "" and \
not spec.eltype == "" and not spec.elname == "" and \
not spec.vers == "":
versions = ueAssetUtils.getVersions(spec)
if int(spec.vers) > len(versions):
return p
v = versions[int(spec.vers)-1]
if v:
files = glob.glob(os.path.join(v["path"], v["file_name"]+"*.obj"))
if len(files) < 1:
return p
ext = files[0].split(".")[-1]
if len(files) == 1:
p = os.path.join(v["path"], v["file_name"]+"."+ext)
else:
p = os.path.join(v["path"], v["file_name"]+".%04d."+ext)
# p = os.path.join(v["path"], elpassDir,
# v["file_name"]+elpassFile+".%04d."+ext)
return p
示例9: getUeConstant
def getUeConstant():
n = nuke.thisNode()
spec = 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(),
n.knob("vers").value())
if not spec.proj == "" and not spec.grp == "" and \
not spec.asst == "" and not spec.elclass == "" and \
not spec.eltype == "" and not spec.elname == "" and \
not spec.vers == "":
versions = ueAssetUtils.getVersions(spec)
if int(spec.vers) > len(versions):
return
v = versions[int(spec.vers)-1]
if v:
layerFile = os.path.join(v["path"], "%s.col" % v["file_path"])
if os.path.exists(layerFile):
f = open(layerFile)
palette = json.loads(layerfile.read())
f.close()
if spec.elname in palette:
colour.knob("color").setValue(palette[spec.elname][0], 0)
colour.knob("color").setValue(palette[spec.elname][1], 1)
colour.knob("color").setValue(palette[spec.elname][2], 2)
colour.knob("color").setValue(1.0, 3)
示例10: loadElements
def loadElements(self):
global asst
asst = str(self.asstMenu.currentText())
spec = ueSpec.Spec(proj, grp, asst)
self.elements = ueAssetUtils.getElements(spec)
# self.eltypeList.clear()
self.loadTypes()
示例11: updateVersInfo
def updateVersInfo(self):
try:
ver = self.versions[int(vers) - 1]
spec = ueSpec.Spec(proj, grp, asst, elclass, eltype, elname, vers, elpass)
self.verCreatedBy.setText(ver["created_by"])
self.verCreatedAt.setText(ueCore.formatDatetime(ver["created_at"]))
files = glob.glob(os.path.join(ver["path"], ver["file_name"] + "*"))
self.verFilesList.clear()
for f in sorted(files):
self.verFilesList.addItem(QtGui.QListWidgetItem(os.path.basename(f)))
if "comment" in ver:
self.verComment.setText(ver["comment"])
else:
self.verComment.setText("N/A")
if "thumbnail" in ver:
spec = ueSpec.Spec(proj, grp, asst, elclass, eltype, elname, vers)
f = ueAssetUtils.getThumbnailPath(spec)
img = QtGui.QImage(f)
imgs = img.scaled(200, 80, aspectRatioMode=QtCore.Qt.KeepAspectRatio)
self.verThumb.setPixmap(QtGui.QPixmap.fromImage(imgs))
else:
img = QtGui.QImage(os.path.join(os.getenv("UE_PATH"), "lib", "placeholders", "thumbnail.png"))
imgs = img.scaled(200, 80, aspectRatioMode=QtCore.Qt.KeepAspectRatio)
self.verThumb.setPixmap(QtGui.QPixmap.fromImage(imgs))
except IndexError:
pass
示例12: addFiles
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)
示例13: loadLayerLists
def loadLayerLists(self):
elements = ueAssetUtils.getElements(ueSpec.Spec(proj, grp, asst))
self.layerListPickerBox.clear()
if __layerClass__ in elements:
if __layerType__ in elements[__layerClass__]:
for layerList in sorted(elements[__layerClass__][__layerType__]):
self.layerListPickerBox.addItem(layerList)
示例14: loadElements
def loadElements(self):
global asst, elements
asst = str(self.asstMenu.currentText())
elements = ueAssetUtils.getElements(ueSpec.Spec(proj, grp, asst))
self.animationTab.reload()
self.backgroundTab.reload()
self.renderTab.reload()
示例15: createVersion
def createVersion(spec, dbMeta={}, layer=None):
version = {}
spec.vers = len(ueAssetUtils.getVersions(spec))+1
version["version"] = spec.vers
version["created_by"] = getpass.getuser()
for m in dbMeta:
version[m] = dbMeta[m]
if not layer == None:
p = os.path.join(version["path"])
ueClient.client.saveVersion(spec, version)
return ueAssetUtils.getVersions(spec)[spec.vers-1]