def newGeo(hpath):
    templateNode = hou.node(hpath).createNode("geometryTemplate")
    alist = listContainers()
    resp = ui.inputWindow("Enter the New Operator Label", wtitle="OTL Label")
    filename = str()
    if resp != None and resp.strip() != "":
        name = formatName(resp)
        filename = name.replace(" ", "_")
        templateNode.setName(filename, unique_name=True)
    answer = ui.listWindow(alist, wmessage="Select Container Asset this belongs to:")
    if not answer:
        ui.infoWindow(
            "Geometry must be associated with a container asset! Geometry asset not created.",
            msev=messageSeverity.Error,
        )
        templateNode.destroy()
        return
    answer = answer[0]
    sdir = "$JOB/PRODUCTION/assets/"
    gfile = ui.fileChooser(
        start_dir=sdir + alist[answer] + "/geo",
        wtitle="Choose Geometry",
        mode=fileMode.Read,
        extensions="*.bjson, *.obj",
    )
    if len(gfile) > 4 and gfile[:4] != "$JOB":
        ui.infoWindow(
            "Path must start with '$JOB'. Default geometry used instead.",
            wtitle="Path Name",
            msev=messageSeverity.Error,
        )
        templateNode.destroy()
    elif gfile != "":
        hou.parm(templateNode.path() + "/read_file/file").set(gfile)
def rename(node = None):
    """Renames the selected node. EXACTLY ONE node may be selected, and it MUST be a digital asset.
        The node must already exist in the database.
    """
    updateDB()
    if node != None:
        if not isDigitalAsset(node):
            ui.infoWindow("Not a Digital Asset.")
        else:
            if isContainer(node):
                oldlibraryPath = node.type().definition().libraryFilePath()
                oldfilename = os.path.basename(oldlibraryPath)
                oldAssetName = oldfilename.split('.')[0]
                assetDirPath = os.path.join(ASSETSDIR, oldAssetName)

                dependents = getAssetDependents(oldAssetName)

                if dependents:
                    ui.infoWindow('The following assets are depenent on this asset: \n\n'+printList(dependents)+'\nModify these assets first before attempting to rename again!!', wtitle='Can NOT rename!', msev=messageSeverity.Error)
                    return

                info = getFileInfo(oldfilename)
                if not info[2]:
                    if ui.passwordWindow('r3n@m3p@ssw0rd', wmessage='Enter the rename password...'):
                        resp = ui.inputWindow("Enter the New Operator Label", wtitle="Rename OTL")
                        if resp != None and resp.strip() != '':
                            name = formatName(resp)
                            newfilename = name.replace(' ', '_')
                            newfilepath = os.path.join(OTLDIR, newfilename+'.otl')
                            if os.path.exists(newfilepath):
                                ui.infoWindow("Asset by that name already exists. Cannot rename asset.", wtitle='Asset Name', msev=messageSeverity.Error)
                            elif not amu.canRename(assetDirPath, newfilename):
                                ui.infoWindow("Asset checked out in Maya. Cannot rename asset.", wtitle='Asset Name', msev=messageSeverity.Error)
                            else:
                                node.type().definition().copyToHDAFile(newfilepath, new_name=newfilename, new_menu_name=name)
                                hou.hda.installFile(newfilepath, change_oplibraries_file=True)
                                newnode = hou.node(determineHPATH()).createNode(newfilename)
                                node.destroy()
                                hou.hda.uninstallFile(oldlibraryPath, change_oplibraries_file=False)
                                subprocess.check_call( ['rm','-f',oldlibraryPath] )
                                amu.renameAsset(assetDirPath, newfilename)
                else:
                    logname, realname = amu.lockedBy(info[3].encode('utf-8'))
                    whoLocked = 'User Name: ' + logname + '\nReal Name: ' + realname + '\n'
                    errstr = 'Cannot checkout asset. Locked by: \n\n' + whoLocked
                    ui.infoWindow(errstr, wtitle='Asset Locked', msev=messageSeverity.Error)
    else:
        ui.infoWindow("Select EXACTLY one node.")
