MotionBuilder Forum
Welcome to Autodesk’s MotionBuilder Forums. Share your knowledge, ask questions, and explore popular MotionBuilder topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Finding current camera in switcher while looping.

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
943 Views, 2 Replies

Finding current camera in switcher while looping.

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.......
2 REPLIES 2
Message 2 of 3
andylt
in reply to: Anonymous

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.
Message 3 of 3
tistatos
in reply to: Anonymous

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)



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.find('Producer') != -1:
camsToRemove.append(cameras)

#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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report