def newTexture():
    # Get a list of assets 
    assetList = glob.glob(os.path.join(os.environ['ASSETS_DIR'], '*'))
    selections = []
    for aL in assetList:
        # basename takes last folder in path.
        selections.append(os.path.basename(aL)) 
        # sort alphabetically
    selections.sort()
    answer = ui.listWindow(selections, wmessage='Choose an asset to add/update textures for')
    if answer:
        answer = answer[0]
        assetName = selections[answer]
        assetImageDir = os.path.join(os.environ['ASSETS_DIR'], assetName, 'images')

        # Direct user to geometry file path and have them choose the correct one
        sdir = '$JOB/PRODUCTION/assets/'+assetName+'/geo/bjsonFiles'
        geoPath = ui.fileChooser(start_dir=sdir, wtitle='Choose Asset Geometry for Texture', mode=fileMode.Read, extensions='*.bjson, *.obj')
        geoName, ext = os.path.splitext(os.path.basename(geoPath))

        # Show a list of shading passes
        shadingPassList = ['diffuse','specular','bump','scalar_displacement','vector_displacement', 'opacity', 'single_SSS', 'multi_SSS', 'other']
        answer = ui.listWindow(shadingPassList, wmessage='Which texture will you be creating/updating?')
        if answer: 
            answer = answer[0]
            shadingPass = shadingPassList[answer]

            # Allow user to choose texture map in user local directory   
            userDirectory = os.environ['USER_DIR']
            userTextureMap = ui.fileChooser(start_dir=userDirectory, wtitle='Browse to the Texture Map in your User Directory', image=True, extensions='*.jpg,*.jpeg,*.tiff,*.tif,*.png,*.exr') 
            #Allow user to search for texture in any directory
            userTextureMap = os.path.expandvars(userTextureMap)

            # Set Variables for texture paths
            newTexture = '/tmp/newTexture.png'
            convertedTexture = '/tmp/convertedTexture.png'
            finalTexture = '/tmp/finalTexture.exr'

            # Change to 16 bits and convert to png 
            os.system('iconvert -d 16 ' +userTextureMap+ newTexture)
        
            # Gamma correct for linear workflow
            if shadingPass == 'diffuse' or shadingPass == 'specular' or shadingPass == 'single_SSS' or shadingPass == 'multi_SSS' or shadingPass == 'other':
                os.system('icomposite' +convertedTexture +'= gamma 0.4545454545' +newTexture) 
            
            # Convert to .exr with otimized settings
            os.system('iconvert -d half '+convertedTexture+finalTexture+' storage tile 64 tiley 65 compression zip')
            
            # Seperate extension from filename and rename texture to production pipeline name 
            finalTextureName, ext = os.path.splitext(os.path.basename(finalTexture))

            newTextureName = assetName+'_'+geoName+'_'+shadingPass+ext
 
            newfilepath = os.path.join(assetImageDir,newTextureName)

            shutil.copy(finalTexture,newfilepath)

            # Output final success message
            ui.infoWindow('Your texture was saved to: '+newfilepath+' as a .exr image file')
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 checkoutLightingFile():
    print("checkoutLightingFile")
    shotPaths = glob.glob(os.path.join(os.environ["SHOTS_DIR"], "*"))
    selections = []
    for sp in shotPaths:
        selections.append(os.path.basename(sp))
    selections.sort()
    print("Im calling ui")
    answer = ui.listWindow(selections, wmessage="Select shot file to checkout:")
    print("Im done calling ui")
    if answer:
        answer = answer[0]
        toCheckout = os.path.join(os.environ["SHOTS_DIR"], selections[answer], "lighting")

        try:
            destpath = amu.checkout(toCheckout, True)
        except Exception as e:
            if not amu.checkedOutByMe(toCheckout):
                ui.infoWindow("Can Not Checkout: " + str(e))
                return
            else:
                destpath = amu.getCheckoutDest(toCheckout)

        toOpen = os.path.join(destpath, get_filename(toCheckout) + ".hipnc")

        if os.path.exists(toOpen):
            hou.hipFile.load(toOpen)
        else:
            hou.hipFile.clear()
            hou.hipFile.save(toOpen)
