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.

  1. DeselectAll()
  2. SelectByName("Main camera")
  3. Obj=GetSelectedObjectByIndex(0)
  4. Camera = Obj.ToCamera()

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.

  1. DeselectAll()
  2. SelectByName("Main camera")
  3. Obj=GetSelectedObjectByIndex(0)
  4. Camera = Obj.ToCamera()
  5. Exposure=Camera.Exposure()
  6. Exposure=Exposure+2
  7. Camera.SetExposure (Exposure)

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.

  1. DeselectAll()
  2. SelectByName("Main camera")
  3. Obj=GetSelectedObjectByIndex(0)
  4. if Obj.IsCamera():
  5. print "It's a camera"
  6. else:
  7. print "It's not a camera"
  8. DeselectAll()
  9. SelectByName("Sun light")
  10. Obj=GetSelectedObjectByIndex(0)
  11. if Obj.IsCamera():
  12. print "It is a camera"
  13. else:
  14. print "It's not a camera"

 

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

  1. DeselectAll()
  2. SelectByName("Main camera")
  3. Obj=GetSelectedObjectByIndex(0)
  4. Camera = false
  5. Camera = Obj.ToCamera()
  6. if Camera:
  7. print "It is a Camera"
  8. DeselectAll()
  9. SelectByName("Sun light")
  10. Obj=GetSelectedObjectByIndex(0)
  11. Camera2 = false
  12. Camera2 = Obj.ToCamera()
  13. if Camera2 is None:
  14. print "It is not a Camera"

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 - 2017