Beispiel #3
0
def rename(node = None):
    """Renames the selected node. EXACTLY ONE node may be selected, and it MUST be a digital asset.
        The node must already exist in the database.
    """
    updateDB()
    if node != None:
        if not isDigitalAsset(node):
            ui.infoWindow("Not a Digital Asset.")
        else:
            if isContainer(node):
                oldlibraryPath = node.type().definition().libraryFilePath()
                oldfilename = os.path.basename(oldlibraryPath)
                oldAssetName = oldfilename.split('.')[0]
                assetDirPath = os.path.join(ASSETSDIR, oldAssetName)

                dependents = getAssetDependents(oldAssetName)

                if dependents:
                    ui.infoWindow('The following assets are depenent on this asset: \n\n'+printList(dependents)+'\nModify these assets first before attempting to rename again!!', wtitle='Can NOT rename!', msev=messageSeverity.Error)
                    return

                info = getFileInfo(oldfilename)
                if not info[2]:
                    if ui.passwordWindow('r3n@m3p@ssw0rd', wmessage='Enter the rename password...'):
                        resp = ui.inputWindow("Enter the New Operator Label", wtitle="Rename OTL")
                        if resp != None and resp.strip() != '':
                            name = formatName(resp)
                            newfilename = name.replace(' ', '_')
                            newfilepath = os.path.join(OTLDIR, newfilename+'.otl')
                            if os.path.exists(newfilepath):
                                ui.infoWindow("Asset by that name already exists. Cannot rename asset.", wtitle='Asset Name', msev=messageSeverity.Error)
                            elif not amu.canRename(assetDirPath, newfilename):
                                ui.infoWindow("Asset checked out in Maya. Cannot rename asset.", wtitle='Asset Name', msev=messageSeverity.Error)
                            else:
                                node.type().definition().copyToHDAFile(newfilepath, new_name=newfilename, new_menu_name=name)
                                hou.hda.installFile(newfilepath, change_oplibraries_file=True)
                                newnode = hou.node(determineHPATH()).createNode(newfilename)
                                node.destroy()
                                hou.hda.uninstallFile(oldlibraryPath, change_oplibraries_file=False)
                                subprocess.check_call( ['rm','-f',oldlibraryPath] )
                                amu.renameAsset(assetDirPath, newfilename)
                else:
                    logname, realname = amu.lockedBy(info[3].encode('utf-8'))
                    whoLocked = 'User Name: ' + logname + '\nReal Name: ' + realname + '\n'
                    errstr = 'Cannot checkout asset. Locked by: \n\n' + whoLocked
                    ui.infoWindow(errstr, wtitle='Asset Locked', msev=messageSeverity.Error)
    else:
        ui.infoWindow("Select EXACTLY one node.")
def newContainer(hpath):
    templateNode = hou.node(hpath).createNode("containerTemplate")
    templateNode.hide(True)
    resp = ui.inputWindow("Enter the New Operator Label", wtitle="OTL Label")
    if resp != None and resp.strip() != '':
        name = formatName(resp)
        filename = name.replace(' ', '_')
        newfilepath = os.path.join(OTLDIR, filename+'.otl')
        if not os.path.exists(newfilepath):
            # create file heirarchy if container asset
            amu.createNewAssetFolders(ASSETSDIR, filename)
            templateNode.type().definition().copyToHDAFile(newfilepath, new_name=filename, new_menu_name=name)
            hou.hda.installFile(newfilepath, change_oplibraries_file=True)
            newnode = hou.node(hpath).createNode(filename)
        else:
            ui.infoWindow("Asset by that name already exists. Cannot create asset.", wtitle='Asset Name', msev=messageSeverity.Error)
        
    # clean up
    templateNode.destroy()
