Override Nuke Studio context template using new API
0

2 posts in this topic

Hello Guys,

i am just wondering if there is any possibility to override those context templates by the new api using hook located on a FTRACK_CONNECT_PLUGIN_PATH instead of rewriting your default context templates delivered in connect package. I just tried something like this but it doesn't work so far. Thank you !

import ftrack_api
import ftrack_api.event.base


def get_sample_context_template(event):
    '''Return context templates for Nuke Studio.'''
    # Define tag regular expressions.
    return [{
        'name': 'Sample Shot',
        'description': (
            'Match name before and after dash. '
            'Example: ch01_dragon_0010 will be matched as sequence with name '
            'ch01 and a shot named ch01_dragon_0010.'
        ),
        'expression': ''
    }]

def register(session, **kw):
    '''Register plugin.'''

    # Validate that session is an instance of ftrack_api.Session. If not,
    # assume that register is being called from an incompatible API
    # and return without doing anything.
    if not isinstance(session, ftrack_api.Session):
        # Exit to avoid registering this plugin again.
        return

    session.event_hub.subscribe('topic=ftrack.connect.nuke-studio.get-context-templates',get_sample_context_template)

Share this post


Link to post
Share on other sites

Resolution for now is to use legacy API and override application launch like this

 

import os

import ftrack
import ftrack_connect.application

NUKE_STUDIO_APPLICATION_HOOK = os.path.abspath(
    os.path.join(os.path.dirname(__file__), '../../../application_hooks/nuke_studio_context_template')
)


def modify_application_launch(event):
    """Modify the application environment to include  our location plugin."""
    environment = event['data']['options']['env']

    ftrack_connect.application.appendPath(
        NUKE_STUDIO_APPLICATION_HOOK,
        'FTRACK_EVENT_PLUGIN_PATH',
        environment
    )


def register(registry, **kw):
    """Register application launch hook plugin."""

    # Validate that registry is the correct ftrack.Registry. If not,
    # assume that register is being called with another purpose or from a
    # new or incompatible API and return without doing anything.
    if registry is not ftrack.EVENT_HANDLERS:
        # Exit to avoid registering this plugin again.
        return

    ftrack.EVENT_HUB.subscribe(
        'topic=ftrack.connect.application.launch and data.application.identifier=nuke_studio*',
        modify_application_launch
    )

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
0