Hi Guys
Get a problem with this command.
I try to retrieve my context variables from a work file path.
lets say my file is here
path = '/s/prods/shotgun_test/projects/sahara_test/assets/char/Totor/maya/scenes/mod/gdubost/char-Totor-base-zbr-v001.ma'
so i do
import sgtk
tk = sgtk.sgtk_from_path( path )
context = tk.context_from_path(path)
my context is
# Result: <Sgtk Context: Project: {'type': 'Project', 'id': 73, 'name': 'Sahara Test'}
Entity: {'type': 'Asset', 'id': 842, 'name': 'Totor'}
Step: {'type': 'Step', 'id': 10, 'name': 'Model'}
Task: None
User: {'type': 'HumanUser', 'id': 39, 'name': 'gdubost'}
Shotgun URL: https://mikrosca.shotgunstudio.com/detail/Asset/842
Additional Entities: []> #
tpl = tk.template_from_path(path)
<Sgtk TemplatePath maya_asset_work: assets/{sg_asset_type}/{Asset}/maya/scenes/{Step}/{user}/{sg_asset_type}-{Asset}-{asset_variant}-{task_name}-v{version}.ma>
when i try the following
context.as_template_fields(tpl)
I got
# Error: TankError: file /s/prods/shotgun_test/software/sahara_test_dev_gdubost/install/core/python/tank/context.py line 445: Key '<Sgtk StringKey task_name>' in template '<Sgtk TemplatePath maya_asset_work: assets/{sg_asset_type}/{Asset}/maya/scenes/{Step}/{user}/{sg_asset_type}-{Asset}-{asset_variant}-{task_name}-v{version}.ma>' could not be populated by context 'Model, Asset Totor' because the context does not contain a shotgun entity of type 'Task'! #
the "task_name" has been declared in my asset_step.yml like that
task_name:
type: str
shotgun_entity_type: Task
shotgun_field_name: sg_task_code #where sg_task_code is a new field declared in the Task entity
So i dont undertsand why the script not able to get task_name='zbr' in my exemple
Thx for helping
Cheers
Guy