# Copyright 2009 Autodesk, Inc.  All rights reserved.
# Use of this software is subject to the terms of the Autodesk license agreement 
# provided at the time of installation or download, or which otherwise accompanies
# this software in either electronic or hard copy form.
#
# Script description:
# Find a Device (from its name) in the scene and start it
#
# Topic:FBDevice, FBScene, FBPlayerControl
#

from pyfbsdk import *

#Change the name of the following value to match your device name
DeviceName = "MyDevice"

def FindDevice( pName ):
    lResult = None
    lDeviceList = FBSystem().Scene.Devices

    if lDeviceList:
        #print "get camera device"
        for lDevice in lDeviceList:
            #print "Device Name = %s" % lDevice.Name    
            if lDevice.Name == pName:
                lResult = lDevice
                break
    else:
        print 'No device found'

    return lResult


#Actual script
lDevice = FindDevice( DeviceName )
if lDevice:
    lDevice.Live = True
    lDevice.RecordMode = True
    lDevice.Online = True

    lPlayer = FBPlayerControl()
    #First argument for Record is to override the take, second one is to copy the data
    #Uncomment the following lines to automatically record
    #lPlayer.Record(False, True)
    #lPlayer.Play(False)
else:
    print 'No device found'