Beispiel #1
0
def getAssetName(node):
    if hou_asset_mgr.isDigitalAsset(node):
        lpath = node.type().definition().libraryFilePath()
        filename = os.path.basename(lpath)
        return str(filename.split('.')[0].replace("'", "_"))
    else:
        return None
def getAssetName(node):
    if hou_asset_mgr.isDigitalAsset(node):
        lpath = node.type().definition().libraryFilePath()
        filename = os.path.basename(lpath)
        return str(filename.split(".")[0].replace("'", "_"))
    else:
        return None
Beispiel #3
0
def bakeNodeRecursive(node, writePath):
    bake(node, writePath)
    children = node.children()
    for child in children:
        if mgr.isDigitalAsset(child):
            bakeAsset(child)
        else:
            bakeNodeRecursive(child, writePath)
def bakeNodeRecursive(node, writePath):
    bake(node, writePath)
    children = node.children()
    for child in children:
        if mgr.isDigitalAsset(child):
            bakeAsset(child)
        else:
            bakeNodeRecursive(child, writePath)
Beispiel #5
0
def rollbackOTL(node=None):
    """Pulls a rollback window for the user to select a version to rollback to. EXACTLY ONE node may be selected, and it MUST be a digital asset.
	    The node must already exist in the database.
	"""
    print 'RollbackOTL'

    #Need to check if a particular node is a digital asset first. Rollback is will only work as a DA, with model, rigs and animation.
    if node != None:

        if not ham.isDigitalAsset(node):
            ui.infoWindow('Wait! You can only rollback Digital Assets!')
            print "NOT A DIGITAL ASSET."
        else:
            # First, we need to see if this is checked out or not. If it is checked out, then we can proceed. If not, state so.
            # For the productions path
            libraryPath = node.type().definition().libraryFilePath()
            filename = os.path.basename(libraryPath)

            asset_name, ext = os.path.splitext(filename)
            #print "asset_name " + asset_name
            toCheckout = os.path.join(ASSETSDIR, asset_name, 'otl')
            #print "toCheckout " + toCheckout
            myCheckout = False

            myCheckout = amu.isCheckedOut(toCheckout)
            if myCheckout:  #If it has been checked out
                myCheckout = amu.checkedOutByMe(toCheckout)
                if myCheckout:  #If user was the last to checkout
                    #Here we rollback.
                    versionedFolders = os.path.join(toCheckout, "src")
                    #print "versionedFolders ", versionedFolders
                    versions = glob.glob(os.path.join(versionedFolders, '*'))
                    #print "selections ", versions
                    #Wooohoooo!!!
                    selections = []
                    selectionInfo = []
                    nodeInfoDest = toCheckout

                    for vr in versions:
                        selections.append(os.path.basename(vr))
                        comment = amu.getVersionComment(
                            nodeInfoDest, os.path.basename(vr))
                        selectionInfo.append(comment)
                    selections.sort()
                    dialog = VersionDialog()
                    dialog.addItems(selections, selectionInfo)
                    dialog.show()
                    dialog.setParams(versionedFolders, asset_name, toCheckout,
                                     True)
                    pyqt_houdini.exec_(dialog)

                else:
                    hou.ui.displayMessage('Already checked out.')
                    return
            else:
                hou.ui.displayMessage('Please checkout asset first.')
    else:
        print "Node does not exist"
def rollbackOTL(node = None):
	"""Pulls a rollback window for the user to select a version to rollback to. EXACTLY ONE node may be selected, and it MUST be a digital asset.
	    The node must already exist in the database.
	"""
	print 'RollbackOTL'

	#Need to check if a particular node is a digital asset first. Rollback is will only work as a DA, with model, rigs and animation.
	if node != None:

		if not ham.isDigitalAsset(node):
			ui.infoWindow('Wait! You can only rollback Digital Assets!')
			print "NOT A DIGITAL ASSET."
		else:
			# First, we need to see if this is checked out or not. If it is checked out, then we can proceed. If not, state so.
			# For the productions path			
			libraryPath = node.type().definition().libraryFilePath()
			filename = os.path.basename(libraryPath)

			asset_name, ext = os.path.splitext(filename)
			#print "asset_name " + asset_name
			toCheckout = os.path.join(ASSETSDIR, asset_name, 'otl')
			#print "toCheckout " + toCheckout
			myCheckout = False

			myCheckout = amu.isCheckedOut(toCheckout)
			if myCheckout: #If it has been checked out
				myCheckout = amu.checkedOutByMe(toCheckout)
				if myCheckout: #If user was the last to checkout
					#Here we rollback.
					versionedFolders = os.path.join(toCheckout, "src")
					#print "versionedFolders ", versionedFolders
					versions = glob.glob(os.path.join(versionedFolders, '*'))
					#print "selections ", versions
					#Wooohoooo!!!
					selections = []
					selectionInfo = []
					nodeInfoDest = toCheckout

					for vr in versions:
						selections.append(os.path.basename(vr))
						comment = amu.getVersionComment(nodeInfoDest,os.path.basename(vr))
						selectionInfo.append(comment)
					selections.sort()
					dialog = VersionDialog()
					dialog.addItems(selections,selectionInfo)
					dialog.show()
					dialog.setParams(versionedFolders,asset_name,toCheckout,True)
					pyqt_houdini.exec_(dialog)
					
				else:
					hou.ui.displayMessage('Already checked out.')
					return
			else:
				hou.ui.displayMessage('Please checkout asset first.')
	else:
		print "Node does not exist"
