Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® MotionBuilder® / Python / Finding current camera in switcher while looping.
  RSS 2.0 ATOM  

Finding current camera in switcher while looping.
Rate this thread
 
60397
 
Permlink of this thread  
avatar
  • Newt Zac
  • Posted: 27 September 2011 05:14 AM
  • Total Posts: 6
  • Joined: 20 December 2010 11:39 AM

Hi,

I am able to query what the current camera is in the camera switcher at a given moment but I am trying to query the current camera while looping over the scene’s frame range.  While looping I am able to get an accurate current camera index update (.CurrentCameraIndex) but the name of the camera is not updating while looping over each frame.  Anyone have a solution to this problem?  I also noticed that the camera switcher has in it’s property list a Camera Index property but not property for Current Camera.  Maybe this is why it isn’t working. 

Here is the code I am trying to use:

for i in range (1, 50):
CS = FBCameraSwitcher()
curCam = CS.CurrentCamera
print curCam.LongName
FBPlayerControl().StepForward()
FBSystem().Scene.Evaluate()

I am calling the FBCameraSwitcher in the loop on purpose.  This was the only way to get the camera index to update.  The Evaluate command doesn’t seem to help whether at the top of the loop or bottom.

Thanks in advanced.......



Replies: 0
avatar
  • andylt1
  • Posted: 27 September 2011 06:12 AM

I’ve ran into the same issue. Pretty annoying that something that should be simple is so hard.

I’ve also tried using FBCameraSwitcher().UseEvaluateSwitch(), but no luck. As mentioned FBSystem().Scene.Evaluate() does nothing too.

In the docs it mentioned that setting FBCameraSwitcher().CurrentCamera = NULL uses the auto update switch

“CurrentCamera - Read Write Property: Camera currently being used by the switcher. Set to NULL to turn on evalute switch, otherwise manual switch.”

But NULL throws an error in python.

Anyone solved this?

a.



Replies: 0
avatar
  • Tistatos
  • Posted: 28 September 2011 09:31 PM

This is my, not so elegant, but working solution:

def camSwitchData():

    
lCameraSwitcher FBCameraSwitcher()
    
lCameraIndexProp lCameraSwitcher.PropertyList.Find("Camera Index")
    
lCamIndexProp lCameraIndexProp.GetAnimationNode()

    
cameras GetCams()

    
#We print the the frame the camera switcher switches camera
    
for i,key in enumerate(lCamIndexProp.FCurve.Keys):
            print 
"%s :'%s'" %(key.Time.GetTimeString(), cameras[int(key.Value)-1])


    
def GetCams():
"""
The index of the cameras switcher is in the same order as the scenes cameras
Excluding the producer cameras.
"""
    
cameras []
    
#Get All Cameras
    
for cam in FBSystem().Scene.Cameras:
        
cameras.append(cam.Name)

    
#Clean out the producer cameras
    #we have to loop twice or we get IndexOutOfRange Issues.

    
camsToRemove []
    
for i in range(len(cameras)):
        if 
cameras[i].find('Producer') != -1:
            
camsToRemove.append(cameras[i])

    
#finally remove the cameras and return the cameralist.
    
for i in camsToRemove:
        
cameras.remove(i)    
    return 
cameras

So bascially the camera index of the camera switcher is the same as the scene’s cameras excluding the “producer-”.

And now you have a list when the cameras switch.



Replies: 0