Mike Posted June 9, 2016 Report Share Posted June 9, 2016 I'm trying to figure out how to query what an item is based on user selection. In my tool, a user might be selecting a Sequence, Task, Shot, etc and I'd like different things to happen based on their selection. Is there any way to query this with the new API? The docs seem to just show how to query something only if you know exactly what entity type you want. I have this right now: dir_contents = [] for item in project['children']: dir_contents.append( item ) for item in dir_contents: item_name = item['name'] item_type = item['context_type'] item_id = item['id'] When I tested this code out by selecting a Sequence entity, I printed out every attribute and expected to find 'sequence' as a value somewhere, but only the attribute, context_type, resulted in something close to what I was looking for ( print item['context_type'] resulted in 'task' as a value ) Thanks for any help! Link to comment Share on other sites More sharing options...
Lucas Correia Posted June 10, 2016 Report Share Posted June 10, 2016 Hi Mike, There is two abstract types in the API schema which represent objects in the project hierarchy. Context - Can be either a Project, or a TypedContext TypedContext - An object in the project hierarchy: e.g. a Folder, Task or Sequence. A TypedContext will have a object_type relation to an ObjectType entity. This entity will in turn have some information about which kind of object it is. The object_type information is used behind the scene to generate the dynamic types in the API. Below is an example how you can use this information: >>> sequence = session.query('Sequence').first() >>> print sequence.entity_type Sequence >>> print sequence['object_type']['name'] Sequence >>> print isinstance(sequence, session.types['Sequence']) True Regards, Lucas Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.