Forum Replies Created

Page 16 of 32
  • This expression in the position property of the null should work:

    p = thisComp.layer(“2D object”).transform.position.value;
    p[2] = thisComp.layer(“3D object”).transform.position.value[2];

    p;

    Xavier.

  • This should work:

    x = effect("value")("Slider");
    holdTime = 2;
    holdTimeErr = 0.5;
    rdmTime = 10;
    rdmTimeErr = 2;
    hold = false; // change to true to start with a value on hold;

    f = timeToFrames(inPoint);
    F = timeToFrames(time);
    h1 = timeToFrames(holdTime-holdTimeErr);
    h2 = timeToFrames(holdTime+holdTimeErr);
    r1 = timeToFrames(rdmTime-rdmTimeErr);
    r2 = timeToFrames(rdmTime+rdmTimeErr);
    while(f

    Xavier

  • Try change the line:

    fDist=length(mCam,mPos);

    with:

    fDist=Math.abs(mCam[2],mPos[2]);

    Xavier.

  • Xavier Gomez

    July 31, 2015 at 4:46 pm in reply to: Expression to pull name of group of layers?

    To retrieve that number, you can use

    num = 0;
    str = “01_”;

    N=thisComp.numlayers;
    for (n=1; n<=N; n++){if (thisComp.layer(n).name.indexOf(str)===0) ++num;}; // at this stage, num is the number of layers in the comp whose name starts with "01_". // then you use it to calculate your position offset. Xavier

  • Xavier Gomez

    July 29, 2015 at 11:29 am in reply to: Stretching UI Panel Buttons across resizable panel

    Set the alignment like this:

    shortcuts.structBtn1.alignment = [‘fill’, ‘top’];

    (view the (Adobe/pdf) JavaScript_Tools_Guide for more details).

    Xavier.

  • Xavier Gomez

    July 28, 2015 at 11:25 am in reply to: Applying animation presets to solid via scripting

    * To ask for the folder path, you can use:

    var myPresetsFolder = Folder.selectDialog();

    or :

    var allPresetsFolder = Folder(Folder.appPackage.absoluteURI + “/” + “Presets”);
    var myPresetsFolder = allPresetsFolder.selectDlg();

    (The 2 methods dffer in that in the latter case the dialog “has already navigated to a closer place”.)

    * To read/write in the prefs file, use the app;settings object:

    var allPresetsFolder = Folder(Folder.appPackage.absoluteURI + "/" + "Presets");
    var myPresetsFolder;

    // read the settings
    if (app.settings.haveSetting("MyScriptSection", "myPresetsFolderPath")){
    myPresetFolder = new Folder(app.settings.getSetting("MyScriptSection", "myPresetsFolderPath"));
    };
    if (!myPresetFolder || !myPresetFolder.exists){
    // if the folder does not exist, ask for the path
    myPresetsFolder = allPresetsFolder.selectDlg();
    if (myPresetsFolder && myPresetsFolder.exists){
    // if now it exists, save the path
    app.settings.saveSetting("MyScriptSection", myPresetsFolder.absoulteURI);
    };
    };
    // Beware, at this stage the variable myPresetsFolder can still be null, if the user was prompted a folder dialog and closed it.

    Xavier.

  • Xavier Gomez

    July 24, 2015 at 7:28 pm in reply to: linear expression position to scale

    Hi,

    in case the scale varies when the null hover over the layer, you can use something like this, which is quite simple since it will be the same expression for all cards:


    x = Math.abs(thisComp.layer("mov scale").transform.position[0] - transform.position[0]);
    fadeDist = 500;
    s = ease(x, 0, fadeDist, 100, 75);
    [s,s];

    If the numbers you indicate do not correspond to any layer position, then:

    x = Math.abs(thisComp.layer(“mov scale”).transform.position[0] – 1161.3);
    fadeDist = 1161.3 – 662.7;
    scalex = ease(x, 0, fadeDist, 100, 75);
    [scalex,scalex];

    Xavier.

  • Xavier Gomez

    July 19, 2015 at 5:00 pm in reply to: Turning on a layer dependant on waveform.

    Expressions must be self-contained and cant use buffers.
    At each frame, the expression code must look forward and backwards to see if there are enugh frames above threshold or not.
    I didnt try but the following should work:

    threshold = 0.5; // minimum amplitude
    fMin = 15; // minimum number of frames above threshold
    L = thisComp.layer("Audio Amplitude");
    ampSlider = L.effect("Both Channels")("Slider");
    if (ampSlider.value<=threshold){
    0;
    }
    else{
    f = 1;
    dt = thisComp.frameDuration;
    // search backwards
    t = time;
    while( f<fMin && L.inPoint<=(t-=dt) && ampSlider.valueAtTime(t)>threshold && ++f);
    // search forwards
    t = time;
    while( f<fMin && ((t+=dt)<=L.outPoint) && ampSlider.valueAtTime(t)>threshold && ++f);

    f<fMin ? 0 : 100;
    };

    Xavier.

  • Xavier Gomez

    March 20, 2015 at 10:10 am in reply to: Script mask shape to motion path

    When you add a new effect to a layer, previous references to anything inside the layer effects get invalidated.
    If you need to add several effects and keep a reference to all of them during the execution of the script, you should wait to have set them all to declare variables.

    var myComp=app.project.activeItem;
    var myLayer=myComp.selectedLayers[0];
    var myMask=myLayer.mask(1);

    var N=myLayer.numProperties;
    myLayer.property(“Effects”).addProperty(“Point Control”);
    myLayer.property(“Effects”).addProperty(“Slider Control”);

    var Target=myLayer.property(“Effects”).property(N+1);
    Target.name=”myTarget”;
    var myTarget=Target.property(“Point”);

    var mySlider=myLayer.property(“Effects”).property(N+2);
    mySlider.name=”mySlider”;

    N+=2;// the actual number of effects now

    Xavier

  • The selection of a dropdownlist is a ListItem or null, so in any case, typeof mydropdownlist.selection should be “object”.
    In the console: $.writeln(mydropdownlist.selection) will be either “null” or the selected item text property (not its index). The string is not the selection itself, it is a display string for the selection.

    And to set the selection you can do either of:

    // selection by index:
    dd.selection = dd.items[0];
    dd.selection = 0;

    // selection by text (it will be the first item that carry that text, or null if not found)
    dd.selection = dd.find(someText);

    And may be some other ways.

    Xavier

Page 16 of 32

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