当前位置: 首页>>代码示例>>Python>>正文


Python AssetUtils.getElement方法代码示例

本文整理汇总了Python中ueCore.AssetUtils.getElement方法的典型用法代码示例。如果您正苦于以下问题:Python AssetUtils.getElement方法的具体用法?Python AssetUtils.getElement怎么用?Python AssetUtils.getElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ueCore.AssetUtils的用法示例。


在下文中一共展示了AssetUtils.getElement方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: createElement

# 需要导入模块: from ueCore import AssetUtils [as 别名]
# 或者: from ueCore.AssetUtils import getElement [as 别名]
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)
开发者ID:hdd,项目名称:ue,代码行数:16,代码来源:Create.py

示例2: addFiles

# 需要导入模块: from ueCore import AssetUtils [as 别名]
# 或者: from ueCore.AssetUtils import getElement [as 别名]
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)
开发者ID:hdd,项目名称:ue,代码行数:32,代码来源:ueAddFiles.py

示例3: printInfo

# 需要导入模块: from ueCore import AssetUtils [as 别名]
# 或者: from ueCore.AssetUtils import getElement [as 别名]
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 ""
开发者ID:hdd,项目名称:ue,代码行数:53,代码来源:ueInfo.py

示例4: saveUtility

# 需要导入模块: from ueCore import AssetUtils [as 别名]
# 或者: from ueCore.AssetUtils import getElement [as 别名]
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
开发者ID:hdd,项目名称:ue,代码行数:63,代码来源:Utilities.py

示例5: updateElement

# 需要导入模块: from ueCore import AssetUtils [as 别名]
# 或者: from ueCore.AssetUtils import getElement [as 别名]
def updateElement(spec, dbMeta={}):
    ueClient.client.updateElement(spec, dbMeta)

    return ueAssetUtils.getElement(spec)
开发者ID:hdd,项目名称:ue,代码行数:6,代码来源:Update.py

示例6: open

# 需要导入模块: from ueCore import AssetUtils [as 别名]
# 或者: from ueCore.AssetUtils import getElement [as 别名]
spec.elname = "master"

# 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")
开发者ID:hdd,项目名称:ue,代码行数:33,代码来源:publishCels.py

示例7: save

# 需要导入模块: from ueCore import AssetUtils [as 别名]
# 或者: from ueCore.AssetUtils import getElement [as 别名]
    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()
开发者ID:hdd,项目名称:ue,代码行数:72,代码来源:Render.py

示例8: runRender

# 需要导入模块: from ueCore import AssetUtils [as 别名]
# 或者: from ueCore.AssetUtils import getElement [as 别名]
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:
#.........这里部分代码省略.........
开发者ID:hdd,项目名称:ue,代码行数:103,代码来源:Render.py


注:本文中的ueCore.AssetUtils.getElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。