Beispiel #5
0
def newContainer(hpath):
    templateNode = hou.node(hpath).createNode("containerTemplate")
    templateNode.hide(True)
    resp = ui.inputWindow("Enter the New Operator Label", wtitle="OTL Label")
    if resp != None and resp.strip() != '':
        name = formatName(resp)
        filename = name.replace(' ', '_')
        newfilepath = os.path.join(OTLDIR, filename+'.otl')
        if not os.path.exists(newfilepath):
            # create file heirarchy if container asset
            amu.createNewAssetFolders(ASSETSDIR, filename)
            templateNode.type().definition().copyToHDAFile(newfilepath, new_name=filename, new_menu_name=name)
            hou.hda.installFile(newfilepath, change_oplibraries_file=True)
            fileutil.clobberPermissions(newfilepath)
            newnode = hou.node(hpath).createNode(filename)
        else:
            ui.infoWindow("Asset by that name already exists. Cannot create asset.", wtitle='Asset Name', msev=messageSeverity.Error)
        
    # clean up
    templateNode.destroy()
Beispiel #6
0
def newGeo(hpath):
    templateNode = hou.node(hpath).createNode("geometryTemplate")
    alist = listContainers()
    resp = ui.inputWindow("Enter the New Operator Label", wtitle="OTL Label")
    filename = str()
    if resp != None and resp.strip() != '':
        name = formatName(resp)
        filename = name.replace(' ', '_')
        templateNode.setName(filename, unique_name=True)
    answer = ui.listWindow(alist, wmessage='Select Container Asset this belongs to:')
    if not answer:
        ui.infoWindow("Geometry must be associated with a container asset! Geometry asset not created.", msev=messageSeverity.Error)
        templateNode.destroy()
        return
    answer = answer[0]
    sdir = '$JOB/PRODUCTION/assets/'
    gfile = ui.fileChooser(start_dir=sdir + alist[answer]+'/geo', wtitle='Choose Geometry', mode=fileMode.Read, extensions='*.bjson, *.obj')
    if len(gfile) > 4 and gfile[:4] != '$JOB':
        ui.infoWindow("Path must start with '$JOB'. Default geometry used instead.", wtitle='Path Name', msev=messageSeverity.Error)
        templateNode.destroy()
    elif gfile != '':
        hou.parm(templateNode.path() + '/read_file/file').set(gfile)
def rename():
    """Renames the selected node. EXACTLY ONE node may be selected, and it MUST be a digital asset.
        The node must already exist in the database.
    """
    updateDB()
    node = getSelectedNode()
    if node != None:
        if not isDigitalAsset(node):
            ui.infoWindow("Not a Digital Asset.")
        else:
            if isContainer(node):
                oldlibraryPath = node.type().definition().libraryFilePath()
                oldfilename = os.path.basename(oldlibraryPath)
                oldAssetName = oldfilename.split('.')[0]
                assetDirPath = os.path.join(ASSETSDIR, oldAssetName)
                info = getFileInfo(oldfilename)
                if not info[2]:
                    if ui.passwordWindow('r3n@m3p@ssw0rd', wmessage='Enter the rename password...'):
                        resp = ui.inputWindow("Enter the New Operator Label", wtitle="Rename OTL")
                        if resp != None and resp.strip() != '':
                            name = formatName(resp)
                            newfilename = name.replace(' ', '_')
                            newfilepath = os.path.join(OTLDIR, newfilename+'.otl')
                            if os.path.exists(newfilepath):
                                ui.infoWindow("Asset by that name already exists. Cannot rename asset.", wtitle='Asset Name', msev=messageSeverity.Error)
                            elif not amu.canRename(assetDirPath, newfilename):
                                ui.infoWindow("Asset checked out in Maya. Cannot rename asset.", wtitle='Asset Name', msev=messageSeverity.Error)
                            else:
                                node.type().definition().copyToHDAFile(newfilepath, new_name=newfilename, new_menu_name=name)
                                hou.hda.installFile(newfilepath, change_oplibraries_file=True)
                                newnode = hou.node(determineHPATH()).createNode(newfilename)
                                node.destroy()
                                hou.hda.uninstallFile(oldlibraryPath, change_oplibraries_file=False)
                                os.system('rm -f '+oldlibraryPath)
                                amu.renameAsset(assetDirPath, newfilename)
                else:
                    ui.infoWindow(lockedBy(info[3].encode('utf-8')))
    else:
        ui.infoWindow("Select EXACTLY one node.")