Paidi28 Posted March 10, 2016 Report Posted March 10, 2016 Hey I previously used the old API and was wondering should I move to the new one ? Is there anything that I currently can not do in it that I can do in the old one ? Is there any other resources or tutorials for using the API other than the documentation and the "Developing with ftrack" section of the docs ?
eight Posted March 15, 2016 Report Posted March 15, 2016 You can use both APIs together, so if there is something you cannot do with the new API, you can just fall back on the old API. I don't know where to find extra tutorials, but ftrack has a public bitbucket account with some examples you can study. Most of them seem to be using the old API though.
Björn Rydahl Posted March 17, 2016 Report Posted March 17, 2016 Hi, here are some links to docs of the new API that might help: http://ftrack-python-api.rtd.ftrack.com/en/stable/example/index.html http://ftrack-python-api.rtd.ftrack.com/en/stable/release/migrating_from_old_api.html Cheers
Paidi28 Posted March 21, 2016 Author Report Posted March 21, 2016 Hey, Björn, Not sure whether I should post a new post so will reply here first. I have created a script using the old API for populating ftrack from some outside data. I managed to get it working but it is quite slow so would like to use the new API. When I try something like this however I get an error TypeError: list indices must be integers, not str task['custom_attributes']['Category'] = item_dict['sub_type'] In the docs you have task['custom_attributes']['my_text_field'] = 'foo' Any idea where I am going wrong ?
Björn Rydahl Posted March 21, 2016 Report Posted March 21, 2016 Hey, what type of custom attribute is Category? If it is an enumerator you need to set it as a list: task['custom_attributes']['my_enum'] = ['some_value'] http://ftrack-python-api.rtd.ftrack.com/en/stable/example/custom_attribute.html#validation Let me know if that helps. Cheers
Paidi28 Posted March 22, 2016 Author Report Posted March 22, 2016 It is a text value on a Task object ? Edit* have since made some progress. My problem now appears to be that I cannot set the custom attribute or print their keys ? Thanks for the help! [] Traceback (most recent call last): File "C:\ftrack\NewAPIHandler.py", line 80, in <module> handler.create_new_asset(sg_dict) File "C:\ftrack\NewAPIHandler.py", line 46, in create_new_asset asset['custom_attributes']['Category'] = shotgun_item_dict['sg_sub_type'] File "C:\Python27\lib\site-packages\ftrack_api\collection.py", line 420, in __ setitem__ custom_attribute_value = self._get_entity_by_key(key) File "C:\Python27\lib\site-packages\ftrack_api\collection.py", line 386, in _g et_entity_by_key configuration_id = self.get_configuration_id_from_key(key) File "C:\Python27\lib\site-packages\ftrack_api\collection.py", line 403, in ge t_configuration_id_from_key raise KeyError(key) KeyError: 'Category'
Mattias Lagergren Posted March 23, 2016 Report Posted March 23, 2016 Hi, I see that you are trying ot access it on an asset, does it exist on the asset or only on Task? If you do: print asset['custom_attributes'].keys() you can see what is available.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.