Skip to content

Instantly share code, notes, and snippets.

@xenjee
Forked from lcrs/hook.py
Created April 20, 2017 03:04
Show Gist options
  • Save xenjee/9d6941d7f53294dfb26be530ddff2c50 to your computer and use it in GitHub Desktop.
Save xenjee/9d6941d7f53294dfb26be530ddff2c50 to your computer and use it in GitHub Desktop.

Revisions

  1. @lcrs lcrs created this gist Apr 19, 2017.
    155 changes: 155 additions & 0 deletions hook.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,155 @@
    #!/bin/env python
    #******************************************************************************
    #
    # Filename: hook.py
    #
    # Copyright (c) 2008 Autodesk Canada Co.
    # All rights reserved.
    #
    # Use of this software is subject to the terms of the Autodesk license
    # agreement provided at the time of installation or download, or which
    # otherwise accompanies this software in either electronic or hard copy form.
    # *****************************************************************************


    # Hook called when a sequence finishes rendering (even if unsuccessful).
    # moduleName : Name of the rendering module -- String.
    # sequenceName : Name of the rendered sequence -- String.
    # elapsedTimeInSeconds : number of seconds used to render -- Float
    def renderEnded(moduleName, sequenceName, elapsedTimeInSeconds):
    pass


    # Hook called when a sequence finishes playback (even if unsuccessful).
    # sequenceName : Name of the rendered sequence -- String.
    # fps : FPS -- Float
    # debugInfo: Debugging Playback Information -- Dict
    def playbackEnded(sequenceName, fps, debugInfo):
    pass


    # Hook called when the user changes the video preview device. The following
    # values are read from the init.cfg VideoPreviewDevice keyword.
    # description : Description of the video preview device -- String
    # (ex : "1920x1080@5994i_free")
    # width : Width of the preview device -- Integer.
    # height : Height of the preview device -- Integer.
    # bitDepth : Bit depth of the preview device -- Integer.
    # rateString : Rate of the preview device -- String.
    # (ex : "6000i")
    # syncString : Sync source of the preview device -- String.
    # (ex : "freesync")
    def previewWindowConfigChanged(description,width,height,bitDepth,
    rateString,syncString):
    pass


    # Hook returning the custom ui actions to display to the user in the
    # contextual menu.
    #
    # Returns a tuple of group dictionaries.
    #
    # A group dictionary defines a custom menu group where keys defines
    # the group.
    #
    # Keys:
    #
    # name: [String]
    # Name of the action group that will be created in the menu.
    #
    # actions: [String]
    # Tuple of action dictionary which menu items will be created
    # in the group.
    #
    # An action dictionary of userData where the keys defines
    # the action
    #
    # Keys:
    #
    # name: [String]
    # Name of the action that will be passed on customUIAction
    # callback.
    #
    # caption: [String]
    # Caption of the menu item.
    #
    # For example: 2 menu groups containing 1 custom action
    #
    # def getCustomUIActions():
    #
    # action1 = {}
    # action1[ "name" ] = "action1"
    # action1[ "caption" ] = "Action Number 1"
    #
    # group1 = {}
    # group1[ "name" ] = "Custom Group 1"
    # group1[ "actions" ] = ( action1, )
    #
    # action2 = {}
    # action2[ "name" ] = "action2"
    # action2[ "caption" ] = "Action Number 2"
    #
    # group2 = {}
    # group2[ "name" ] = "Custom Group 2"
    # group2[ "actions" ] = ( action2, )
    #
    # return ( group1, group2 )
    #
    #
    def getCustomUIActions():
    pathcopyaction = dict(name='pathcopy', caption='Copy to clipboard')
    pathcopygrp = dict(name='Clip path', actions=(pathcopyaction,))
    return (pathcopygrp,)

    # Hook called when a custom action is triggered in the menu
    #
    # info [Dictionary] [Modifiable]
    # Information about the custom action,
    #
    # Keys:
    #
    # name: [String]
    # Name of the action being triggered.
    #
    # selection: [Tuple]
    # Tuple of wiretap ids.
    #
    # userData [Dictionary] [Modifiable]
    # Dictionary that is passed to getCustomUIActions.
    #
    def customUIAction(info, userData):
    if info['name'] == 'pathcopy':
    import re, os
    import PySide.QtGui as qtg
    import libwiretapPythonClientAPI as wt

    qa = qtg.QApplication.instance()
    paths = []

    wt.WireTapClientInit()
    wtserver = wt.WireTapServerHandle('localhost')
    wtmeta = wt.WireTapStr()
    for wtid in info['selection']:
    wtclip = wt.WireTapNodeHandle(wtserver, wtid)
    wtclip.getMetaData('EDL', '', 1, wtmeta)
    wtedl = wtmeta.c_str()
    for line in wtedl.splitlines():
    if 'ORIGIN' in line and re.match('^DLEDL: EDIT:[0-9]+ ORIGIN: .+$', line):
    path = line.split(':')[3][1:]
    paths.append(path)
    pathstogether = '\n'.join(paths)
    print "Copying to clipboard: " + pathstogether
    qa.clipboard().setText(pathstogether)

    # Hook called when starting the application and when switching project
    # This value will be used as default for the rename shotname dialog
    #
    # project: [String]
    # Usually called with current project.
    #
    # Ex: if project == "project_name":
    # return "<track>_<segment>_project"
    # return "<track>_<segment>_global"

    def timelineDefaultShotName( project ):
    return ""