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: 

Change Camera Attributes via Python

1 REPLY 1
Reply
Message 1 of 2
bfr26
829 Views, 1 Reply

Change Camera Attributes via Python

I am relatively new to python in mobu and am trying to change attributes of a certain camera via python. Specifically the Focal Length and toggling items such as Title Safe and the grid.

What i can't figure out is how to select a camera based on its name and then proceed to change its attributes.

Any suggestions?

Thanks!
1 REPLY 1
Message 2 of 2
castortroy182
in reply to: bfr26

Hi,

here is a quick example how to get access to the cameras in your mobu-scene:


from pyfbsdk import *

# we are getting an object instance of the whole scene
myScene = FBSystem().Scene

# we know that myScene.Cameras is a list of objects, the cameras
# Therefore we iterate through this list by every object and print out the name
for obj in myScene.Cameras:
print obj.Name


This is a very simple way to get any information about your scene. Look up "FBScene" in the Mobu SDK Help(Mobu-Menu->Help->Motionbuilder SDK Help). There you can find any other attributes or functions this class holds or can execute if it is instanced as an object we have access to via python.
If you look for FBCamera(the camera object class) you will find a huge amount of camera attributes you can reach, e.g. FocalLength. 🙂
If we add this knowledge to our little script:

from pyfbsdk import *

myScene = FBSystem().Scene

for obj in myScene.Cameras:
#prints out the name
print obj.Name
#prints out the FocalLength
print obj.FocalLength


That's it for the start. 🙂

Cheers,

Chris

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

Post to forums  

Autodesk Design & Make Report