Last active
August 11, 2017 12:48
-
-
Save sridharankaliyamoorthy/f4adb1a6baea050099f2e0ac15071fcc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# :coding: utf-8 | |
# :copyright: Copyright (c) 2016 ftrack | |
import os | |
import ftrack | |
import ftrack_connect.application | |
''' | |
This connect plugin hook will add the pyblish nuke prototype to the | |
environment when Nuke is launching from Connect. This hook should only | |
be sourced by Connect. | |
''' | |
plugin_base_dir = os.path.normpath( | |
os.path.join( | |
os.path.abspath( | |
os.path.dirname(__file__) | |
), | |
'..' | |
) | |
) | |
application_hook = os.path.join( | |
plugin_base_dir, 'resource', 'application_hook' | |
) | |
nuke_plugin_path = os.path.join( | |
plugin_base_dir, 'resource', 'nuke_plugin' | |
) | |
ftrack_connect_nuke_publish_path = os.path.join( | |
plugin_base_dir, 'source' | |
) | |
python_dependencies = os.path.join( | |
plugin_base_dir, 'dependencies' | |
) | |
def on_application_launch(event): | |
'''Handle application launch and add environment to *event*.''' | |
# Filter out Nuke studio. | |
if event['data']['application']['identifier'].startswith('nuke_studio'): | |
return | |
ftrack_connect.application.appendPath( | |
python_dependencies, | |
'PYTHONPATH', | |
event['data']['options']['env'] | |
) | |
ftrack_connect.application.appendPath( | |
ftrack_connect_nuke_publish_path, | |
'PYTHONPATH', | |
event['data']['options']['env'] | |
) | |
ftrack_connect.application.appendPath( | |
application_hook, | |
'FTRACK_EVENT_PLUGIN_PATH', | |
event['data']['options']['env'] | |
) | |
ftrack_connect.application.appendPath( | |
nuke_plugin_path, | |
'NUKE_PATH', | |
event['data']['options']['env'] | |
) | |
event['data']['options']['env']['FTRACK_CONTEXT_ID'] = ( | |
event['data']['options']['env']['FTRACK_TASKID'] | |
) | |
def register(registry): | |
'''Subscribe to application launch events on *registry*.''' | |
if registry is not ftrack.EVENT_HANDLERS: | |
# Not a session, let us early out to avoid registering multiple times. | |
return | |
ftrack.EVENT_HUB.subscribe( | |
'topic=ftrack.connect.application.launch and data.application.identifier=nuke*', | |
on_application_launch | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# :coding: utf-8 | |
# :copyright: Copyright (c) 2015 ftrack | |
import nukecon | |
import re | |
import glob | |
import nuke | |
import ftrack | |
import os | |
import traceback | |
from nukecon import Connector | |
from ftrack_connect.connector import ( | |
FTAssetHandlerInstance, | |
HelpFunctions, | |
FTAssetType, | |
FTAssetObject, | |
FTComponent | |
) | |
class GenericAsset(FTAssetType): | |
def __init__(self): | |
super(GenericAsset, self).__init__() | |
def importAsset(self, iAObj=None): | |
return 'Imported generic asset' | |
def publishAsset(self): | |
return [], 'Generic publish not supported' | |
def changeVersion(self, iAObj=None, applicationObject=None): | |
#print 'changing' | |
return True | |
def addFTab(self, resultingNode): | |
'''Add new ftrack tab to *resultingNode*''' | |
knobs = resultingNode.knobs().keys() | |
if 'ftracktab' not in knobs: | |
# Note: the tab is supposed to be existing as it gets created | |
# through callback during the read and write nodes creation. | |
# This check is to ensure corner cases are handled properly. | |
tab = nuke.Tab_Knob('ftracktab', 'ftrack') | |
resultingNode.addKnob(tab) | |
btn = nuke.String_Knob('componentId') | |
resultingNode.addKnob(btn) | |
btn = nuke.String_Knob('componentName') | |
resultingNode.addKnob(btn) | |
btn = nuke.String_Knob('assetVersionId') | |
resultingNode.addKnob(btn) | |
btn = nuke.String_Knob('assetVersion') | |
resultingNode.addKnob(btn) | |
btn = nuke.String_Knob('assetName') | |
resultingNode.addKnob(btn) | |
btn = nuke.String_Knob('assetType') | |
resultingNode.addKnob(btn) | |
btn = nuke.String_Knob('assetId') | |
resultingNode.addKnob(btn) | |
def setFTab(self, resultingNode, iAObj): | |
componentId = ftrack.Component(iAObj.componentId).getEntityRef() | |
assetVersionId = ftrack.AssetVersion(iAObj.assetVersionId).getEntityRef() | |
resultingNode.knob('assetId').setValue( | |
HelpFunctions.safeString(iAObj.assetId) | |
) | |
resultingNode.knob('componentId').setValue( | |
HelpFunctions.safeString(componentId) | |
) | |
resultingNode.knob('componentName').setValue( | |
HelpFunctions.safeString(iAObj.componentName) | |
) | |
resultingNode.knob('assetVersionId').setValue( | |
HelpFunctions.safeString(assetVersionId) | |
) | |
resultingNode.knob('assetVersion').setValue( | |
HelpFunctions.safeString(iAObj.assetVersion) | |
) | |
resultingNode.knob('assetName').setValue( | |
HelpFunctions.safeString(iAObj.assetName) | |
) | |
resultingNode.knob('assetType').setValue( | |
HelpFunctions.safeString(iAObj.assetType) | |
) | |
class ImageSequenceAsset(GenericAsset): | |
def __init__(self): | |
super(ImageSequenceAsset, self).__init__() | |
def getStartEndFrames(self, iAObj): | |
'''Return start and end from *iAObj*.''' | |
component = ftrack.Component(iAObj.componentId) | |
if component.getSystemType() == 'sequence': | |
# Find out frame start and end from members if component | |
# system type is sequence. | |
members = component.getMembers(location=None) | |
frames = [int(member.getName()) for member in members] | |
start = min(frames) | |
end = max(frames) | |
else: | |
start, end = HelpFunctions.getFileSequenceStartEnd(iAObj.filePath) | |
return start, end | |
def importAsset(self, iAObj=None): | |
'''Create nuke read node from *iAObj.''' | |
if iAObj.filePath.endswith('nk'): | |
nuke.nodePaste(iAObj.filePath) | |
return | |
else: | |
resultingNode = nuke.createNode('Read', inpanel=False) | |
resultingNode['name'].setValue( | |
HelpFunctions.safeString(iAObj.assetName) + '_' + | |
HelpFunctions.safeString(iAObj.componentName) | |
) | |
self.addFTab(resultingNode) | |
# Compute frame range | |
# TODO: Store these attributes on the component for easy access. | |
resultingNode['file'].fromUserText( | |
HelpFunctions.safeString(iAObj.filePath) | |
) | |
start, end = self.getStartEndFrames(iAObj) | |
resultingNode['first'].setValue(start) | |
resultingNode['origfirst'].setValue(start) | |
resultingNode['last'].setValue(end) | |
resultingNode['origlast'].setValue(end) | |
proxyPath = '' | |
assetVersion = ftrack.AssetVersion(iAObj.assetVersionId) | |
try: | |
proxyPath = assetVersion.getComponent(name='proxy').getImportPath() | |
except: | |
pass | |
try: | |
proxyPath = assetVersion.getComponent(name=iAObj.componentName + '_proxy').getImportPath() | |
except: | |
pass | |
if proxyPath != '': | |
resultingNode['proxy'].fromUserText(proxyPath) | |
self.setFTab(resultingNode, iAObj) | |
return 'Imported %s asset' % iAObj.componentName | |
def changeVersion(self, iAObj=None, applicationObject=None): | |
n = nuke.toNode(HelpFunctions.safeString(applicationObject)) | |
#print assetVersionId | |
proxyPath = '' | |
try: | |
proxyPath = ftrack.AssetVersion(iAObj.assetVersionId).getComponent(name='proxy').getImportPath() | |
except: | |
print 'No proxy' | |
n['file'].fromUserText( | |
HelpFunctions.safeString(iAObj.filePath) | |
) | |
if proxyPath != '': | |
n['proxy'].fromUserText(proxyPath) | |
start, end = self.getStartEndFrames(iAObj) | |
n['first'].setValue(start) | |
n['origfirst'].setValue(start) | |
n['last'].setValue(end) | |
n['origlast'].setValue(end) | |
self.setFTab(n, iAObj) | |
return True | |
def publishContent(self, content, assetVersion, progressCallback=None): | |
publishedComponents = [] | |
for c in content: | |
filename = c[0] | |
componentName = c[1] | |
sequenceComponent = FTComponent() | |
start = int(float(c[2])) | |
end = int(float(c[3])) | |
if not start - end == 0: | |
sequence_format = u'{0} [{1}-{2}]'.format( | |
filename, start, end | |
) | |
else: | |
sequence_format = u'{0}'.format( | |
filename, start | |
) | |
sequenceIdentifier = sequence_format | |
metaData = [] | |
if not '_proxy' in componentName: | |
metaData.append(('img_main', 'True')) | |
for meta in c[5]: | |
metaData.append((meta[0], meta[1])) | |
sequenceComponent.componentname = componentName | |
sequenceComponent.path = sequenceIdentifier | |
sequenceComponent.metadata = metaData | |
publishedComponents.append(sequenceComponent) | |
try: | |
node = nuke.toNode(HelpFunctions.safeString(content[0][4])) | |
thumbnail = Connector.createThumbNail(node) | |
if thumbnail: | |
publishedComponents.append(FTComponent(componentname='thumbnail', path=thumbnail)) | |
except: | |
print 'Failed to create thumbnail' | |
import sys | |
traceback.print_exc(file=sys.stdout) | |
return publishedComponents | |
def publishAsset(self, iAObj=None): | |
publishedComponents = [] | |
# needs rewrite with using publishContent | |
return publishedComponents, '%s published' % iAObj.componentName | |
class CameraAsset(GenericAsset): | |
def __init__(self): | |
super(CameraAsset, self).__init__() | |
def importAsset(self, iAObj=None): | |
resultingNode = nuke.createNode("Camera2", inpanel=False) | |
resultingNode['read_from_file'].setValue(True) | |
resultingNode['file'].setValue( | |
HelpFunctions.safeString( | |
nukecon.Connector.windowsFixPath(iAObj.filePath) | |
) | |
) | |
resultingNode['name'].setValue( | |
HelpFunctions.safeString(iAObj.assetName) | |
) | |
self.addFTab(resultingNode) | |
self.setFTab(resultingNode, iAObj) | |
return 'Imported camera asset' | |
def changeVersion(self, iAObj=None, applicationObject=None): | |
n = nuke.toNode(HelpFunctions.safeString(applicationObject)) | |
n['read_from_file'].setValue(True) | |
n['file'].setValue(nukecon.Connector.windowsFixPath(iAObj.filePath)) | |
self.setFTab(n, iAObj) | |
return True | |
def publishContent(self, content, assetVersion, progressCallback=None): | |
publishedComponents = [] | |
for c in content: | |
publishfilename = c[0] | |
componentName = c[1] | |
publishedComponents.append(FTComponent(componentname=componentName, path=publishfilename)) | |
return publishedComponents | |
def publishAsset(self, iAObj=None): | |
return [], "Publish function not implemented for camera asset" | |
class GeometryAsset(GenericAsset): | |
def __init__(self): | |
super(GeometryAsset, self).__init__() | |
def importAsset(self, iAObj=None): | |
resultingNode = nuke.createNode("ReadGeo2", inpanel=False) | |
resultingNode['file'].setValue( | |
HelpFunctions.safeString( | |
nukecon.Connector.windowsFixPath(iAObj.filePath) | |
) | |
) | |
resultingNode['name'].setValue( | |
HelpFunctions.safeString(iAObj.assetName) | |
) | |
self.addFTab(resultingNode) | |
self.setFTab(resultingNode, iAObj) | |
return 'Imported geo asset' | |
def changeVersion(self, iAObj=None, applicationObject=None): | |
n = nuke.toNode(HelpFunctions.safeString(applicationObject)) | |
n['file'].setValue( | |
HelpFunctions.safeString( | |
nukecon.Connector.windowsFixPath(iAObj.filePath) | |
) | |
) | |
self.setFTab(n, iAObj) | |
return True | |
def publishContent(self, content, assetVersion, progressCallback=None): | |
publishedComponents = [] | |
for c in content: | |
publishfilename = c[0] | |
componentName = c[1] | |
publishedComponents.append(FTComponent(componentname=componentName, path=publishfilename)) | |
return publishedComponents | |
def publishAsset(self, iAObj=None): | |
return [], "Publish function not implemented for geometry asset" | |
class GizmoAsset(GenericAsset): | |
'''Gizmo asset.''' | |
def __init__(self): | |
super(GizmoAsset, self).__init__() | |
def importAsset(self, iAObj=None): | |
if iAObj.filePath.endswith('gizmo'): | |
resultingNode = nuke.createNode(iAObj.filePath) | |
resultingNode['name'].setValue(iAObj.assetName) | |
self.addFTab(resultingNode) | |
self.setFTab(resultingNode, iAObj) | |
def changeVersion(self, iAObj=None, applicationObject=None): | |
old_gizmo = nuke.toNode(applicationObject) | |
gizmo_path = os.path.dirname(iAObj.filePath) | |
nuke.pluginAddPath(gizmo_path) | |
new_gizmo = nuke.createNode(iAObj.filePath) | |
# connect inputs | |
for i in range(old_gizmo.inputs()): | |
new_gizmo.setInput(i, old_gizmo.input(i)) | |
# connect outputs | |
for d in old_gizmo.dependent(nuke.INPUTS | nuke.HIDDEN_INPUTS): | |
for input in [i for i in range(d.inputs()) if d.input(i) == old_gizmo]: | |
d.setInput(input, new_gizmo) | |
# restore ititial position | |
new_gizmo.setXYpos(old_gizmo.xpos(), old_gizmo.ypos()) | |
# swap them over | |
nuke.delete(old_gizmo) | |
new_gizmo['name'].setValue(iAObj.assetName) | |
self.addFTab(new_gizmo) | |
self.setFTab(new_gizmo, iAObj) | |
return True | |
def publishContent(self, content, assetVersion, progressCallback=None): | |
publishedComponents = [] | |
for c in content: | |
publishfilename = c[0] | |
componentName = c[1] | |
publishedComponents.append(FTComponent(componentname=componentName, path=publishfilename)) | |
return publishedComponents | |
class NukeSceneAsset(GizmoAsset): | |
'''Nuke scene asset.''' | |
def importAsset(self, iAObj=None): | |
if iAObj.filePath.endswith('nk'): | |
resultingNode = nuke.createNode(iAObj.filePath) | |
self.addFTab(resultingNode) | |
self.setFTab(resultingNode, iAObj) | |
class RenderAsset(GenericAsset): | |
'''Render asset.''' | |
def changeVersion(self, iAObj=None, applicationObject=None): | |
'''Change current version of the give *iAObj* and *applicationObject*.''' | |
n = nuke.toNode(HelpFunctions.safeString(applicationObject)) | |
n['file'].fromUserText( | |
HelpFunctions.safeString(iAObj.filePath) | |
) | |
self.setFTab(n, iAObj) | |
return True | |
def publishContent(self, content, assetVersion, progressCallback=None): | |
'''Return components to publish.''' | |
components = [] | |
for row in content: | |
filename = row[0] | |
componentName = row[1] | |
components.append( | |
FTComponent(componentname=componentName, path=filename) | |
) | |
try: | |
node = nuke.toNode( | |
HelpFunctions.safeString(content[0][4]) | |
) | |
thumbnail = Connector.createThumbNail(node) | |
if thumbnail: | |
components.append( | |
FTComponent(componentname='thumbnail', path=thumbnail) | |
) | |
except Exception: | |
pass | |
return components | |
def importAsset(self, iAObj=None): | |
'''Import asset as new node.''' | |
resultingNode = nuke.createNode('Read', inpanel=False) | |
resultingNode['name'].setValue( | |
HelpFunctions.safeString(iAObj.assetName) + '_' + | |
HelpFunctions.safeString(iAObj.componentName) | |
) | |
resultingNode['file'].fromUserText( | |
HelpFunctions.safeString(iAObj.filePath) | |
) | |
self.addFTab(resultingNode) | |
self.setFTab(resultingNode, iAObj) | |
def registerAssetTypes(): | |
assetHandler = FTAssetHandlerInstance.instance() | |
assetHandler.registerAssetType(name='cam', cls=CameraAsset) | |
assetHandler.registerAssetType(name='img', cls=ImageSequenceAsset) | |
assetHandler.registerAssetType(name='geo', cls=GeometryAsset) | |
assetHandler.registerAssetType(name='render', cls=RenderAsset) | |
# new mill asset types | |
assetHandler.registerAssetType(name='nuke_gizmo', cls=GizmoAsset) | |
assetHandler.registerAssetType(name='comp', cls=NukeSceneAsset) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# :coding: utf-8 | |
# :copyright: Copyright (c) ftrack | |
import os | |
import sys | |
# Set the default ftrack server and API key variables to use if no matching | |
# environment variables are found. | |
os.environ.setdefault('FTRACK_SERVER', 'https://YOUR-FTRACK-SERVER') | |
os.environ.setdefault('FTRACK_APIKEY', 'YOUR-API-KEY') | |
# Add ftrack core egg to path. | |
sys.path.append( | |
os.path.join( | |
os.path.dirname(os.path.abspath(__file__)), 'FTrackCore.egg' | |
) | |
) | |
# Import core ftrack functionality from egg into top level namespace. | |
from FTrackCore import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
os.environ.setdefault('FTRACK_SERVER', 'https://magiclab.ftrackapp.com') | |
os.environ.setdefault('FTRACK_APIKEY', '5dd6282a-71bd-45a6-94c4-5a8b6b52fc0a') | |
#os.environ['LOGNAME'] = '<my username>' | |
import ftrack | |
for project in ftrack.getProjects(): | |
print project.getFullName() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def SetProject(): | |
if nuke.nodesSelected(): | |
read=nuke.selectedNode() | |
if read.Class() == "Read": | |
read=nuke.selectedNode() | |
a = read['first'].value() | |
b = read['last'].value() | |
f = read['format'].value() | |
nuke.root().knob('first_frame').setValue(a) | |
nuke.root().knob('last_frame').setValue(b) | |
nuke.root().knob('format').setValue(f) | |
nuke.root().knob('lock_range').setValue(True) | |
nuke.root().knob('floatLut').setValue('linear') | |
nukescripts.script_and_write_nodes_version_up() | |
else: | |
msg= "Cannot set Project from " + read.Class() + " node Select Read node!" | |
nuke.message(msg) | |
else: | |
nuke.message("Please select any read node to set Project Setting") | |
myMenu.addCommand('SetProject', 'SetProject()', 'e') | |
###################### | |
import SearchReplacePanel | |
def addSRPanel(): | |
'''Run the panel script and add it as a tab into the pane it is called from''' | |
myPanel = SearchReplacePanel.SearchReplacePanel() | |
return myPanel.addToPane() | |
# THIS LINE WILL ADD THE NEW ENTRY TO THE PANE MENU | |
nuke.menu('Pane').addCommand('SearchReplace', addSRPanel) | |
# THIS LINE WILL REGISTER THE PANEL SO IT CAN BE RESTORED WITH LAYOUTS | |
nukescripts.registerPanel('com.ohufx.SearchReplace', addSRPanel) | |
myMenu.addCommand('addSRPanel', 'addSRPanel()', '+e') | |
###### | |
def autocroptool(): | |
selectedNodes = nuke.selectedNodes() | |
for eachNode in selectedNodes: | |
# if it's a read node proceed, if not move on to the next selected node | |
if eachNode.Class() == "Read": | |
# create curveTool node | |
curveNode = nuke.nodes.CurveTool() | |
# set input 0 to eachNode (a Read node in this case) | |
curveNode.setInput(0, eachNode) | |
# set the operation to Auto Crop | |
curveNode.knob("operation").setValue("Auto Crop") | |
# set the ROI to the width and height coming from the Read node | |
curveNode["ROI"].setValue([0, 0, eachNode.width(), eachNode.height()]) | |
# execute Go! button using the project's frame range | |
nuke.execute(curveNode, nuke.root().firstFrame(), nuke.root().lastFrame()) #<-- takes project's frame range | |
#nuke.execute(curveNode, eachNode.knob("first").value(), eachNode.knob("last").value()) #<-- inherits the range from the read node | |
# create crop node | |
cropNode = nuke.nodes.Crop() | |
# set input 0 to curveNode | |
cropNode.setInput(0, curveNode) | |
# copy animation from curveTool node | |
cropNode.knob("box").copyAnimations(curveNode.knob("autocropdata").animations()) | |
# set blackoutside to False, otherwise objects can come out with an ugly black outline | |
cropNode.knob("crop").setValue(False) | |
myMenu.addCommand('autocroptool', 'autocroptool()', 'Ctrl+e') | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys | |
import PySide | |
from PySide.QtGui import QApplication | |
from PySide.QtGui import QMessageBox | |
# Create the application object | |
app = QApplication(sys.argv) | |
# Create a simple dialog box | |
msgBox = QMessageBox() | |
msgBox.setText("Hello World - using PySide version " + PySide.__version__ + "tesdt") | |
msgBox.exec_() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# clear the current selection | |
nukescripts.clear_selection_recursive() | |
#find the type of node user wants to select?? | |
userInput = nuke.getInput('what do u want to choose\n ????','TransformMasked') | |
#go through all nodes | |
for node in nuke.allNodes(): | |
#find which ones are Crop | |
if node.Class() == userInput: | |
#add them to selection | |
node.setSelected('True') | |
print node.name() | |
nuke.message('Selected %d %s nodes.' % (len(nuke.selectedNodes()),userInput)) | |
cn = nuke.selectedNodes() | |
for tn in cn: | |
if tn.knob('filter'): | |
tn.knob('filter').setValue('Notch') | |
else: | |
print tn.name() + " does not have raw option " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nuke.selectAll() | |
cn = nuke.selectedNodes() | |
numNodes = len(cn) | |
print len(cn) | |
for tn in cn: | |
if numNodes > 01: | |
#print tn.name() | |
if tn.knob('postage_stamp'): | |
tn.knob('postage_stamp').setValue(1) | |
if tn.knob('raw'): | |
tn.knob('raw').setValue(1) | |
else: | |
print tn.name() + " does not have raw option " | |
else: | |
print "kjsdklsj" | |
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# clear the current selection | |
nukescripts.clear_selection_recursive() | |
#find the type of node user wants to select?? | |
userInput = nuke.getInput('what do u want to choose\n ????','Crop') | |
#go through all nodes | |
for node in nuke.allNodes(): | |
#find which ones are Crop | |
if node.Class() == userInput: | |
#add them to selection | |
node.setSelected('True') | |
print node.name() | |
nuke.message('Selected %d %s nodes.' % (len(nuke.selectedNodes()),userInput)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
os.environ['FTRACK_SERVER'] = 'https://magiclab.ftrackapp.com' | |
os.environ['FTRACK_APIKEY'] = '<5dd6282a-71bd-45a6-94c4-5a8b6b52fc0a>' | |
os.environ['LOGNAME'] = '<sridhar_graphics@yahoo.co.in>' | |
import ftrack | |
for project in ftrack.getProjects(): | |
print project.getFullName() | |
# :coding: utf-8 | |
# :copyright: Copyright (c) 2014 ftrack | |
import ftrack_connect_foundry.plugin | |
import ftrack_connect_foundry.bridge | |
import ftrack_connect_nuke.manager | |
class Plugin(ftrack_connect_foundry.plugin.Plugin): | |
'''ftrack manager plugin for NUKE.''' | |
@classmethod | |
def _initialiseBridge(cls): | |
'''Initialise bridge.''' | |
if cls._bridge is None: | |
cls._bridge = ftrack_connect_foundry.bridge.Bridge() | |
@classmethod | |
def getInterface(cls): | |
'''Return instance of manager interface.''' | |
cls._initialiseBridge() | |
return ftrack_connect_nuke.manager.ManagerInterface(cls._bridge) | |
@classmethod | |
def getUIDelegate(cls, interfaceInstance): | |
'''Return instance of UI delegate.''' | |
cls._initialiseBridge() | |
# This import is here as certain ui modules should not be loaded | |
# unless a ui delegate is requested. | |
import ftrack_connect_nuke.ui.delegate | |
return ftrack_connect_nuke.ui.delegate.Delegate(cls._bridge) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2009 The Foundry Visionmongers Ltd. All Rights Reserved. | |
import nuke | |
# This is for testing that all plugins were compiled correctly | |
def load_all_plugins(): | |
tried = 0 | |
failed = 0 | |
p = nuke.plugins(nuke.ALL, "*." + nuke.PLUGIN_EXT) | |
for i in p: | |
# Ignore Alembic_In, since it isn't a nuke plugin. | |
# TODO - Needs to be moved a directory up so it doesn't show as a nuke plugin | |
if i.find("Alembic_In") != -1: | |
continue | |
tried += 1 | |
print i | |
try: | |
try_load = nuke.load(i) | |
except: | |
print i, "failed to load." | |
failed += 1 | |
if failed > 0: | |
print failed, "of", tried, "plugin(s) total did not load" | |
else: | |
print "All available binary plugins (", tried, ") successfully loaded" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# :coding: utf-8 | |
# :copyright: Copyright (c) 2016 ftrack | |
import os | |
import ftrack | |
import ftrack_connect.application | |
''' | |
This connect plugin hook will add the pyblish nuke prototype to the | |
environment when Nuke is launching from Connect. This hook should only | |
be sourced by Connect. | |
''' | |
plugin_base_dir = os.path.normpath( | |
os.path.join( | |
os.path.abspath( | |
os.path.dirname(__file__) | |
), | |
'..' | |
) | |
) | |
application_hook = os.path.join( | |
plugin_base_dir, 'resource', 'application_hook' | |
) | |
nuke_plugin_path = os.path.join( | |
plugin_base_dir, 'resource', 'nuke_plugin' | |
) | |
ftrack_connect_nuke_publish_path = os.path.join( | |
plugin_base_dir, 'source' | |
) | |
python_dependencies = os.path.join( | |
plugin_base_dir, 'dependencies' | |
) | |
def on_application_launch(event): | |
'''Handle application launch and add environment to *event*.''' | |
# Filter out Nuke studio. | |
if event['data']['application']['identifier'].startswith('nuke_studio'): | |
return | |
ftrack_connect.application.appendPath( | |
python_dependencies, | |
'PYTHONPATH', | |
event['data']['options']['env'] | |
) | |
ftrack_connect.application.appendPath( | |
ftrack_connect_nuke_publish_path, | |
'PYTHONPATH', | |
event['data']['options']['env'] | |
) | |
ftrack_connect.application.appendPath( | |
application_hook, | |
'FTRACK_EVENT_PLUGIN_PATH', | |
event['data']['options']['env'] | |
) | |
ftrack_connect.application.appendPath( | |
nuke_plugin_path, | |
'NUKE_PATH', | |
event['data']['options']['env'] | |
) | |
event['data']['options']['env']['FTRACK_CONTEXT_ID'] = ( | |
event['data']['options']['env']['FTRACK_TASKID'] | |
) | |
def register(registry): | |
'''Subscribe to application launch events on *registry*.''' | |
if registry is not ftrack.EVENT_HANDLERS: | |
# Not a session, let us early out to avoid registering multiple times. | |
return | |
ftrack.EVENT_HUB.subscribe( | |
'topic=ftrack.connect.application.launch and data.application.identifier=nuke*', | |
on_application_launch | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
text = "/test/projects/name/seq001/shot001/vfx/v003/seq001_shot005_vfx_v00001511.0001.nk" | |
def version_up(val): | |
number = val.group(2) | |
new_version = str(int(number)+1).zfill(len(number)) | |
return val.group(1) + new_version + val.group(3) | |
regex = re.sub( r"(_[vV])(\d+)(\.)", version_up, text) | |
print regex | |
nukescripts.script_and_write_nodes_version_up() | |
------------------------------ | |
import SearchReplacePanel | |
def addSRPanel(): | |
'''Run the panel script and add it as a tab into the pane it is called from''' | |
myPanel = SearchReplacePanel.SearchReplacePanel() | |
return myPanel.addToPane() | |
# THIS LINE WILL ADD THE NEW ENTRY TO THE PANE MENU | |
nuke.menu('Pane').addCommand('SearchReplace', addSRPanel) | |
# THIS LINE WILL REGISTER THE PANEL SO IT CAN BE RESTORED WITH LAYOUTS | |
nukescripts.registerPanel('com.ohufx.SearchReplace', addSRPanel) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment