Forum Replies Created

  • Mac Ward

    August 20, 2009 at 11:30 pm in reply to: Script tot enable/disable expressions

    How would I get the panel to close after clicking a button?

  • Got it!

    /* seed: https://forums.creativecow.net/thread/227/13876
    Thank you Filip Vandueren and Dan Ebberts

    This takes the 'Layer you wish to Resize' and matches its width, at every frame to the width
    of the 'Layer you wish to match

    */show_prompt1()
    var src;

    function show_prompt1()
    {
    src=prompt("Enter the Layer # you wish to resize","");
    src = parseInt(src)
    //~ if (src!=null )
    //~ {
    //~ src -= 1
    //~ }
    }

    show_prompt2()
    var goal;

    function show_prompt2()
    {
    goal=prompt("Enter the Layer # you wish to match in size","")
    goal = parseInt(goal)
    //~ if (goal!=null)
    //~ {
    //~ goal -= 1;
    //~ }
    }

    ai = app.project.activeItem;
    srcLayer = ai.layer(src);
    goalLayer = ai.layer(goal);
    //alert(srcLayer)
    g = "frames per second";
    g = 30;

    //~ srcWidth = srcLayer.srcRectAtTime(20/g,true).width;
    //~ alert(srcWidth)

    for (var i = 0; i<500 /*switch to lsrc layer length in frames*/; i++){
    srcWidth=srcLayer.sourceRectAtTime(i/g,true).width;
    goalWidth = goalLayer.sourceRectAtTime(0, true).width;

    if(srcWidth != goalWidth){
    initScale = 100*goalWidth/srcWidth;
    srcLayer.scale.setValueAtTime(i/g, [initScale,initScale,initScale]);
    srcLayer.property("scale").addKey(i/g);
    }
    }

  • It seems that in the sourceRectAtTime line, src is not being seen as an integer. Does anyone know how to force it to be an integer? Because this does return the desired value:
    show_prompt1();

    ai = app.project.activeItem;
    srcLayer = ai.layer(src);

    function show_prompt1(){
    source=prompt("Enter the Layer # you wish to resize","");
    if (source!=null ){
    src = 1} //substituting the integer for source

    }

    alert(ai.layer(src).name)

    but this does not:

    show_prompt1();

    ai = app.project.activeItem;
    srcLayer = ai.layer(src);

    function show_prompt1(){
    source=prompt("Enter the Layer # you wish to resize","");
    if (source!=null ){
    src = source}

    }

    alert(src)

    alert(ai.layer(1).name)

    alert(ai.layer(src).name)

  • PS

    In my for loops I’m using 500 and 50 for the number of frames to Keyframe, only because I haven’t figured out how to say ‘layer length in frames’.

  • Well Filip, I’m close.

    I got this to work, which is very specific to the particular comp I’m working on:

    compW = app.project.activeItem.width
    compH = app.project.activeItem.height

    g = "frames per second"
    g = 30

    ai=app.project.item(1);

    txtLayer=ai.layer("ngngv");

    for (i=0; i<500; i++){

    w=txtLayer.sourceRectAtTime(i/g,true).width//*txtLayer.scale.value[0]/100;;
    maxWidth= compW;

    if (w

    But I'm trying to make a varsion that's not comp specific, and that fits to a given layer's width, rather than to the comp width. But it keeps giving me an error at the first "sourceRectAtTime" line, saying "Null is not an object". What am I doing wrong?

    show_prompt1()
    var src;

    function show_prompt1()
    {
    src=prompt("Enter the Layer # you wish to resize","");

    }

    show_prompt2()
    var goal;

    function show_prompt2()
    {
    goal=prompt("Enter the Layer # you wish to match in size","");

    }

    ai = app.project.item(1);
    srcLayer = ai.layer(src);
    goalLayer = ai.layer(goal);

    g = "frames per second";
    g = 30;

    for (var i = 0; i<50 /*switch to lsrc layer length in frames*/; i++){
    srcWidth = app.project.item(1).layer(src).sourceRectAtTime(i/g,true).width;
    goalWidth = goalLayer.sourceRectAtTime(0, true).width;

    if(srcWidth != goalWidth){
    initScale = 100*goalWidth/srcWidth;
    srcLayer.scale.setValueAtTime(i/g, [initScale,initScale,initScale]);
    srcLayer.property("scale").addKey(i/g);
    }
    }

  • Filip, Thank you for offering your script. I am not seeing it attached, though. Am I missing it?

  • Well, I’m getting familiar with Photoshop Scripting and would be happy to give it an attempt in the ESTK. Do you happen to know how to access the Fit to Comp Width command?

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy