Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Script UI Panel

  • Posted by Tim Mathews on March 16, 2011 at 4:11 pm

    Been trying to do my own version (only for personal use) of the “Ft-Toolbar” ft-toolbar by Francios Tarlier. I’m trying to learning scripting to expand my knowledge base, as I’ve gotten a pretty good handle on Expressions. I’m trying to build a Script UI Panel, which works as expected on the MAC, but not on the PC and I can’t figure out why only the particular button shows up: Do I have to make a buttonPanel for them to sit in?

    Here’s the code: (Thanks in advance for your help)

    var whichComp = app.project.activeItem;
    var myLayer = whichComp.selectedLayers;

    var w = buildUI(this);

    function buildUI(thisObj) {
    var win = (thisObj instanceof Panel) ? thisObj:new Window('palette', 'Tim Tools',undefined, {resizable: true});

    if (win != null) {
    win.particularLayer = win.add('button', [10,13,120,35], 'Particular Layer'); //Create Particular Button
    win.particularLayer.onClick = function()
    {
    //Make a solid and apply Particular to it
    app.beginUndoGroup("Particular Creation");
    particularSolid = whichComp.layers.addSolid([0.51, 0.075, 0.075], "Particular fx", whichComp.width, whichComp.height, 1.0);
    particularSolid.property("Effects").addProperty("tc Particular");
    app.endUndoGroup("Particular Creation");
    }
    win.GazBlurT = win.add('button', [10,43,120,35], 'Gaussian Blur'); //Create Gaussian Blur Button
    win.GazBlurT.onClick = function()
    {
    //Add the Gaussian Blur fx to the current first layer selected
    var currentLayer = whichComp.selectedLayers[0];
    currentLayer.property("Effects").addProperty("ADBE Gaussian Blur");
    }

    win.cameraT = win.add('button', [10,73,120,35], 'Camera'); //Adds Camera to the Scene
    win.cameraT.onClick = function()
    {
    //Add new camera to current comp letting user name camera
    whatName = prompt("What do you want to name the Camera?", "Camera 1");
    myCamera = whichComp.layers.addCamera(whatName, [whichComp.width * .5, whichComp.height * .5]);
    }
    win.adjLayer = win.add('button', [10,103,120,35], 'Adjustment Layer');
    win.adjLayer.onClick = function()
    {
    //Add an adjustment layer to current Comp
    var adjustName = prompt("What do you want to call the Adjustment Layer", "Adjustment Layer 1");
    var currentLayer = whichComp.layers.addSolid([1.0, 1.0, 1.0], adjustName, whichComp.width, whichComp.height, 1.0);
    currentLayer.adjustmentLayer = true;
    }

    win.preComp = win.add('button', [10,133,120,35], 'PreCompose');
    win.preComp.onClick = function()
    {
    //Pre-comp selected layers letting user name Pre-Comp
    var preCompName = prompt("What do you want to name the Comp?", "My Comp Name");
    var theseLayers = whichComp.selectedLayers;
    var howManyLayers = theseLayers.length;
    //If no layers selected assume user wants to Pre-Comp everything in the comp
    if(howManyLayers == 0){
    var layerIndices = new Array();
    howManyLayers = whichComp.layers.length;
    for (i = 0; i < howManyLayers; i++){
    layerIndices[i] = i + 1;
    }
    var newPreComp = whichComp.layers.precompose(layerIndices, preCompName);
    }
    else
    {
    //If only one layers selected give Move All option [Not available for multiple layers]
    if(howManyLayers == 1){
    var moveAllName = prompt("Move all attributes?", "Yes");
    var whatLayerAmI = theseLayers[0].index;
    switch(moveAllName)
    {
    case "Yes":
    moveAllName = true;
    break;
    case "No":
    moveAllName = false;
    break;
    case "yes":
    moveAllName = true;
    break;
    case "no":
    moveAllName = false;
    break;
    case "YES":
    moveAllName = true;
    break;
    case "NO":
    moveAllName = false;
    break;
    default:
    }
    var newPreComp = whichComp.layers.precompose([whatLayerAmI], preCompName, moveAllName);

    }
    else{
    //See which layers are selected and precompose them
    var combineLayers = new Array(howManyLayers);
    for (i = 0; i < howManyLayers; i++){
    combineLayers[i] = theseLayers[i].index;
    }

    var newPreComp = whichComp.layers.precompose(combineLayers, preCompName);
    }
    }
    }
    }
    return win
    }

    Tim Mathews replied 15 years, 4 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    March 17, 2011 at 12:11 am

    I think there are a couple of problems. I wasn’t able to get your panel to show up at all until I added w.show();

    Also, as soon as I changed all your button sizes to undefined, all of them appeared in the panel. So there must be some conflict with the size of the panel and the size/position of the buttons. I’m just guessing.

    I’m not too familiar with the way you’re creating this panel (I always use resource strings to define the whole thing at once rather than use add()) so I don’t have much more to suggest. I think you’re close though.

    Dan

  • Tim Mathews

    March 17, 2011 at 2:08 am

    Dan, thanks for looking at this for me. There must be something “out of whack” like you implied. The “show()” doesn’t hurt the panel for me, but it shows on my PC and MAC either way. [I’ll try leaving it in for the PCs sake]. The other interesting thing is that if I declare the buttons to be undefined they won’t show up at all on either machine. I’ll do some more digging around to find the solution for both machines.
    I did see one sample script that used a resource string, so I’ll investigate that a little more too.
    Thanks again.
    I’d like to suggest, although the free help is greatly appreciated, that you write a book: Dan Ebberts’: Everything you need to know about scripting for After Effects. I’d buy it twice just because your site and forum answers have helped me so much over the years. For all those who forgot to say it, “Thanks!”
    I’ll post the final working panel settings for others who are struggling. I won’t post the working button code as I think we should support Franquios’ work. His script is really cool and easily customizable. (and NO I don’t know him at all!)

  • Tim Mathews

    April 13, 2011 at 5:36 pm

    Here’s the resource string I used to get it to work (as promised all be it late):

    var beginRes = “group {
    orientation:’column’, alignment:[‘fill’,’fill’],
    tp: Panel {
    type:’tabbedpanel’, alignment:[‘fill’,’fill’], alignChildren:[‘fill’,’center’],
    tpBasic: Panel {
    type:’tab’, orientation: ‘row’, space: ‘0’,text:’Toolbar’, alignChildren:[‘center’,’top’],
    preCompBtn: Button { type:’button’, text: ‘PreComp’, helpTip: ‘” + preCompHelpText + “‘},
    reflectBtn: Button { type:’button’, text: ‘Reflect’, helpTip: ‘” + reflectionHelpText + “‘},
    particularBtn: Button { type:’button’, text: ‘Particular’, helpTip: ‘” + particularHelpText + “‘},
    radialTransBtn: Button { type:’button’, text: ‘Radial TransFX’, helpTip: ‘” + radialTransHelpText + “‘},
    shineFXBtn: Button { type:’button’, text: ‘Shine FX’, helpTip: ‘” + shineHelpText + “‘},
    editorButtons: Button { type:’button’, text: ‘Edit’, helpTip: ‘Edit Button List’},
    },
    tpAdvanced: Panel { //this tab is just to hold my play buttons
    type:’tab’, orientation: ‘row’, space: ‘0’, text:’Play Objects’, alignChildren:[‘center’,’center’],
    minSlide: StaticText { text: ‘0’},
    mySlider: Slider { type: ‘slider’, minvalue: ‘0’, maxvalue: ‘100’, value: ‘0’},
    curSlide: StaticText { text: ‘0’},
    maxSlide: StaticText { text: ‘100’},
    btnVersion1: Button { text:’Get File’ },
    btnVersion2: Button { text:’Version 2′ },” + iconButtonData + “},
    },
    }”

    var myPanel = pal.add(beginRes);

    ****************************************************************
    That creates my dockable Script UI Panel. I’ve got some “helpTip” variables that are used too, so that a user can mouse over and sit on a button and get the help window description.

    This works for both CS4 & CS5, but I can’t figure out why it doesn’t work in CS3. Any ideas? I’ve seen other Resource strings for CS3 that were similar to this that work fine, which I’ve tried patterning this after to no avail.

    Thanks

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