Jump to content

Linking or deep copy of Asset Builds


L Smallwood

Recommended Posts

Hi Ftrack,

Is it possible (either through the web UI or via the API) to either copy or link asset builds between projects, or even within the same project?

We’d like to set up two projects that will contain similar lists of asset builds, and have the asset builds in ProjectB be a kind of symlink to the asset builds in ProjectA.  That way, we could have different hierarchies in the projects, and could add extra stuff in ProjectB that won’t show up in ProjectA.  If the asset is deleted in ProjectA, the asset would be deleted in ProjectB as well.

Barring that, is there a way to do a “deep copy” of an asset between projects such that all associated data (published versions, components, file locations, etc) are copied as well?

Thank you!

Link to comment
Share on other sites

Hi,

you can use links to connect an asset build to a shot for example.

Either via the links tab in the sidebar for the asset build or using the gantt chart (links/dependencies).

 

But, the UI does currently not support adding links between two different projects. You can still add the links using the API:

http://ftrack-python-api.rtd.ftrack.com/en/stable/example/entity_links.html

between an asset in projectA and a shot in projectB and the link will show up in the web UI under the links tab.

 

There is currently not a way to "deep copy" like you describe. You could probably create the asset in the various projects and link the "master" asset to the child ones, setup an event listener that detects changes on the master and propagate those changes to the children using the links, but that would require some coding.

 

Best,

Björn

Link to comment
Share on other sites

Hi Bjorn, 

Thanks a bunch for the info.  I'm trying to create an entity link now and am hitting a problem.  When I try to link two asset builds in two different projects, I get this error:

In [16]: session.create('TypedContextLink', {'from': oAssetBuild1, 'to': oAssetBuild2})
---------------------------------------------------------------------------
UnrecognisedEntityTypeError               Traceback (most recent call last)
<ipython-input-16-0604c8440a83> in <module>()
----> 1 session.create('TypedContextLink', {'from': oAssetBuild1, 'to': oAssetBuild2})

/anaconda/lib/python2.7/site-packages/ftrack_api/session.pyc in create(self, entity_type, data, reconstructing)
    502 
    503         '''
--> 504         entity = self._create(entity_type, data, reconstructing=reconstructing)
    505         entity = self.merge(entity)
    506         return entity

/anaconda/lib/python2.7/site-packages/ftrack_api/session.pyc in _create(self, entity_type, data, reconstructing)
    511             EntityTypeClass = self.types[entity_type]
    512         except KeyError:
--> 513             raise ftrack_api.exception.UnrecognisedEntityTypeError(entity_type)
    514 
    515         return EntityTypeClass(self, data=data, reconstructing=reconstructing)

UnrecognisedEntityTypeError: Entity type "TypedContextLink" not recognised.

I'm following the instructions on the page you linked to -- any idea what I'm doing wrong?

Thanks,

Lori

Link to comment
Share on other sites

Hi Mattias,

Our ftrack version has been upgraded to 3.5.11.4590, and now I'm getting a different error with the same code I was running before:  that the asset build object (which shows up as a "task" type in the back end) is not JSON serializable.

The documentation states that 

 

Quote

 

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.

 

  •  

Since both of the objects I'm linking are tasks, I would expect them to link successfully as TypedContextLinks.  Are there further restrictions on linking than what's outlined in the docs?

Thanks,

Lori

Link to comment
Share on other sites

How are you creating the link and what error are you seeing? Also verify that the entities you are linking are what you expect the variables to be. 

 

I've verified that the following works as expected.

asset_build_1, asset_build_2 = session.query('AssetBuild limit 2')[:]
assert isinstance(asset_build_1, session.types['AssetBuild'])
assert isinstance(asset_build_2, session.types['AssetBuild'])
asset_build_link = session.create('TypedContextLink', {
    'from': asset_build_1,
    'to': asset_build_2
})
session.commit()


Regards,
Lucas

Link to comment
Share on other sites

Hi Lucas,

My code was using ftrack.getProject() to get the project entity, then looping through the asset builds using getAssetBuilds() to find the necessary assets to link.  Then I was trying to link those AssetBuilds (which show up as "task" objects in the back end like I mentioned) using the call to session.create('TypedContextLink').

Looks like I'll need to use session queries instead.  I'll give that a try, and if I have more difficulty I'll post to the API forum.

Thanks for your help.

-- Lori

 

Link to comment
Share on other sites

Hi Lori,

I see. The objects returned from the legacy API and the new API are not compatible. See migrating from the legacy API for more information. For more information on the API in general - see ftrack.com/developer

To get all asset builds on a project with the code "my_project",  you can use the following query:
 

asset_builds = session.query('AssetBuild where project.name is "my_project"')


Regards,
Lucas

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...