def checkin(node=None):
    """Checks in the selected node.  EXACTLY ONE node may be selected, and it MUST be a digital asset.
        The node must already exist in the database, and USERNAME must have the lock."""
    if not hou_asset_mgr.isDigitalAsset(node):
        hou.ui.displayMessage("Not a Digital Asset.")
    else:
        libraryPath = node.type().definition().libraryFilePath()  # user checkout folder
        filename = os.path.basename(libraryPath)  # otl filename
        toCheckin = os.path.dirname(libraryPath)

        if os.path.exists(os.path.join(toCheckin, ".checkoutInfo")) and amu.canCheckin(toCheckin):
            response = hou.ui.readInput("What did you change?", buttons=("OK", "Cancel"), title="Comment")
            if response[0] != 0:
                return
            comment = response[1]
            hou_asset_mgr.lockAsset(node, False)
            hou_asset_mgr.saveOTL(node)
            node.type().definition().save(libraryPath)
            hou.hda.uninstallFile(libraryPath, change_oplibraries_file=False)
            amu.setComment(toCheckin, comment)
            assetdir = amu.checkin(toCheckin)
            assetpath = amu.getAvailableInstallFiles(assetdir)[0]
            amu.install(assetdir, assetpath)
            hou.hda.installFile(os.path.join(OTLDIR, filename), change_oplibraries_file=True)
            hou.hda.uninstallFile("Embedded")
            if (
                isCameraAsset(node)
                and hou.ui.displayMessage(
                    "Export Alembic?", buttons=("Yes", "No"), default_choice=0, title="Export Alembic"
                )
                == 0
            ):
                writeCamerasToAlembic(node)
            if (
                isSetAsset(node)
                and hou.ui.displayMessage(
                    "Export Alembic?", buttons=("Yes", "No"), default_choice=0, title="Export Alembic"
                )
                == 0
            ):
                writeSetToAlembic(node)
            hou.ui.displayMessage("Checkin Successful!")

        else:
            hou.ui.displayMessage("Can Not Checkin.")
Beispiel #8
0
def checkin(node = None):
    """Checks in the selected node.  EXACTLY ONE node may be selected, and it MUST be a digital asset.
        The node must already exist in the database, and USERNAME must have the lock."""
    if not hou_asset_mgr.isDigitalAsset(node):
        hou.ui.displayMessage("Not a Digital Asset.")
    else:
        libraryPath = node.type().definition().libraryFilePath() #user checkout folder
        filename = os.path.basename(libraryPath) # otl filename
        toCheckin = os.path.dirname(libraryPath)

        if os.path.exists(os.path.join(toCheckin, ".checkoutInfo")) and amu.canCheckin(toCheckin):
            response = hou.ui.readInput("What did you change?", buttons=('OK', 'Cancel',), title='Comment')
            if(response[0] != 0):
                return
            comment = response[1]
            hou_asset_mgr.lockAsset(node, False)
            hou_asset_mgr.saveOTL(node)
            node.type().definition().save(libraryPath)
            hou.hda.uninstallFile(libraryPath, change_oplibraries_file=False)
            amu.setComment(toCheckin, comment)
            assetdir = amu.checkin(toCheckin)
            assetpath = amu.getAvailableInstallFiles(assetdir)[0]
            amu.install(assetdir, assetpath)
            hou.hda.installFile(os.path.join(OTLDIR, filename), change_oplibraries_file=True)
            hou.hda.uninstallFile("Embedded")
            if isCameraAsset(node) and hou.ui.displayMessage('Export Alembic?'
                                                        , buttons=('Yes','No',)
                                                        , default_choice=0
                                                        , title='Export Alembic') == 0:
                writeCamerasToAlembic(node)
            if isSetAsset(node) and hou.ui.displayMessage('Export Alembic?'
                                                        , buttons=('Yes','No',)
                                                        , default_choice=0
                                                        , title='Export Alembic') == 0:
                writeSetToAlembic(node)
            hou.ui.displayMessage("Checkin Successful!")

        else:
            hou.ui.displayMessage('Can Not Checkin.')
