Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

How to make my script dockable?

Community Beginner ,
Mar 19, 2017 Mar 19, 2017

i made a simple after effects script, and i want to know how to turn it to a dockable script...

when i put it in the scriptsUI folder it just shows me 2 screens...

here is the script:


//UI Creation

var myWindow = new Window("palette");

var myMessage = myWindow.add("statictext");

myMessage.text = "תסריט להפיכת טקסט. נעשה על ידי איתי אסולין";

var buttons = myWindow.add("panel", undefined, "buttons");

var HebrewThis = buttons.add("button", undefined, "HebrewThis!");

var Cancel = buttons.add("button", undefined, "Cancel");

buttons.orientation = "row";

//UI Creation End.//

//Function creations

//Hebrew this button

HebrewThis.onClick = function(){

app.beginUndoGroup("AddEffect");

var curItem = app.project.activeItem;

var selectedLayers = curItem.selectedLayers;

// check if comp is selected

if (curItem == null || !(curItem instanceof CompItem)){

// if no comp selected, display an alert

alert("בבקשה בחר שכבה");

} else {

// define the layer in the loop we're currently looking at

var myLayer = app.project.activeItem.layer(1);

var curVal = myLayer.property("Scale").value;

myLayer.property("Scale").setValue([-100, 100]);

var Text = selectedLayers[0].Text.Animators.addProperty("ADBE Text Animator");

myText.property("ADBE Text Selectors").addProperty("ADBE Text Selector");

myText.property("ADBE Text Animator Properties").addProperty("ADBE Text Scale 3D").setValue([-100, 100]);

}

// close the undo group

app.endUndoGroup();

}

  

//Hebrew this button ended.

//cancel button

Cancel.onClick = function(){

          

app.beginUndoGroup("AddEffect");

var curItem = app.project.activeItem;

var selectedLayers = curItem.selectedLayers;

// check if comp is selected

if (curItem == null || !(curItem instanceof CompItem)){

// if no comp selected, display an alert

alert("בבקשה בחר שכבה");

} else {

// define the layer in the loop we're currently looking at

var myLayer = app.project.activeItem.layer(1);

var curVal = myLayer.property("Scale").value;

myLayer.property("Scale").setValue([100, 100]);

var myAnim = selectedLayers[0].Text.Animators.property("ADBE Text Animator");

myAnim.property("ADBE Text Selectors").property("ADBE Text Selector");

myAnim.property("ADBE Text Animator Properties").property("ADBE Text Scale 3D").setValue([100, 100]);

}

// close the undo group

app.endUndoGroup();

    }

.show();

-=

TOPICS
Scripting
3.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Mar 20, 2017 Mar 20, 2017

Oh, Im sorry. Had to fix one line in the code. My bad.

