Jump to content

How to query custom attributes ?


deex

Recommended Posts

Posted

Hello,

 

I have added custom attributes to shots.

When i do a query like this :

tasks = session.query(                          'Shot where name is {0} and '                          'parent.name is {1} and '                          'project.name is {2} '                          .format(shotName,                                  sequenceName,                                  projectName                                  )                          )

My custom attributes are not here. How can i do this please ?

Posted

Doesn't work :

 

session = ftrack_api.Session()    shots = session.query(                          #=====================================================                          # 'select fstart, fend, duration, startHandles, endHandles, fsequenceend, fsequencestart '                          #=====================================================                          'Shot where name is {0} and '                          'parent.name is {1} and '                          'project.name is {2} '                          .format(shotName,                                  sequenceName,                                  projectName                                  )                          )    for i in shots:        print i.keys()        print i['custom_attributes']
    print i['custom_attributes']  File "C:\Python27\lib\site-packages\ftrack_api\entity\base.py", line 167, in __getitem__    raise KeyError(key)KeyError: 'custom_attributes'
 
  • 5 weeks later...
  • 2 weeks later...
Posted

Hi,

 

Code example :

import ftrack_apisession = ftrack_api.Session()projects = session.query(                         'Project where status is active and '                         '(full_name like "ftrack test")')tasks = session.query('Task where project.id is "{0}"'.format(projects[0]['id'])).all()for task in tasks:    customAttr = task['custom_attributes']    print customAttr.keys()    for attr in customAttr:        print attr.keys()

The project :

1449085546-2015-12-02-114403.png

 

Custom attribute (some are hierarchical) :

1449085550-2015-12-02-114438.png

 

Code result :

[][][][][][][][][][][][][][][]

Expected result :

Something not empty.

 

Hey,

 

Could you provide some more information, such as:

 

* Code example

* Information about the project structure and custom attributes you are using

* Expected result

 

 

More information here:

http://ftrack-python-api.rtd.ftrack.com/en/latest/example/custom_attribute.html

Posted

Ah, all my custom attributes are hierarchical. It is why it doesn't work.

 

Hi deex,

 

I noticed that you are querying for tasks but the screenshot you shared is showing a Sequence.  Do you have custom attributes on the tasks as well, other than hierarchical?

 

Accessing hierarchical attributes are not supported at present:

http://ftrack-python-api.rtd.ftrack.com/en/latest/example/custom_attribute.html#hierarchical-attributes

  • 1 year later...
Posted

is there news on this topic ?
From the docs it reads as though it was possible, only I need to loop through all parents myself, But I cannot even see hierarchical  attr in the custom attributes keys ...

cheers
 

Posted
On 17/02/2017 at 4:56 PM, Nebukadhezer said:

is there news on this topic ?
From the docs it reads as though it was possible, only I need to loop through all parents myself, But I cannot even see hierarchical  attr in the custom attributes keys ...

No news at the moment. On your custom attribute configuration there should be a `is_hierarchical` to indicate if it is a an hierarchical attribute..

Archived

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

×
×
  • Create New...