Creative Communities of the World Forums

The peer to peer support community for media production professionals.

  • Posted by Nicolas Elsig on May 10, 2010 at 8:10 am

    Hello why can’t I have a clean palette with this code…
    In Extend Script Tool Kit it seems ok but when loading the palette in AE … everything is aligned to center, one object per lign 🙁
    any idea ?

    Thank you in advance

    //open

    var VERSION = 2.8;
    var scriptName = 'Moka3Dto2D';
    var palette;
    var optionGUI;
    var sizeInit = Number(100);//setup size variable
    var ofsXinit = Number(0);//setup size variable
    var ofsYinit = Number(0);//setup size variable
    var ofsInitialX = 1024;
    var ofsInitialY = 576;
    var ofsInitial = "X : "+ofsInitialX+" Y : "+ofsInitialY;

    function main(thisObj)
    {
    createPalette(thisObj);
    /*
    activeItem = app.project.activeItem;
    if (activeItem == null) {
    return;
    }
    */
    }

    function createPalette(thisObj){

    // win = (thisObj instanceof Panel) ? thisObj : new Window('palette', 'Matrix', [300,100, 570, 480]);
    win = (thisObj instanceof Panel) ? thisObj : new Window('palette', 'Moka3Dto2Dtools', undefined, {resizeable:true});

    //win.lowerPnl = win.add('panel', [10,10,600,600], '');
    // winNameLbl = optionGUI.add("statictext", [10,10, 200, 30], "Select 3d null objects to convert");

    // dnBtn2d = optionGUI.add("button", [10, 30, 180, 30], "2D_null");
    // dnBtn2d.name = "convertButton";

    // dnBtnSolid = optionGUI.add("button", [10, 60, 180, 30], "2D_mask");
    // dnBtnSolid.name = "convertButton1";

    // dnBtnOffset = optionGUI.add("button", [10, 90, 180, 30], "2D_patch");
    // dnBtnOffset.name = "convertButton2";

    // userPanel = optionGUI.add('panel',[5, 115, 180, 145], 'Mask/Patch');
    // winTailleLbl = userPanel.add("statictext", [5,5, 180, 20], "size in pixels : ");
    // solidSizeFld = userPanel.add('edittext', [5, 5, 50, 20], sizeInit);

    // userPanel1 = optionGUI.add('panel',[5, 155, 180, 195], 'Patch only');

    // winOfsXLbl = userPanel1.add("statictext", [5,5, 180, 20], "offset X in pixels : ");
    // ofsXfld = userPanel1.add('edittext', [0,0,40,15], ofsXinit);

    // winOfsYLbl = userPanel1.add("statictext", [5,5, 180, 20], "offset Y in pixels : ");
    // ofsYfld = userPanel1.add('edittext', [0,0,40,15], ofsYinit);
    mainPanel = win.add('panel', [15,15,255,365], '3D trackers tools');

    {

    text1 = mainPanel.add('statictext', [10,13,230,33], 'convert 3d_nulls to ...');
    nullPanel = mainPanel.add('panel', [10,41,230,121], '2D null settings');
    text2 = nullPanel.add('statictext', [18,15,118,35], 'locator size :');
    locSizeFld = nullPanel.add('edittext', [124,12,174,32], '100');
    text3 = nullPanel.add('statictext', [180,15,200,35], '%');
    nullBtn = nullPanel.add('button', [19,38,199,63], '2D_null', {name:'2D_null'});

    maskPatchPanel = mainPanel.add('panel', [10,122,230,322], 'Mask/Patch settings');
    text4 = maskPatchPanel.add('statictext', [19,18,134,38], 'solid size in pixels :');
    solidSizeFld = maskPatchPanel.add('edittext', [139,14,199,34], '100');
    maskBtn = maskPatchPanel.add('button', [19,41,199,66], '2D_mask', {name:'2D_mask'});

    text5 = maskPatchPanel.add('statictext', [19,73,199,93], 'patch offset :');
    text6 = maskPatchPanel.add('statictext', [20,102,40,122], 'X:');
    ofsXfld = maskPatchPanel.add('edittext', [45,99,105,119], '0');
    text7 = maskPatchPanel.add('statictext', [112,102,132,122], 'Y:');
    ofsYfld = maskPatchPanel.add('edittext', [138,99,198,119], '0');
    text8 = maskPatchPanel.add('statictext', [19,125,199,145], 'new position : '+ofsInitial);
    patchBtn = maskPatchPanel.add('button', [19,152,199,177], '2D_patch', {name:'2D_patch'});

    nullBtn.onClick = convert3DTo2D;
    maskBtn.onClick = convert3DToMask;
    patchBtn.onClick = convert3DToOffset;
    solidSizeFld.onChange = onSizeChange;
    ofsXfld.onChange = onOfsXChange;
    ofsYfld.onChange = onOfsYChange;
    }

    if (win instanceof Window)
    {
    win.show();
    }
    else
    {
    win.layout.layout(true);
    }

    }
    main(this);

    Nicolas Elsig replied 16 years, 2 months ago 1 Member · 1 Reply
  • 1 Reply
  • Nicolas Elsig

    May 10, 2010 at 1:01 pm

    Ok I solved the problem by putting a return; after ofsYfld.onChange = onOfsYChange;
    and it well formatted in AfterEffects … maybe it’s the wrong way … but it works (I don’t know why :)… if you have a best way to do it I would be happy to know…

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