Beispiel #9
0
def bakeSelectedAsset():
    node = mgr.getSelectedNode()
    if mgr.isDigitalAsset(node):
        bakeAsset(node)
Beispiel #10
0
def bakeScene():
    node = hou.node("/obj")
    children = node.children()
    for child in children:
        if mgr.isDigitalAsset(child):
            bakeAsset(child)
def rollbackOTL(node = None):
	"""Pulls a rollback window for the user to select a version to rollback to. EXACTLY ONE node may be selected, and it MUST be a digital asset.
	    The node must already exist in the database.
	"""
	print 'RollbackOTL'

	ham.updateDB()

	#Need to check if a particular node is a digital asset first. Rollback is will only work as a DA, with model, rigs and animation.
	if node != None:

		if not ham.isDigitalAsset(node):
			ui.infoWindow('Wait! You can only rollback Digital Assets!')
			print "NOT A DIGITAL ASSET."
		else:
			# First, we need to see if this is checked out or not. If it is checked out, then we can proceed. If not, state so.
			# For the productions path			
			libraryPath = node.type().definition().libraryFilePath()
			filename = os.path.basename(libraryPath)

			asset_name, ext = os.path.splitext(filename)
			#print "asset_name " + asset_name
			toCheckout = os.path.join(ASSETSDIR, asset_name, 'otl')
			#print "toCheckout " + toCheckout
			myCheckout = False

			myCheckout = amu.isCheckedOut(toCheckout)
			if myCheckout: #If it has been checked out
				myCheckout = amu.checkedOutByMe(toCheckout)
				if myCheckout: #If user was the last to checkout
					#Here we rollback.
					versionedFolders = os.path.join(toCheckout, "src")
					#print "versionedFolders ", versionedFolders
					versions = glob.glob(os.path.join(versionedFolders, '*'))
					#print "selections ", versions
					#Wooohoooo!!!
					selections = []
					for vr in versions:
						selections.append(os.path.basename(vr))
					selections.sort()
					answer = hou.ui.selectFromList(selections, message='Select version to rollback:', exclusive=True)
					if answer:
						version = answer[0]
						versionStr = "%03d" % version

						newVersion = os.path.join(versionedFolders, "v" + versionStr)
						checkoutFilePath = os.path.join(amu.getUserCheckoutDir(), asset_name)


						rollingBack = hou.ui.displayMessage('WARNING: You are about to remove your most recent changes. Proceed at your own risk.', buttons=('Actually, I don\'t want to', 'Yes. Roll me back'), severity=hou.severityType.Warning, title=("Woah there, pardner!"))
						

						if (rollingBack):
							print "rollingBack"
							# Temporarily set the version to the rollback version, and check out.
							oldVersion = int(amu.tempSetVersion(toCheckout, version))
							oldVersionStr = "%03d" % oldVersion

							tempFilePath = os.path.join(checkoutFilePath + "_otl_" + versionStr)
							filePath = os.path.join(checkoutFilePath + "_otl_" + oldVersionStr)
							# Now that we've set the version, we will 
							amu.discard(filePath) # Hey! This is working!!!
							amu.checkout(toCheckout, True)

							# Reset the version number, and rename the checkout path to the most recent version.
							amu.tempSetVersion(toCheckout, oldVersion)
							correctCheckoutDest = amu.getCheckoutDest(toCheckout)
							os.rename(tempFilePath, correctCheckoutDest)
				else:
					hou.ui.displayMessage('Already checked out.')
					return
			else:
				hou.ui.displayMessage('Please checkout asset first.')				


			
	else:
		print "Node does not exist"
def bakeSelectedAsset():
    node = mgr.getSelectedNode()
    if mgr.isDigitalAsset(node):
        bakeAsset(node)
def bakeScene():
    node = hou.node("/obj")
    children = node.children()
    for child in children:
        if mgr.isDigitalAsset(child):
            bakeAsset(child)