Action - get right entity type using ftrack_api
2 2

6 posts in this topic

I am running a action on a sequence, shot, task and I get for all 'task' entity type.

How can I get the right entity type using the ftrack_api in an action?

def launch(self, event):
    '''
    @param event: ftrack event
    '''
    user_id = event['source'].get('user', {}).get('id', None)
    data = event['data']
    selection = data.get('selection', [])
    entity_type = selection[0]['entityType']
    entity_id = selection[0]['entityId']

    print entity_type

Share this post


Link to post
Share on other sites

I think the easiest solution may be to get the TypedContext (shot, sequence, task, etc.) from the id if it is a 'task':

entity = session.get('TypedContext', entity_id)

TypedContext is the common base-class, but you will get the correct subclass after the query.

Share this post


Link to post
Share on other sites

How can I get the entity in the ftrack_api if the ftrack type is tempdata?

Example:

legacy api:

temp = ftrack.TempData(id='becd972a-7a77-11e6-be67-005056a76761')

I tried this in the ftrack_api:

entity = session.get('TypedContext', "becd972a-7a77-11e6-be67-005056a76761")

but it returns None.

Thanks for the support!

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
2 2