选择与所选图层具有相同源的所有图层。
如果放在 ScriptUI Panels 文件夹中,它有一个 UI,如果你把它放在 Scripts 文件夹中,它可以在没有 UI 的情况下工作。
/*-------------------------------------
Select SameSource
Version History
1.0.0 - Sep 08, 2021
Initial release
-------------------------------------*/
//______Files Path______
var thisFile = new File(this);
var thisFolderPath = thisFile.path;
//______Build Main Panel______
function buildUI(thisObj){
if(thisObj instanceof Panel){
var win = thisObj;
}else{
selectSameSource();
}
return win;
}
try{
var win = buildUI(this);
var buttonRect = [0, 0, 110, 30];
var panelButtonSpace = [5, 5, 5, 5];
var buttonSpace = [55, 0, 55, 0];
var buttonA = win.add("Button", panelButtonSpace + buttonRect, "Select SameSource");
function selectSameSource(){
app.beginUndoGroup("selectSameSource");
var comp = app.project.activeItem;
var sourceArr = [];
if(comp.selectedLayers.length<1){
}else{
var slLayers = comp.selectedLayers;
}
for(i=0; i<slLayers.length; i++){
sourceArr.push(slLayers[i].source);
}
app.executeCommand(2514); //Invert Selection
var slLayersRe = comp.selectedLayers;
for(i=0; i<sourceArr.length; i++){
for(j=0; j<slLayersRe.length; j++){
if(slLayersRe[j].source==sourceArr[i] && !slLayersRe[j].locked){
slLayersRe[j].selected = false;
}
}
}
app.executeCommand(2514); //Invert Selection
app.endUndoGroup();
}
buttonA.onClick = function(){
selectSameSource();
}
}catch(e){
}
//try catch <-- To make it work even if you don't have it in ScriptUI Panels.