ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

refresh project.selection in script extendscript

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Rainier Raydán
refresh project.selection in script extendscript
on Jun 14, 2017 at 5:59:43 pm

Hi! I wrote a script that search for text layers in selected comp items and enable or disable them. Works fine but when I make another selection while the script interface is running it doesnt work... I want to launch the script and then do the selection... I dont want to make the selection before launch it. Any ideas?

this is what I have:
var proj = app.project;
{
function myScript(thisObj) {
function myScript_buildUI(thisObj) {
var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "Textless_MOOCO_v01", [0, 0, 300, 300]);

res = "group{orientation:'column', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\
panelOne: Panel{orientation:'row', alignChildren:['left', 'fill'],\
onBtn: RadioButton{text:'on'},\
offBtn: RadioButton{text:'off'},\
},\
}"

// Adds resource string to panel
myPanel.grp = myPanel.add(res);

// Assign function to UI elements
myPanel.grp.panelOne.onBtn.onClick = function(){
if(proj.selection > 0){
var textAry = getAllTextLayers (proj.selection);
for(a=0;a 0){
var textAry = getAllTextLayers (proj.selection);
for(a=0;a<textAry.length;a++){
var curText = textAry[a];
curText.enabled = false;
}
}else{ return null;
}
}
// Functions


function getAllTextLayers(compAry){
var compAryLen, myResults, curComp, allLayers, allLayersLen, curLayer;
compAryLen = compAry.length;
myResults = new Array();
for(var i=0; i 0){
return myResults;

}else{
return null;
}
}
// Setup panel sizing and make panel resizable
myPanel.layout.layout(true);
myPanel.grp.minimumSize = myPanel.grp.size;
myPanel.layout.resize();
myPanel.onResizing = myPanel.onResize = function () {this.layout.resize();}

return myPanel;
}

// Build script panel
var myScriptPal = myScript_buildUI(thisObj);

if ((myScriptPal != null) && (myScriptPal instanceof Window)) {
myScriptPal.center();
myScriptPal.show();
}
}

// Execute script
myScript(this);
}


Return to posts index

Rainier Raydán
Re: refresh project.selection in script extendscript
on Jun 14, 2017 at 6:25:15 pm

Sorry guys, it does work! I just edit this line
proj.selection > 0

to this:
proj.selection.length <= 1

Thanks!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]