Duplicate a layer and a camera and do stuff individually?

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
Simma
Posts: 98
Joined: June 8th, 2010, 2:57 pm

Hi all,

I'm trying to write a script that will (among other stuff) duplicate my selected layers, which is a camera layer and a footage layer. Then I would like to to do different things to them, say adjust the position of the camera and adjust the rotation of the footage. I think I can find the duplicate part, but could anyone point me in the right directio how to "seperate" camera layers from footage layers so I can assign stuff to them individually?
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

Hi Simma,

Layers are objects so you can test to see if they are instanceof's known objects like this:

Code: Select all

var selLayers=app.project.activeItem.selectedLayers;

for (var i=0; i<selLayers.length;i++){
    if(selLayers[i] instanceof CameraLayer) alert("Layer: \""+selLayers[i].name+"\" is a camera");
    if(selLayers[i] instanceof AVLayer) alert("Layer: \""+selLayers[i].name+"\" is an AV layer");
    }
-Lloyd
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

btw, to figure out what the object name to test against is, just do an alert on the layer and it will tell you what it is within brackets like this: [AVLayer]

Keep in mind that these are case-sensitive.

-Lloyd
Simma
Posts: 98
Joined: June 8th, 2010, 2:57 pm

Thank you Lloyd, you (and this site) is very helpful. I did search for info about this but couldn't find any.

Don't know if this is correct, but it worked for me;

Code: Select all


var selLayers = app.project.activeItem.selectedLayers;

for (var i=0; i<selLayers.length;i++)
    if(selLayers[i] instanceof CameraLayer){
   var myCamera = selLayers[i]
   var dupCamera = myCamera.duplicate();
    
   
} else {
    var myLayer = selLayers[i]
    var dupLayer = myLayer.duplicate();

 }
Post Reply