Working with the Camera Settings

First we need to get the camera object. Here is a quick example of selecting a camera called Main camera. Then we use ToCamera to get the VUECamera Class object so we can manipulate the camera specific settings.

[codesyntax lang=”python”]
DeselectAll()
SelectByName(“Main camera”)
Obj=GetSelectedObjectByIndex(0)
Camera = Obj.ToCamera()
[/codesyntax]

Once we have a VUECamera Class object we can get and set its settings. In this example we’ll get its exposure and increase it by 2.

[codesyntax lang=”python”]
DeselectAll()
SelectByName(“Main camera”)
Obj=GetSelectedObjectByIndex(0)
Camera = Obj.ToCamera()
Exposure=Camera.Exposure()
Exposure=Exposure+2
Camera.SetExposure (Exposure)
[/codesyntax]

Now we aren’t always going to be sure if an object is a camera or not. We can check if it is using isCamera.

[codesyntax lang=”python”]
DeselectAll()
SelectByName(“Main camera”)
Obj=GetSelectedObjectByIndex(0)
if Obj.IsCamera():
print “It’s a camera”
else:
print “It’s not a camera”

DeselectAll()
SelectByName(“Sun light”)
Obj=GetSelectedObjectByIndex(0)
if Obj.IsCamera():
print “It is a camera”
else:
print “It’s not a camera”
[/codesyntax]

 

If you want to check if the object you got back from ToCamera really is a VUECamera Class object:

[codesyntax lang=”python”]
DeselectAll()
SelectByName(“Main camera”)
Obj=GetSelectedObjectByIndex(0)
Camera = false
Camera = Obj.ToCamera()
if Camera:
print “It is a Camera”

DeselectAll()
SelectByName(“Sun light”)
Obj=GetSelectedObjectByIndex(0)
Camera2 = false
Camera2 = Obj.ToCamera()

if Camera2 is None:
print “It is not a Camera”
[/codesyntax]

Vue has quite a few functions for working just with the Camera object to get and set various Camera specific features:

  • DepthOfField
  • Exposure
  • Focal
  • FocusDistance
  • HorizontalFilmShift
  • LensAberration
  • SetDepthOfField
  • SetExposure
  • SetFocal
  • SetFocusDistance
  • SetHorizontalFilmShift
  • SetLensAberration
  • SetVerticalFilmShift
  • VerticalFilmShift
Feature Command Default Example
Get the Camera’s Depth of Field Setting DepthOfField ()
DeselectAll()
SelectByName("Main camera")
Obj=GetSelectedObjectByIndex(0)
Camera = Obj.ToCamera()
DoF=Camera.DepthOfField ()
print DoF
Set the Camera’s Depth of Field Setting SetDepthOfField (float fNewDepthOfField) 0.0

DeselectAll()
SelectByName("Main camera")
Obj=GetSelectedObjectByIndex(0)
Camera=Obj.ToCamera()
Camera.SetDepthOfField (20.5)
Get the Camera’s Exposure Setting Exposure
DeselectAll()
SelectByName("Main camera")
Obj=GetSelectedObjectByIndex(0)
Camera = Obj.ToCamera()
E=Camera.Exposure ()
print E
Set the Camera’s Exposure Setting SetExposure (float fNewExposure)
DeselectAll()
SelectByName("Main camera")
Obj=GetSelectedObjectByIndex(0)
Camera=Obj.ToCamera()
Camera.SetExposure (0.5)
Get the Camera’s Focal Setting Focal
DeselectAll()
SelectByName("Main camera")
Obj=GetSelectedObjectByIndex(0)
Camera=Obj.ToCamera()
F=Camera.Focal ()
print F
Set the Camera’s Focal Length SetFocal (float fNewFocal) 35.0
DeselectAll()
SelectByName("Main camera")
Obj=GetSelectedObjectByIndex(0)
Camera=Obj.ToCamera()
Camera.SetFocal (90)
Get the Camera’s Focus Distance FocusDistance ()
DeselectAll()
SelectByName("Main camera")
Obj=GetSelectedObjectByIndex(0)
Camera = Obj.ToCamera()
FD =Camera. FocusDistance ()
print FD
Set the Camera’s Focus Distance SetFocusDistance (float fNewFocus) 100.0
DeselectAll()
SelectByName("Main camera")
Obj=GetSelectedObjectByIndex(0)
Camera = Obj.ToCamera()
Camera.SetFocusDistance (290)
Get the Camera’s Horizontal Film Shift Setting HorizontalFilmShift ()
DeselectAll()
SelectByName("Main camera")
Obj=GetSelectedObjectByIndex(0)
Camera = Obj.ToCamera()
HFS=Camera. HorizontalFilmShift ()
print HFS
Set the Camera’s Horizontal Film Shift Setting Set Horizontal FilmShift (float fShift)
DeselectAll()
SelectByName("Main camera")
Obj=GetSelectedObjectByIndex(0)
Camera = Obj.ToCamera()
Camera.SetHorizontalFilmShift (2)
Get the Camera’s Vertical Film Shift Setting VerticalFilmShift ()
DeselectAll()
SelectByName("Main camera")
Obj=GetSelectedObjectByIndex(0)
Camera = Obj.ToCamera()
VFS =Camera.VerticalFilmShift ()
print VFS
Set the Camera’s Vertical Film Shift Setting SetVerticalFilmShift (float fShift)
DeselectAll()
SelectByName("Main camera")
Obj=GetSelectedObjectByIndex(0)
Camera=Obj.ToCamera()
Camera.SetVerticalFilmShift (2)
Get the Camera’s Lens Aberration Setting LensAberration (float fAberration)
DeselectAll()
SelectByName("Main camera")
Obj=GetSelectedObjectByIndex(0)
Camera = Obj.ToCamera()
LA=Camera.LensAberration()
print LA
Set the Camera’s Lens Aberration Setting SetLensAberration (float fAberration)
DeselectAll()
SelectByName("Main camera")
Obj=GetSelectedObjectByIndex(0)
Camera=Obj.ToCamera()
Camera.SetLensAberration(2)

You can see more of these functions in action in two longer scripts I wrote to load and save camera settings as CSV files.

impworks © Copyright Mark Caldwell 1996 - 2024