예제 #4
0
def checkoutLightingFile():
    print("checkoutLightingFile")
    shotPaths = glob.glob(os.path.join(os.environ['SHOTS_DIR'], '*'))
    selections = []
    for sp in shotPaths:
        selections.append(os.path.basename(sp))
    selections.sort()
    print('Im calling ui')
    answer = ui.listWindow(selections, wmessage='Select shot file to checkout:')
    print('Im done calling ui')
    if answer:
        answer = answer[0]
        toCheckout = os.path.join(os.environ['SHOTS_DIR'], selections[answer], 'lighting')

        try:
            destpath = amu.checkout(toCheckout, True)
        except Exception as e:
            if not amu.checkedOutByMe(toCheckout):
                ui.infoWindow('Can Not Checkout: '+str(e))
                return
            else:
                destpath = amu.getCheckoutDest(toCheckout)

        toOpen = os.path.join(destpath, get_filename(toCheckout)+'.hipnc')

        if os.path.exists(toOpen):
            hou.hipFile.load(toOpen)
        else:
            hou.hipFile.clear()
            hou.hipFile.save(toOpen) 
def checkoutLightingFile():
    shotPaths = glob.glob(os.path.join(os.environ['SHOTS_DIR'], '*'))
    selections = []
    for sp in shotPaths:
        selections.append(os.path.basename(sp))
    selections.sort()
    answer = ui.listWindow(selections, wmessage='Select shot file to checkout:')
    if answer:
        answer = answer[0]
        toCheckout = os.path.join(os.environ['SHOTS_DIR'], selections[answer], 'lighting')

        try:
            destpath = amu.checkout(toCheckout, True)
        except Exception as e:
            if not amu.checkedOutByMe(toCheckout):
                ui.infoWindow('Can Not Checkout: '+str(e))
                return
            else:
                destpath = amu.getCheckoutDest(toCheckout)

        toOpen = os.path.join(destpath, get_filename(toCheckout)+'.hipnc')

        if os.path.exists(toOpen):
            hou.hipFile.load(toOpen)
        else:
            hou.hipFile.clear()
            hou.hipFile.save(toOpen)
def newTexture():
    # Get a list of assets
    assetList = glob.glob(os.path.join(os.environ["ASSETS_DIR"], "*"))
    selections = []
    for aL in assetList:
        # basename takes last folder in path.
        selections.append(os.path.basename(aL))
        # sort alphabetically
    selections.sort()
    answer = ui.listWindow(selections, wmessage="Choose an asset to add/update textures for")
    if answer:
        answer = answer[0]
        assetName = selections[answer]
        assetImageDir = os.path.join(os.environ["ASSETS_DIR"], assetName, "images")

        # Allow user to choose texture map in user local directory
        userDirectory = os.environ["USER_DIR"]
        userSelection = ui.fileChooser(
            start_dir=userDirectory,
            wtitle="Select texture map, or folder of texture maps",
            image=True,
            extensions="*.jpg,*.jpeg,*.tiff,*.tif,*.png,*.exr",
        )

        # Allow user to search for texture in any directory
        userSelection = os.path.expandvars(userSelection)

        if os.path.isdir(userSelection):
            folder_name = os.path.basename(os.path.dirname(userSelection))
            texture_paths = glob.glob(os.path.join(userSelection, "*"))

            newFileDir = os.path.join(assetImageDir, folder_name)
            os.system("rm -rf " + newFileDir)
            print "newFileDir:: " + newFileDir
            os.makedirs(newFileDir)

            for t in texture_paths:
                convert_texture(t, assetImageDir, folder_name=folder_name)
        else:
            convert_texture(userSelection, assetImageDir)

        ui.infoWindow("Done.")
def unlockLightingFile():
    print("unlockLightingFile")
    shotPaths = glob.glob(os.path.join(os.environ['SHOTS_DIR'], '*'))
    selections = []
    for sp in shotPaths:
        selections.append(os.path.basename(sp))
    selections.sort()
    answer = ui.listWindow(selections, wmessage='Select shot file to unlock:')
    if answer:
        answer = answer[0]
        toUnlock = os.path.join(os.environ['SHOTS_DIR'], selections[answer], 'lighting')
	if amu.isLocked(toUnlock):
		reply = ui.warningWindow('Are you sure you want to unlock this file?')
    		if reply == 0:
			hou.hipFile.save()
        		hou.hipFile.clear()		
			amu.unlock(toUnlock)
			ui.infoWindow('Lighting file unlocked')
			
	else:
		ui.infoWindow('Lighting file already unlocked')
                return
