Avoid activeCamera errors by checking if activeCamera exist?

Moderators: Disciple, zlovatt

Post Reply
jeremy
Posts: 3
Joined: February 22nd, 2012, 7:15 pm

I have created some expressions that work in conjunction with a camera brought in from a 3D app. Because I am frequently swapping out the camera for a new one, I am using thisComp.activeCamera rather than a hard link. Of course this means that if the camera ends before the comp, it will error and disable every one of my expressions.

I'd like to think it is possible to put my whole expression in an if statement checking if an activeCamera exists. I have tried some things without success, but was curious if anyone had a better idea of how to do it.

These both still error:

Code: Select all

if (thisComp.activeCamera){
}

Code: Select all

if (thisComp.activeCamera != null){
}
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

I think try/catch will work:

try{
thisComp.activeCamera;
(do stuff)
}catch (err){
(do different stuff)
}


Dan
jeremy
Posts: 3
Joined: February 22nd, 2012, 7:15 pm

Dan Ebberts wrote:try{
thisComp.activeCamera;
(do stuff)
}catch (err){
(do different stuff)
}
Works perfectly! Thanks!
Post Reply