No problem :) It's worth building up a library of utility functions like the above. It cuts down the amount of donkey work and repetitive coding you have to do from script to script. Here's another one you might find useful at some point, it takes an item type ( eg mask, groupLocator, mesh etc) and a name and returns the ID (or None if it doesn't exist):
def GetItemID(type, name):
"""
Return the ID string of an item of known 'type' and 'name'
"""
numitems = lx.eval('query sceneservice %s.N ?' % type)
if numitems > 0:
for x in xrange(numitems):
if lx.eval('query sceneservice %s.name ? {%s}' % (type, x)) == name:
return lx.eval('query sceneservice %s.ID ? {%s}' % (type, x))
else:
return None
else:
return None
you'd use it like the following:
cam_id = GetItemID('camera', 'Camera')
or
maskID = GetItemID('mask', 'Matr: Red')
etc