blank panel

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
jus2poubelle
Posts: 6
Joined: July 1st, 2013, 3:38 am

Hi,

I've made a script which works almost like I want it to. But I can't execute it 2 times in the same "session". I have to restart AE each time I want to relaunch the script. If not, the panel appears completely blank.
I'm still a novice so I must have done something wrong. But has somebody already encountered this problem?

PS: sorry for the frenchglish language :)
beginUndoGroup
Posts: 81
Joined: November 27th, 2012, 6:41 am

You should post the part UI part of your script, maybe not everything, but at least exhibit how you build the palette and how you show it.
jus2poubelle
Posts: 6
Joined: July 1st, 2013, 3:38 am

ok, I tried to simplify the script and keep only the code around the UI. But the problem doesn't occur anymore...

Still, I guess I'm doing it wrong by some manner. So I post it anyhow. If someone can tell me a better way to write my code, i'll be happy

Code: Select all

    function exportToXml(thisObject)   
    {

            var globalLayerArray = new Array;
            var myProj = app.project;
            var myComp;
            var myPath;
            function layerItem(layer, name) {
                this.layer = layer;
                this.name = name;
            }            
        // updateListBox refresh "list"
        function updateListBox(list)
        {
            list.removeAll();
            for (var i = 0; i<globalLayerArray.length; i++)
            {
                list.add("item", i + ": " + globalLayerArray[i].name);
            }
            $.writeln("list updated \n ------------");
        }
        // addItem in "list"
        function addItem(list)
        {
            myComp = myProj.activeItem;
            if (myComp.selectedLayers)
            {
                $.writeln(myComp.selectedLayers.length + " selected layers");
                var sel = myComp.selectedLayers;
                for (var i = 0; i<sel.length; i++)
                {
                    var notInGlobal = true;
                    for (var o=0; o<globalLayerArray.length; o++)
                    {
                        if (sel[i].name == globalLayerArray[o].name)
                            notInGlobal = false;
                    }
                
                    if (notInGlobal)
                    {
                        globalLayerArray.push(new layerItem ( sel[i], sel[i].name));
                        $.writeln("added: " + sel[i].name);
                    }else
                        $.writeln("not added: " + sel[i].name);
                }
                updateListBox (list);         
            }
        }
        function UI()
        {
        var pal = new Window("palette", "Export to XML");
             var myAGroup = pal.add("group");
                 myAGroup.orientation = "row";
                 myAGroup.alignChildren = "fill";
                 var myFirstAGroup = myAGroup.add("group");
                    myFirstAGroup.orientation = "column";
                    var addBtn = myFirstAGroup.add("button", undefined, "add");
                    var delBtn = myFirstAGroup.add("button", undefined, "delete");
                var mySecondAGroup = myAGroup.add("group");
                    mySecondAGroup.alignChildren = "fill";
                    var myListBox = mySecondAGroup.add ("ListBox", undefined, "", {multiselect:true});
                    myListBox.size = [200,150];
                    myListBox.alignment = ["fill", "fill"];
                var myThirdAGroup = myAGroup.add("group");
                    myThirdAGroup.preferredSize =[100,150];
                    myThirdAGroup.orientation = "column";
                    myThirdAGroup.alignChildren = ["left","top"];
                    myThirdAGroup.enabled = false;
                    var animCheck = myThirdAGroup.add("checkbox", undefined, "animated");
                    var stillCheck = myThirdAGroup.add("checkbox", undefined, "still layer");
                    var complexLabl = myThirdAGroup.add("statictext", undefined, "complexity: " + 1);
                    var complexSlider = myThirdAGroup.add ("slider", undefined, 1, 1, 5);

                    
            var myBGroup = pal.add("group");
                var exptBtn = myBGroup.add("button", undefined, "create render comp");


        addBtn.onClick = function(){
            addItem(myListBox);
            }

        myListBox.onChange = function () {
            pal.myAGroup.myThirdAGroup.enabled = true;
            }

        pal.center();
        pal.show();
        }
    UI();

    }
    exportToXml(this);
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

If you're on CS6 there's a bug that I believe is fixed in the 11.0.2 update that can cause subsequent panels to be blank after a UI group has been enabled/disabled in a session. I haven't been able to replicate your problem just by launching, closing and relaunching your script so I'm not sure this is the issue, but I can see you are doing ".enabled = true/false" on UI groups. If it is this, you can fix it either by upgrading to 11.0.2 (you could check the version and warn about this in your script) or you can individually enable/disable the UI controls rather than doing it at the group level.

One thing I noticed was that your UI isn't using the panel that is created when installing the script in ScriptUI Panels and launching from the Window menu. You end up with a blank Panel and also the Window that is being defined by your script. To fix this there are two bits of your script you need to alter:

Code: Select all

var pal = (thisObject instanceof Panel) ? thisObject: new Window("palette", "Export to XML", undefined);

Code: Select all

if (pal instanceof Window) {
  pal.center();
  pal.show();
} else {
  pal.layout.layout(true);
}
I haven't tested this fully but it certainly gets your UI in the panel created by launching as a ScriptUI Panel.

Paul
jus2poubelle
Posts: 6
Joined: July 1st, 2013, 3:38 am

OK, I have to do some more tests to be sure. But right now it seems to be the solution.

I can say you've just save my sanity. I was about to cry yesterday. :)

Thank you so much for your help !
beginUndoGroup
Posts: 81
Joined: November 27th, 2012, 6:41 am

Just a remark: you should not assign a value to myProj right at the beginning of your script.
If the user closes the project and opens a new one while the script palette is open this will generate an error (Object not valid).
Unless ofc if you know this will not happen.
Aaron Cobb
Posts: 10
Joined: September 10th, 2007, 12:22 pm

I've been having a hell of a time with this blank panel problem in CS6 (big corporate client is never on the most up-to-date version of anything). Thing is, I'm using 11.0.4.2.
Sometimes I get the blank panel (other scripts, including ones I didn't write, show up blank, too) and sometimes AE locks up altogether.

Is this stuff resolved in CC?
Post Reply