예제 #8
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)
예제 #9
0
def unlockLightingFile():
    print("unlockLightingFile")
    shotPaths = glob.glob(os.path.join(os.environ['SHOTS_DIR'], '*'))
    selections = []
    for sp in shotPaths:
        selections.append(os.path.basename(sp))
    selections.sort()
    answer = ui.listWindow(selections, wmessage='Select shot file to unlock:')
    if answer:
        answer = answer[0]
        toUnlock = os.path.join(os.environ['SHOTS_DIR'], selections[answer], 'lighting')
	if amu.isLocked(toUnlock):
		reply = ui.warningWindow('Are you sure you want to unlock this file?')
    		if reply == 0:
			hou.hipFile.save()
        		hou.hipFile.clear()		
			amu.unlock(toUnlock)
			ui.infoWindow('Lighting file unlocked')
			
	else:
		ui.infoWindow('Lighting file already unlocked')
                return
예제 #10
0
def newTexture():
    # Get a list of assets 
    assetList = glob.glob(os.path.join(os.environ['ASSETS_DIR'], '*'))
    selections = []
    for aL in assetList:
        # basename takes last folder in path.
        selections.append(os.path.basename(aL)) 
        # sort alphabetically
    selections.sort()
    answer = ui.listWindow(selections, wmessage='Choose an asset to add/update textures for')
    if answer:
        answer = answer[0]
        assetName = selections[answer]
        assetImageDir = os.path.join(os.environ['ASSETS_DIR'], assetName, 'images')

        # Allow user to choose texture map in user local directory   
        userDirectory = os.environ['USER_DIR']
        userSelection = ui.fileChooser(start_dir=userDirectory, wtitle='Select texture map, or folder of texture maps', image=True, extensions='*.jpg,*.jpeg,*.tiff,*.tif,*.png,*.exr') 
        
        #Allow user to search for texture in any directory
        userSelection = os.path.expandvars(userSelection)

        if os.path.isdir(userSelection):
            folder_name = os.path.basename(os.path.dirname(userSelection))
            texture_paths = glob.glob(os.path.join(userSelection, '*'))

            newFileDir = os.path.join(assetImageDir, folder_name)
            os.system('rm -rf '+newFileDir)
            print 'newFileDir:: '+newFileDir
            os.makedirs(newFileDir)
            
            for t in texture_paths:
                convert_texture(t, assetImageDir, folder_name=folder_name)
        else:
            convert_texture(userSelection, assetImageDir)

        ui.infoWindow('Done.')
예제 #11
0
def newTexture():
    # Get a list of assets
    assetList = glob.glob(os.path.join(os.environ["ASSETS_DIR"], "*"))
    selections = []
    for aL in assetList:
        # basename takes last folder in path.
        selections.append(os.path.basename(aL))
        # sort alphabetically
    selections.sort()
    answer = ui.listWindow(selections, wmessage="Choose an asset to add/update textures for")
    if answer:
        answer = answer[0]
        assetName = selections[answer]
        assetImageDir = os.path.join(os.environ["ASSETS_DIR"], assetName, "images")

        # Direct user to geometry file path and have them choose the correct one
        sdir = "$JOB/PRODUCTION/assets/" + assetName + "/geo/bjsonFiles"
        geoPath = ui.fileChooser(
            start_dir=sdir, wtitle="Choose Asset Geometry for Texture", mode=fileMode.Read, extensions="*.bjson, *.obj"
        )
        geoName, ext = os.path.splitext(os.path.basename(geoPath))

        # Show a list of shading passes
        shadingPassList = [
            "diffuse",
            "specular",
            "single_SSS",
            "multi_SSS",
            "opacity",
            "bump",
            "scalar_displacement",
            "vector_displacement",
            "other",
        ]
        answer = ui.listWindow(shadingPassList, wmessage="Which texture will you be creating/updating?")
        if answer:
            answer = answer[0]
            shadingPass = shadingPassList[answer]

            # Allow user to choose texture map in user local directory
            userDirectory = os.environ["USER_DIR"]
            userTextureMap = ui.fileChooser(
                start_dir=userDirectory,
                wtitle="Browse to the Texture Map in your User Directory",
                image=True,
                extensions="*.jpg,*.jpeg,*.tiff,*.tif,*.png,*.exr",
            )
            # Allow user to search for texture in any directory
            userTextureMap = os.path.expandvars(userTextureMap)

            # Set Variables for texture paths
            convertedTexture = "/tmp/intermediateTexture.exr"
            finalTexture = "/tmp/finishedTexture.exr"

            # Gamma correct for linear workflow
            if shadingPass in (shadingPassList[:4] + shadingPassList[-1:]):
                args = ["icomposite", convertedTexture, "=", "gamma", str(1 / 2.2), userTextureMap]
                subprocess.check_call(args)
                didgamma = "\nIt has been gamma corrected."
            else:
                convertedTexture = userTextureMap
                didgamma = ""

            # Convert to .exr with otimized settings. Also, setting compatible with RenderMan (in case we need to render there)
            args = ["txmake", "-mode", "periodic", "-compression", "zip"]
            args += ["-format", "openexr", "-half", convertedTexture, finalTexture]

            subprocess.check_call(args)

            # Uncomment the following and comment out the previous call if PRMan is not present
            """
            args = 'iconvert -d half ' + convertedTexture + ' ' 
            args += finalTexture + ' storage tile tilex 32 tiley 32 compression zip'

            subprocess.check_call( args.split() )
            """

            # Rename texture and move into production pipeline
            finalTextureName, ext = os.path.splitext(os.path.basename(finalTexture))

            newTextureName = assetName + "_" + geoName + "_" + shadingPass + ext

            newfilepath = os.path.join(assetImageDir, newTextureName)

            shutil.copy(finalTexture, newfilepath)

            # Remove temporary files
            os.remove(finalTexture)
            os.remove(convertedTexture)

            # Output final success message
            ui.infoWindow("Your texture was saved to: " + newfilepath + didgamma)
