Skip to content

Example: Create a Version and link it to a Shot

kporangehat edited this page Dec 10, 2010 · 6 revisions

You've just created a sweet new Version (or Take) of your shot. Now you want to update Shotgun and create a new Version linked to the Shot.

Find the Shot

First we need to find the Shot since we'll need to know know its id to link our Version to it.

filters = [ ['project','is', {'type':'Project','id':4}],
	     ['code', 'is', '100_010'] ]
shot = sg.find_one('Shot',filters)

Create the Version

Now we can create the Version with the link to the Shot

data = { 'project': {'type':'Project','id':4},
         'code': '100_010_anim_v1',
         'description': 'first pass at opening shot with bunnies'
         'sg_path_to_frames': '/v1/gun/s100/010/frames/anim/100_010_animv1_jack',
         'sg_status_list': 'rev',
         'entity': {'type':'Shot', 'id':shot['id']},
         'user': {'type':'HumanUser', 'id':165} }
result = sg.create('Version', data)

This will create a new Version named '100_010_anim_v1' linked to the Shot '100_010' in the Project 'Gunslinger'.

  • data is a list of key/value pairs where the key is the column name to update and the value is the value.
  • project and 'code' are required
  • description and 'sg_path_to_frames' are just text fields that you might want to update as well
  • sg_status_list is the status column for the Version. Here we are setting it to "rev" (Pending Review) so that it will get reviewed in the next dailies session and people will ooh and aaah.
  • entity is where we link this version to the Shot. Entity columns are always handled with this format. You must provide the entity type and its 'id'.
  • user is another entity column where we set the artist responsible for this masterpiece. In this example, I know the 'id' that corresponds to this user, but if you don't know the id you can look it up by searching on any of the fields, similar to what we did for the Shot above, like:
filters = [ ['login', 'is', 'jschmoe'] ]
user = sg.find('HumanUser',filters)

The variable result now contains the id of the new Version that was created.

214