I'm writing a script for Maya where I try to save a shot from a sequence with only its own camera.
import maya.cmds as mc
list_of_shots_to_delete = mc.sequenceManager( listShots=True )
list_of_shots_to_delete.remove( my_shot )
for k in list_of_shots_to_delete:
cam = getShotsCamera( k )
if cam != None:
if cam == getShotsCamera( my_shot ):
print cam + " is needed!"
else:
mc.delete( getShotsCamera( k ) )
mc.lockNode( k, lock=False )
print "Shot "+ k +" deleted!"
mc.delete( k )
Basically what this loop does is, for each unneeded shot in the sequence, deletes its camera (unless it is the same camera from the shot I want to save) and then deletes the shot itself. For some reason, if a shot shares the same camera as another, the last one of then in the list_of_shots_to_delete
list won't be deleted (it will skip the last 3 lines of this loop).
Can anybody help?