Notifications
Clear all

[Closed] Camera Target from Target Camera

Hi guys,

Trying to define a function for camera alignment to predefined points
Once I have the camera selected and defined as a variable what’s the best way of getting the camera target without user input?

for instance:

c = selectByName title:“Choose Camera” single:true
t = ? (camera target node from the above variable?)

ps. a filter function for cameras in the above dialogue would be handy as well

3 Replies

I think one of the scripts in the blur script pack selects targets based on their camera. You could probably use that to figure out how it’s done. If you don’t have one of the BSPacks, you can try www.scriptspot.com.

Originally posted by Alex Morris
[B]Hi guys,

Trying to define a function for camera alignment to predefined points
Once I have the camera selected and defined as a variable what’s the best way of getting the camera target without user input?

for instance:

c = selectByName title:“Choose Camera” single:true
t = ? (camera target node from the above variable?)

ps. a filter function for cameras in the above dialogue would be handy as well [/B]

Hi Alex,

Every targeted object (Spot, Camera, Tape etc.) has a .target property pointing at the actual target object.

fn camera_filter obj = ( superclassof obj == Camera )
c = selectByName title:“Choose Camera” single:true filter:camera_filter
t = c.target

Some additional details you might need someday:
The TargetObject() constructor lets you create your own targets to assign to Cameras, Lights etc when creating them yourself.
TargetObject is of Geometry class which might be important when collecting Lights or Cameras. When accessing the Lights or Cameras global array, the targets will be listed there, but not being a Light or Camera class, they could cause your problems.
For example, to collect all Cameras but no targets, you would have to say

cam_array = for c in Cameras where classof c != GeometryClass collect c

Compare to

cam_array = Cameras as array

which will give you both Cameras and their Targets…

Thanks for the quick response guys, I’ll try incorporating this in the next few days and repost the whole thing.