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?
Duplicate a layer and a camera and do stuff individually?
Moderator: Paul Tuersley
- 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:
-Lloyd
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");
}
- 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
Keep in mind that these are case-sensitive.
-Lloyd
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;
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();
}