Ejemplo n.º 1
0
def newContainer(hpath):
    templateNode = hou.node(hpath).createNode("containerTemplate")
    templateNode.hide(True)
    # resp = ui.inputWindow("Enter the New Operator Label", wtitle="OTL Label")
    response = hou.ui.readInput("Enter the New Operator Label", buttons=("Ok", "Cancel"), title="OTL Label")
    if response[0] == 0:
        name = response[1]
    else:
        name = None
    if name != None and name.strip() != "":
        name = formatName(name)
        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:
            hou.ui.displayMessage(
                "Asset by that name already exists. Cannot create asset.",
                title="Asset Name",
                severity=hou.severityType.Error,
            )

    # clean up
    templateNode.destroy()
Ejemplo n.º 2
0
def copyToOtlDir(node, filename, newName, newDef):
    """Moves the .otl file out of the USERDIR into the OTLDIR and removes it from USERDIR.
        Changes the oplibrary to the one in OTLDIR."""
    newfilepath = os.path.join(OTLDIR, filename)
    oldfilepath = os.path.join(USERDIR, filename)
    node.type().definition().copyToHDAFile(newfilepath, new_name=newName, new_menu_name=newDef)
    fileutil.clobberPermissions(newfilepath)
    switchOPLibraries(oldfilepath, newfilepath)
Ejemplo n.º 3
0
def copyToUsrDir(node, filename):
    """Copies the .otl file from OTLDIR to USERDIR
        Changes the oplibrary to the one in USERDIR"""
    if not os.path.exists(USERDIR):
        os.mkdir(USERDIR)
    newfilepath = os.path.join(USERDIR, filename)
    oldfilepath = os.path.join(OTLDIR, filename)
    node.type().definition().copyToHDAFile(newfilepath)
    fileutil.clobberPermissions(newfilepath)
    switchOPLibraries(oldfilepath, newfilepath)
Ejemplo n.º 4
0
def newContainer(hpath):
    templateNode = hou.node(hpath).createNode("containerTemplate")
    templateNode.hide(True)
    # resp = ui.inputWindow("Enter the New Operator Label", wtitle="OTL Label")
    response = hou.ui.readInput("Enter the New Operator Label",
                                buttons=('Ok', 'Cancel'),
                                title="OTL Label")
    if response[0] == 0:
        name = response[1]
    else:
        name = None
    if name != None and name.strip() != '':
        name = hou_asset_mgr.formatName(name)
        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)

            newversiondir = os.path.join(ASSETSDIR, filename + '/otl')
            print "dir " + newversiondir
            newversionpath = os.path.join(newversiondir,
                                          'src/v000/' + filename + '.otl')
            print "path " + newversionpath
            templateNode.type().definition().copyToHDAFile(newversionpath,
                                                           new_name=filename,
                                                           new_menu_name=name)
            stablepath = amu.install(newversiondir, newversionpath)
            fileutil.clobberPermissions(stablepath)
            os.symlink(stablepath, newfilepath)
            hou.hda.installFile(newfilepath, change_oplibraries_file=True)
            newnode = hou.node(hpath).createNode(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:
            hou.ui.displayMessage(
                "Asset by that name already exists. Cannot create asset.",
                title='Asset Name',
                severity=hou.severityType.Error)

    # clean up
    templateNode.destroy()
Ejemplo n.º 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")
    response = hou.ui.readInput("Enter the New Operator Label", buttons=('Ok', 'Cancel'), title="OTL Label")
    if response[0]==0:
        name = response[1]
    else:
        name = None
    if name != None and name.strip() != '':
        name = hou_asset_mgr.formatName(name)
        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)

            newversiondir = os.path.join(ASSETSDIR, filename+'/otl')
            print "dir " + newversiondir
            newversionpath = os.path.join(newversiondir, 'src/v000/'+filename+'.otl')
            print "path " + newversionpath
            templateNode.type().definition().copyToHDAFile(newversionpath, new_name=filename, new_menu_name=name)
            stablepath = amu.install(newversiondir, newversionpath)
            fileutil.clobberPermissions(stablepath)
            os.symlink(stablepath, newfilepath)
            hou.hda.installFile(newfilepath, change_oplibraries_file=True)
            newnode = hou.node(hpath).createNode(filename)
            
            # Then we will call the set_permissions shell script to see if this will fix our issue.
            set_permissions_path = JOB+"/papa-tools/set_permissions.sh"

            subprocess.call([set_permissions_path])

            # 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:
            hou.ui.displayMessage("Asset by that name already exists. Cannot create asset.", title='Asset Name', severity=hou.severityType.Error)
        
    # clean up
    templateNode.destroy()
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()
Ejemplo n.º 7
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()