Skip to content

Example: Creating a Shot

kporangehat edited this page Dec 10, 2010 · 3 revisions

To create a Shot, you need to provide the following values:

  • project : this is a link of the Project the Shot belongs to. It should be a dictionary like {"type":"Project","id": 123} where the id value is the id of the Project.
  • code (also known as the name of the Shot)
  • optionally any other info you want to provide
data = 
{ 
    'project': {"type":"Project","id": 4},
    'code': '100_010',
    'description': 'Open on a beautiful field with fuzzy bunnies',
    'sg_status_list': 'ip' 
}
result = sg.create('Shot', data)

This will create a new Shot named "100_010" in the Project "Gunslinger" (which has id 4).

  • data is a list of key/value pairs where the key is the column name to update and the value the value.
  • sg is the Shotgun API instance.
  • create() is the API method we are calling. We provide it with the entity type we're searching for and the data we're setting.

The variable result now contains a dictionary hash with the Shot information you created.

{
    'code': '100_010', 
    'description': 'Open on a beautiful field with fuzzy bunnies', 
    'id': 2410, 
    'project': {'id': 4, 'name': 'Demo Project', 'type': 'Project'}, 
    'sg_status_list': 'ip', 
    'type': 'Shot'
}