(function(thisObj) {

    var scriptPalette = scriptBuildUI(thisObj);

    if (scriptPalette !== null && scriptPalette instanceof Window) {

        scriptPalette.center();

        scriptPalette.show();

    } else {

        scriptPalette.layout.layout(true);

    }

    function scriptBuildUI(thisObj) {

        //UI Creation  

        var myWindow = (thisObj instanceof Panel) ? thisObj : new Window("palette", prefs.script.name, undefined, {

            resi

...
Translate
Advocate ,
Mar 19, 2017 Mar 19, 2017

Hi.

The magic in having script as a dock-able panel is to pass this to a function.

I took a liberty to refactor your code a bit, but I think you will figure it out.

Cheers.

(function(thisObj) {

    var scriptPalette = scriptBuildUI(thisObj);

    if (scriptPalette !== null && scriptPalette instanceof Window) {

        scriptPalette.center();

        scriptPalette.show();

    } else {

        scriptPalette.layout.layout(true);

    }

    function scriptBuildUI(thisObj) {

        //UI Creation 

        var myWindow = new Window("palette");

        var myMessage = myWindow.add("statictext");

            myMessage.text = "תסריט להפיכת טקסט. נעשה על ידי איתי אסולין";

        var buttons = myWindow.add("panel", undefined, "buttons");

            buttons.orientation = "row";

        var HebrewThis = buttons.add("button", undefined, "HebrewThis!");

        var Cancel = buttons.add("button", undefined, "Cancel");

        //Hebrew this button 

        HebrewThis.onClick = function() {

                app.beginUndoGroup("AddEffect");

                var curItem = app.project.activeItem;

                var selectedLayers = curItem.selectedLayers;

                // check if comp is selected 

                if (curItem == null || !(curItem instanceof CompItem)) {

                    // if no comp selected, display an alert 

                    alert("בבקשה בחר שכבה");

                } else {

                    // define the layer in the loop we're currently looking at 

                    var myLayer = app.project.activeItem.layer(1);

                    var curVal = myLayer.property("Scale").value;

                    myLayer.property("Scale").setValue([-100, 100]);

                    var Text = selectedLayers[0].Text.Animators.addProperty("ADBE Text Animator");

                    myText.property("ADBE Text Selectors").addProperty("ADBE Text Selector");

                    myText.property("ADBE Text Animator Properties").addProperty("ADBE Text Scale 3D").setValue([-100, 100]);

                }

                // close the undo group 

                app.endUndoGroup();

            } //Hebrew this button ended. 

        //cancel button 

        Cancel.onClick = function() {

            app.beginUndoGroup("AddEffect");

            var curItem = app.project.activeItem;

            var selectedLayers = curItem.selectedLayers;

            // check if comp is selected 

            if (curItem == null || !(curItem instanceof CompItem)) {

                // if no comp selected, display an alert 

                alert("בבקשה בחר שכבה");

            } else {

                // define the layer in the loop we're currently looking at 

                var myLayer = app.project.activeItem.layer(1);

                var curVal = myLayer.property("Scale").value;

                myLayer.property("Scale").setValue([100, 100]);

                var myAnim = selectedLayers[0].Text.Animators.property("ADBE Text Animator");

                myAnim.property("ADBE Text Selectors").property("ADBE Text Selector");

                myAnim.property("ADBE Text Animator Properties").property("ADBE Text Scale 3D").setValue([100, 100]);

            }

            // close the undo group 

            app.endUndoGroup();

        }

        return myWindow;

    } //UI Creation End.// 

})(this);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 20, 2017 Mar 20, 2017

First of all- thanks.

second of all -

i have a problem.

i put it in to the scriptUI folder and ran it through the window tab, and...

b36f88f2a6d548249ac8324472804d63.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 20, 2017 Mar 20, 2017

Oh, Im sorry. Had to fix one line in the code. My bad.

(function(thisObj) {

    var scriptPalette = scriptBuildUI(thisObj);

    if (scriptPalette !== null && scriptPalette instanceof Window) {

        scriptPalette.center();

        scriptPalette.show();

    } else {

        scriptPalette.layout.layout(true);

    }

    function scriptBuildUI(thisObj) {

        //UI Creation  

        var myWindow = (thisObj instanceof Panel) ? thisObj : new Window("palette", prefs.script.name, undefined, {

            resizeable: true

        });

        var myMessage = myWindow.add("statictext");

        myMessage.text = "תסריט להפיכת טקסט. נעשה על ידי איתי אסולין";

        var buttons = myWindow.add("panel", undefined, "buttons");

        buttons.orientation = "row";

        var HebrewThis = buttons.add("button", undefined, "HebrewThis!");

        var Cancel = buttons.add("button", undefined, "Cancel");

        //Hebrew this button  

        HebrewThis.onClick = function() {

                app.beginUndoGroup("AddEffect");

                var curItem = app.project.activeItem;

                var selectedLayers = curItem.selectedLayers;

                // check if comp is selected  

                if (curItem == null || !(curItem instanceof CompItem)) {

                    // if no comp selected, display an alert  

                    alert("בבקשה בחר שכבה");

                } else {

                    // define the layer in the loop we're currently looking at  

                    var myLayer = app.project.activeItem.layer(1);

                    var curVal = myLayer.property("Scale").value;

                    myLayer.property("Scale").setValue([-100, 100]);

                    var Text = selectedLayers[0].Text.Animators.addProperty("ADBE Text Animator");

                    myText.property("ADBE Text Selectors").addProperty("ADBE Text Selector");

                    myText.property("ADBE Text Animator Properties").addProperty("ADBE Text Scale 3D").setValue([-100, 100]);

                }

                // close the undo group  

                app.endUndoGroup();

            } //Hebrew this button ended.  

        //cancel button  

        Cancel.onClick = function() {

            app.beginUndoGroup("AddEffect");

            var curItem = app.project.activeItem;

            var selectedLayers = curItem.selectedLayers;

            // check if comp is selected  

            if (curItem == null || !(curItem instanceof CompItem)) {

                // if no comp selected, display an alert  

                alert("בבקשה בחר שכבה");

            } else {

                // define the layer in the loop we're currently looking at  

                var myLayer = app.project.activeItem.layer(1);

                var curVal = myLayer.property("Scale").value;

                myLayer.property("Scale").setValue([100, 100]);

                var myAnim = selectedLayers[0].Text.Animators.property("ADBE Text Animator");

                myAnim.property("ADBE Text Selectors").property("ADBE Text Selector");

                myAnim.property("ADBE Text Animator Properties").property("ADBE Text Scale 3D").setValue([100, 100]);

            }

            // close the undo group  

            app.endUndoGroup();

        }

        return myWindow;

    } //UI Creation End.//  

})(this);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 21, 2017 Mar 21, 2017

Thank you so much! ❤️

it works grate.

thanks man!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 20, 2018 Apr 20, 2018

here my script to build my window!

I want it dockable !

Everybody can help me?

//------------------------------------------------

var interprate_palette = new Window("window","INTERPRET WINDOW");

if (interprate_palette != null)

{              

                  var projGrp     = interprate_palette.add ("Panel", [10,10,300,120],"Interpret");

                  var ignChk  = projGrp.add("checkbox",[10,10,80,30],"Ignore");    

                  var interoBnt   = projGrp.add("button",[200,10,280,30],"Interpret");

                  var whiteChk  = projGrp.add("checkbox",[10,40,60,60],"White");    

                  var grayChk  = projGrp.add("checkbox",[80,40,130,60],"Gray");

                  var blackChk   = projGrp.add("checkbox",[140,40,190,60],"Black");

                  var ColorBnt  = projGrp.add("button",[200,40,280,60],"Color");

                  var loopLabel = projGrp.add("statictext",[10,70,90,90],"Loop footage :");

                  var looptxt = projGrp.add("edittext",[100,70,160,90],"1");

                  var loopBnt = projGrp.add("button",[200,70,280,90],"Loop");

                  interprate_palette.bounds = [50,50,360,180];

                  interprate_palette.show();

}

ignChk.value = 1;

ignChk.onClick = ignSelect;

whiteChk.onClick = whiteSelect;

grayChk.onClick = graySelect;

blackChk.onClick = blackSelect;

interoBnt.onClick = interpretObj;

ColorBnt.onClick = getColorPremut;

loopBnt.onClick = getLoop;

//------------------------------------------------

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 10, 2019 Feb 10, 2019
LATEST
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines