# 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. # # Topic: FBCamera, FBColor, FBScene # from pyfbsdk import FBSystem, FBModelList, FBColor, FBGetSelectedModels # Because FBGetSelectedModels returns only model references that cannot be # changed into other types, we have this function that tries to match up # the name of the model passed as a parameter, and see if there is a camera # listed in the camera list with the same name. If so, we return this camera. # This function returns None if no camera is found. def GetCamera( pModel ): lSystem = FBSystem() # Set the default return value. lResult = None # Lets find a camera with the same name. for lCamera in lSystem.Scene.Cameras: if pModel.Name == lCamera.Name: lResult = lCamera break # Cleanup. del( lSystem, lCamera ) return lResult # We build the model list object that must be passed to FBGetSelectedModels. lModelList = FBModelList() FBGetSelectedModels( lModelList ) # Iterate thru the list of models selected. for lModel in lModelList: # See if the object is a camera. lSelectedCamera = GetCamera( lModel ) # If the lSelectedCamera is not None. if lSelectedCamera: # If we do have a camera selected, use its BackGroundColor for all # the other cameras in the system. for lCamera in FBSystem().Scene.Cameras: # WARNING: Due to a problem with the implementation of the class # FBPropertyAnimatableColor, we have to create a tuple from the # string representation of the BackGroundColor. This tuple is then # used as a parameter in the constructor of FBColor. lCamera.BackGroundColor = FBColor( eval( str( lSelectedCamera.BackGroundColor ))) # Cleanup. del( lCamera ) # Cleanup. del( lSelectedCamera, lModel ) # Once we have found a camera, we do not bother to look at the other # Selected models. break # cleanup. # Cleanup everything. del( GetCamera ) del( lModelList ) del( FBSystem, FBModelList, FBColor, FBGetSelectedModels )