app.executeCommand for New Comp Problem

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
User avatar
ugofil
Posts: 1
Joined: April 6th, 2010, 12:35 pm
Location: Los Angeles, CA
Contact:

Hello,

I am trying to figure out a rather wierd/frustrating problem... I have a script that uses app.executeCommand(2796) (for "New Comp from Selection...") and it works just fine and dandy when I run the script from "Run Script File" but does not when I run it from the UI panel I have.

Has anyone run across this problem or know of a fix? I suspect it has something to do with this specific command in the UI panel but I cannot figure out what. By the way, I am able to issue other commands via app.executeCommand and they work fine from my UI panel.

Thanks,
Philip
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

Hey Philip

app.executeCommand is an unsupported function, or a "private api" as Apple calls them so it's best to avoid using it as there is no guarantee that it will work. I use it only when there is not other option. In the case of New Comp from selection, it is very easy to do that through standard api's:

Code: Select all

var projSelection = app.project.activeItem;  //the selected item in the project window
var myComp = app.project.items.addComp(projSelection.name, projSelection.width, projSelection.height, projSelection.pixelAspect, projSelection.duration, projSelection.frameRate); //Create a new comp with the same dimensions as the selected item
myComp.layers.add(projSelection); //add the item to the newly created comp
-Lloyd
Post Reply