Hi there, here is what we did to setup an asset library in Tank. We wanted to share it, as we guess others will want to build something like that. Comments are more than welcome !
Shotgun :
- Enabled the AssetLibrary entity.
- Added a Library "entity" field to Assets, accepting a AssetLibrary.
- Rule : if not left empty, then the Asset is part of library.
Schema :
- Added a "libraries" tree under project and project/work/humanuser, copied the "assets" tree under libraries/library.
- Added a library.yml under libraries, side by side with a library folder, entity_type: "AssetLibrary" and default project based filter.
- In librairies/library/assets/asset_type, changed the filter in asset.yml to include :
{ "path": "sg_library", "relation" : "is_not", "values" : [null] }
{ "path": "sg_library", "relation": "is", "values": [ "$library"] }
- In assets/asset_type ( the regular one, not under a libraries folder ) changed the filter in asset.yml to include ( didn't test the new is null filter ) :
{ "path": "sg_library", "relation": "type_is_not", "values": [ "AssetLibrary"] }
Config :
- Added a key in templates.yml
AssetLibrary :
type : str
- Added various template paths in templates.yml, e.g. :
maya_library_work: work/{HumanUser}/libraries/{AssetLibrary}/assets/{sg_asset_type}/{Asset}/{Step}/maya/{name}.v{version}.mb
maya_library_publish: libraries/{AssetLibrary}/assets/{sg_asset_type}/{Asset}/{Step}/publish/{TankType}/{name}/v{version}/{Asset}_{name}_v{version}.mb
- Added a library.yml env file, defining engines, apps and templates to use in library context.
Hooks :
- Added "AssetLibrary" in core/hooks/context_additional_entities.py
- Tweaked core/hooks/pick_environment.py "Asset" block :
elif context.entity["type"] == "Asset":
# Need to check if we are dealing with an Asset
# from a library or not
sg = self.parent.shotgun
sg_asset = sg.find_one( context.entity["type"], [ ['id', 'is', context.entity['id']] ], ['sg_library'] )
if sg_asset is not None and sg_asset['sg_library'] is not None :
return "library"
return "asset"