def newTexture():
    # Get a list of assets 
    assetList = glob.glob(os.path.join(os.environ['ASSETS_DIR'], '*'))
    selections = []
    for aL in assetList:
        # basename takes last folder in path.
        selections.append(os.path.basename(aL)) 
        # sort alphabetically
    selections.sort()
    answer = ui.listWindow(selections, wmessage='Choose an asset to add/update textures for')
    if answer:
        answer = answer[0]
        assetName = selections[answer]
        assetImageDir = os.path.join(os.environ['ASSETS_DIR'], assetName, 'images')

        # Direct user to geometry file path and have them choose the correct one
        sdir = '$JOB/PRODUCTION/assets/'+assetName+'/geo/bjsonFiles'
        geoPath = ui.fileChooser(start_dir=sdir, wtitle='Choose Asset Geometry for Texture', mode=fileMode.Read, extensions='*.bjson, *.obj')
        geoName, ext = os.path.splitext(os.path.basename(geoPath))

        # Show a list of shading passes
        shadingPassList = ['diffuse','specular','single_SSS','multi_SSS','opacity','bump','scalar_displacement','vector_displacement','other']
        answer = ui.listWindow(shadingPassList, wmessage='Which texture will you be creating/updating?')
        if answer: 
            answer = answer[0]
            shadingPass = shadingPassList[answer]

            # Allow user to choose texture map in user local directory   
            userDirectory = os.environ['USER_DIR']
            userTextureMap = ui.fileChooser(start_dir=userDirectory, wtitle='Browse to the Texture Map in your User Directory', image=True, extensions='*.jpg,*.jpeg,*.tiff,*.tif,*.png,*.exr') 
            #Allow user to search for texture in any directory
            userTextureMap = os.path.expandvars(userTextureMap)

            # Set Variables for texture paths
            convertedTexture = '/tmp/convertedTexture.exr'
            finalTexture = '/tmp/finalTexture.exr'

            # Gamma correct for linear workflow
            if shadingPass in (shadingPassList[:4] + shadingPassList[-1:]):
                args = ['icomposite',convertedTexture,'=','gamma',str(1/2.2),userTextureMap]
                subprocess.check_call(args)
                didgamma = '\nIt has been gamma corrected.'
            else:
                convertedTexture = userTextureMap
                didgamma = ''
            
            # Convert to .exr with otimized settings. Also, setting compatible with RenderMan (in case we need to render there)
            args = ['txmake','-mode','periodic','-compression','zip']
            args += ['-format','openexr','-half',convertedTexture,finalTexture]

            subprocess.check_call(args)

            # Uncomment the following and comment out the previous call if PRMan is not present
            """
            args = 'iconvert -d half ' + convertedTexture + ' ' 
            args += finalTexture + ' storage tile tilex 32 tiley 32 compression zip'

            subprocess.check_call( args.split() )
            """
            
            # Rename texture and move into production pipeline 
            finalTextureName, ext = os.path.splitext(os.path.basename(finalTexture))

            newTextureName = assetName + '_' + geoName + '_' + shadingPass + ext
 
            newfilepath = os.path.join(assetImageDir,newTextureName)

            shutil.copy(finalTexture,newfilepath)

            # Output final success message
            ui.infoWindow('Your texture was saved to: ' + newfilepath + didgamma)