Jump to content

entityTypes during events


Recommended Posts

I'm trying to make an event that runs some code whenever a shot is created, deleted or renamed.

I'm running into 1 problem and 1 annoyance/slowdown which both stem from the same issue of several types, ie sequence, shot and task, all being handled as entityType "task".
- I currently have to use the entityId and query TypedContext and check if entity isinstance session.types['Shot']. This adds an unnecessary  0.3 second query every time the event is run in order to just check if an entity is a shot. 
Is this really the most optimized way to figure out if something is a sequence, shot or task? Seems like having a subEntityType attribute in the event data dict that stores what subtype it is would save a lot of querying.
- I'm also running into the problem of once a shot is removed I can no longer query the removed entityId, as it returns None, to check if what was deleted was of type shot or not.
How do I figure out if it was specifically a shot that was just deleted?

Link to comment
Share on other sites

Hi Alex,


You should be able to use the objectTypeId on the event, to distinguish between Sequences, Shots and Tasks. When your script starts, get the ids of each relevant ObjectType and then just compare against those. objectTypeId is even available on the event for deleted shots.

Link to comment
Share on other sites

>>> for object_type in session.query("select id, name from ObjectType"):
>>>     print object_type["id"], object_type["name"]
4be63b64-5010-42fb-bf1f-428af9d638f0 Asset Build
01decdd1-51cb-11e3-9d5b-20c9d0831e59 Milestone
bad911de-3bd6-47b9-8b46-3476e237cb36 Shot
11c137c0-ee7e-4f9c-91c5-8c77cec22b2c Task


Link to comment
Share on other sites


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

  • Create New...