// Shy_It.jsx // Dec 4 2011 // After Effects Script //Clinton Reese // /* make layers shy based on regular expression text matching no known way to create a selection from script so hiding layers and then manual selection is the only simple way contains presets dropdown for selecting AECollada 1.1x imported faces and vertices(solids and nulls) uses javascfript regular expression syntax Dec 10 2011 - preserve and restore shy setting buttons, no filter if text empty, help tips Dec 14 2011 - restore not working, not all layers have id so use name instead, dont process null value dropdown no way to get layer id and names can repeat so use layer index with limitation that no layers can be added or removed between a preserve and restore action note: layer id is available in SDK so maybe limitation of cs3 vs cs4/5/5.5 scripting? plan: use layer name unless repeating names found if so use index text search method only works the first time, use match instead */ /** @constructor Constructor. */ function ShyItDialog() { /** Maintain reference to the window we created @type Window */ this.windowRef = null; } /* IDD_FORMVIEW DIALOGEX 0, 0, 180, 120 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD FONT 8, "MS Shell Dlg", 400, 0, 0x0 BEGIN EDITTEXT IDC_EDIT1,24,36,134,12,ES_AUTOHSCROLL COMBOBOX IDC_COMBO1,24,12,134,12,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Go",IDC_BUTTON1,24,95,48,18 PUSHBUTTON "Close",IDC_BUTTON2,110,95,48,18 CONTROL "Opposite",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,65,42,12 CONTROL "Case Sensitive",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,98,65,60,12 END */ ShyItDialog.prototype.run = function() { var retval = true; // // *** Create the window // //palette==modeless var win = new Window("palette", "Shy It", [150, 150, 150+180*4/3, 150+150*4/3]); // bounds = [left, top, right, bottom] this.windowRef = win; savedshy = new Array(); savedshyid = new Array(); savedshyname = new Array(); savedshyindex = new Array(); repeatingnames = false; combooptions = new Array(); combooptions[0] = " "; //combooptions[1] = "Remove Shy"; combooptions[1] = "Faces"; combooptions[2] = "Vertices"; combooptions[3] = "Faces and Vertices" win.dropDwn = win.add("dropdownlist",[1,1,2,2],combooptions); win.dropDwn.bounds = {x:24, y:12, width:140*4/3, height:12*4/3}; win.dropDwn.helpTip = "Choose a preset filter"; win.editCtl = win.add("edittext",[1,1,2,2]); win.editCtl.bounds = {x:24, y:36*4/3, width:140*4/3, height:12*4/3}; win.editCtl.helpTip = "Text filter or regular expression"; win.oppositeCB = win.add("checkbox",[24,65*4/3,24+42*4/3,65*4/3+12*4/3],"Opposite"); win.oppositeCB.value = true; win.oppositeCB.helpTip = "Shy the opposite of the filter text"; win.caseCB = win.add("checkbox",[1,1,2,2],"Case Sensitive"); win.caseCB.bounds = {x:130, y:65*4/3, width:60*4/3, height:12*4/3}; win.caseCB.helpTip = "Enable case sensitive filtering"; win.preserveBtn = win.add("button",[1,1,2,2],"Preserve"); win.preserveBtn.bounds = {x:24, y:95*4/3, width:54, height:18*4/3}; win.preserveBtn.helpTip = "Save the current shy values"; win.restoreBtn = win.add("button",[1,1,2,2],"Restore"); win.restoreBtn.bounds = {x:92, y:95*4/3, width:54, height:18*4/3}; win.restoreBtn.helpTip = "Restore the preserved shy values"; win.goBtn = win.add("button",[1,1,2,2],"Go"); win.goBtn.bounds = {x:24, y:125*4/3, width:54, height:18*4/3}; win.goBtn.helpTip = "Execute the shy command"; win.unshyBtn = win.add("button",[1,1,2,2],"UnShy All"); win.unshyBtn.bounds = {x:92, y:125*4/3, width:54, height:18*4/3}; win.unshyBtn.helpTip = "Remove shy from all layers"; win.quitBtn = win.add("button",[1,1,2,2],"Close"); win.quitBtn.bounds = {x:120*4/3, y:125*4/3, width:54, height:18*4/3}; // // ***Event listener for the quit button // win.quitBtn.onClick = function() { win.close(); } win.preserveBtn.onClick = function(){ var myactiveItem = app.project.activeItem; if(myactiveItem) { //Composition, Footage, or Folder if(myactiveItem.typeName=="Composition") { savedshyname.length = 0; savedshy.length = 0; savedshyindex.length = 0; numlayers = myactiveItem.numLayers; repeatingnames = false; for(i=1;i<=numlayers;i++) { //savedshyid[i]=myactiveItem.layer(i).source.id;//problem null does not have a source id == error savedshyname[i] = myactiveItem.layer(i).name;//repeating names problem savedshyindex[i] = myactiveItem.layer(i).index; //alert(savedshyindex[i]); //check for repeating names if(i>1 && !repeatingnames) { for(k=1;k