ftrack Python API
latest
  • Introduction
  • Installing
  • Tutorial
  • Understanding sessions
  • Working with entities
  • Querying
  • Handling events
  • Caching
  • Locations
  • Usage examples
    • Working with projects
    • Working with components
    • Using review sessions
    • Using metadata
    • Using custom attributes
    • Using custom attributes links
    • Managing custom attributes
    • Using link attributes
    • Using scopes
    • Managing jobs
    • Using notes
    • Using lists
    • Using timers
    • Working with assignments and allocations
    • Working with thumbnails
    • Encoding media
    • Using entity links
      • Using asset version link shortcut
    • Publishing for web review
    • Publishing versions
    • Working with user security roles
    • Working with Task Templates
    • Sync users with LDAP
    • Invite user
    • Creating workflow schemas
  • API Reference
  • Event list
  • Environment variables
  • Security and authentication
  • Release and migration notes
  • Glossary
ftrack Python API
  • Docs »
  • Usage examples »
  • Using entity links
  • Edit on Bitbucket

Using entity links¶

A link can be used to represent a dependency or another relation between two entities in ftrack.

There are two types of entities that can be linked:

  • Versions can be linked to other asset versions, where the link entity type is AssetVersionLink.
  • Objects like Task, Shot or Folder, where the link entity type is TypedContextLink.

Both AssetVersion and TypedContext objects have the same relations incoming_links and outgoing_links. To list the incoming links to a Shot we can use the relationship incoming_links:

for link in shot['incoming_links']:
    print(link['from'], link['to'])

In the above example link[‘to’] is the shot and link[‘from’] could be an asset build or something else that is linked to the shot. There is an equivalent outgoing_links that can be used to access outgoing links on an object.

To create a new link between objects or asset versions create a new TypedContextLink or AssetVersionLink entity with the from and to properties set. In this example we will link two asset versions:

session.create('AssetVersionLink', {
    'from': from_asset_version,
    'to': to_asset_version
})
session.commit()

Using asset version link shortcut¶

Links on asset version can also be created by the use of the uses_versions and used_in_versions relations:

rig_version['uses_versions'].append(model_version)
session.commit()

This has the same result as creating the AssetVersionLink entity as in the previous section.

Which versions are using the model can be listed with:

for version in model_version['used_in_versions']:
    print('{0} is using {1}'.format(version, model_version))
Next Previous

© Copyright 2014, ftrack Revision 825de44d.

Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: latest
Versions
master
latest
stable
2.3.0
2.2.0
2.2.0rc1
2.1.2
2.1.1
2.1.0
2.0.0
backlog-threading-story
backlog-fix-readthedocs-build
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.