*its worth mentioning these have only been tested on Linux and Mac*
This one checks any referenced file paths in the scene and then checks in the directory if there are newer versions than the current, if they are they mark them as red, green if the latest version
py code
import os
#open history event
ix.enable_command_history()
ix.begin_command_batch("Mark outdated Ref Paths History")
contexts = ix.api.OfContextSet()
ix.application.get_factory().get_root().resolve_all_contexts(contexts)
for context in contexts:
if context.is_reference() and not context.is_disabled():
refFileList = context.get_attribute("filename").get_string()
#ix.log_info(refFileList)
#get dir path
backToDir = refFileList.split('/')[:-1]
#get file name minus the version
splitPath = refFileList.split(os.sep)
fileName = os.sep.join(splitPath[-1:])
splitName = fileName.split('_')[:-1]
joinName = os.sep.join(splitName)
assetName = os.path.join(joinName).replace('/', '_')
#list all files in the dir
fileDir = os.path.join(*backToDir)
fileDir = "/" + fileDir
listOfFiles = os.listdir(fileDir)
#filter latest version of file using the name to filter
latestFileVersion = []
for names in listOfFiles:
if names.startswith(assetName):
latestFileVersion.append(names)
latestReference = max(latestFileVersion)
updatedPath = fileDir + "/" + latestReference
#update reference version for latest
if re.match(refFileList, updatedPath):
ix.cmds.ColorTagItems([context], "green")
else:
ix.cmds.ColorTagItems([context], "red")
#close history event
ix.end_command_batch()
ix.disable_command_history()
After this there is this script, which will update all the outdated references to the latest
py code
import os
#open history event
ix.enable_command_history()
ix.begin_command_batch("Update Ref Path History")
contexts = ix.api.OfContextSet()
ix.application.get_factory().get_root().resolve_all_contexts(contexts)
for context in contexts:
if context.is_reference() and not context.is_disabled():
refFileList = context.get_attribute("filename").get_string()
#ix.log_info(refFileList)
#get dir path
backToDir = refFileList.split('/')[:-1]
#get file name minus the version
splitPath = refFileList.split(os.sep)
fileName = os.sep.join(splitPath[-1:])
splitName = fileName.split('_')[:-1]
joinName = os.sep.join(splitName)
assetName = os.path.join(joinName).replace('/', '_')
#list all files in the dir
fileDir = os.path.join(*backToDir)
fileDir = "/" + fileDir
listOfFiles = os.listdir(fileDir)
#filter latest version of file using the name to filter
latestFileVersion = []
for names in listOfFiles:
if names.startswith(assetName):
latestFileVersion.append(names)
latestReference = max(latestFileVersion)
updatedPath = fileDir + "/" + latestReference
#update reference version for latest
updateToLatest = ix.cmds.SetReferenceFilenames([context], [1, 0], [str(updatedPath)])
ix.cmds.ColorTagItems([context], "green")
#close history event
ix.end_command_batch()
ix.disable_command_history()
This one will take the selected textures from wherever they are on disk and copy them into a single location, it will then repath the textures in Clarisse to the new location. You'll have to update the filepath and texDir to work with where you want things to go in your own pipeline
py code
import os
filepath = getSetVars(self, sender, evtid)
texDir = os.path.join(filepath, 'publish', 'attic', 'textures')
#make directories on disk
if not os.path.exists(texDir):
os.makedirs(texDir)
#open history event
ix.enable_command_history()
ix.begin_command_batch("Publish Texture History")
for item in range(ix.selection.get_count()):
item = ix.selection[item]
texturePath = item.attrs.filename[0]
splitTexPath = texturePath.split(os.sep)
currentTexDir = os.sep.join(splitTexPath[:-1]) + "/"
textureName = os.sep.join(splitTexPath[-1:])
#check for udim files, find numbering on disk, copy files
if "<UDIM>" in texturePath:
filenameList = os.path.basename(texturePath).split("<UDIM>")
udimStart, udimEnd = filenameList[0], filenameList[1]
for file in os.listdir(os.path.dirname(texturePath)):
if file.startswith(udimStart) and file.endswith(udimEnd):
udimFileNames = file
shutil.copy(currentTexDir + udimFileNames, texDir)
else:
shutil.copy(texturePath, texDir)
#repath files
ix.cmds.SetValues([str(item) + ".filename"], [str(texDir + textureName)])
#close history event
ix.end_command_batch()
ix.disable_command_history()
This is my version of a save script which in our pipeline will save the first version if nothing exists but if it does it will version up, I found the version up script on here would cause issues if you went back to an older version, it would just save over the next version, this will check what the latest version is and save up from there.
Saving the first version will again need adjusting in your own pipelines but the versioning up part can be pulled out and used on its own.
py code
import glob
import os
taskName, shotName, sequenceName, episodeName, projectName, filepath, userName = getSetVars(self, sender, evtid)
name = projectName + '_' + episodeName + '_' + sequenceName + '_' + shotName + '_' + taskName
firstSaveName = name + '_v001.project'
work_path = os.path.join(filepath, 'work', taskName, userName, 'clarisse')
savePath = work_path + '/' + firstSaveName
extension = "project"
#make directories on disk
if not os.path.exists(work_path):
os.makedirs(work_path)
if os.path.exists(savePath):
file_name = os.path.join(work_path, name + '_[vV]*.' + extension)
elements = glob.glob(file_name)
version = 1
if elements:
match = re.search('_v[0-9]+', os.path.basename(sorted(elements)[-1]))
if match:
ver = match.group().strip('_v')
if ver.isdigit() and int(ver) >= version:
version = int(ver) + 1
newVersionNum = 'v' + str(version).zfill(3)
savePath = os.path.join(work_path, name + '_' + newVersionNum + '.' + extension)
else:
savePath = work_path + '/' + firstSaveName
ix.save_project(savePath)