Add a custom tool the the ftrack menu within Maya¶
In this section we demonstrate how to add your own studio tool to the Maya plug-in, which in this case updates the status of the task you have launched to “In progress”. We add its menu item to the ftrack menu in userSetup.py:
mypipeline/ftrack-connect-pipeline-maya/resource/scripts/userSetup.py
1..
2
3def initialise():
4
5 ..
6
7 maya_utils.init_maya()
8
9 cmds.menuItem(
10 parent=ftrack_menu,
11 label='In Progress',
12 command=(functools.partial(maya_utils.set_task_status, 'in progress', session, logger))
13 )
14
15 maya_utils.scene_open(session, logger)
In DCC custom_commands.py, we add the corresponding set_task_status
function:
mypipeline/ftrack-connect-pipeline-maya/source/ftrack_connect_pipeline_maya/utils/custom_commands.py
1
2def set_task_status(status_name, session, logger, unused_arg=None):
3 '''Change the status of the launched task to *status*'''
4 task = session.query(
5 'Task where id={}'.format(os.environ['FTRACK_CONTEXTID'])
6 ).one()
7 status = session.query('Status where name="{}"'.format(status_name)).one()
8 logger.info(
9 'Changing status of task {} to {}'.format(task['name'], status_name)
10 )
11 task['status'] = status
12 session.commit()