//photoshop 2021 //基本操作--> //选择图层 function layerclick(layername) { var idslct = charIDToTypeID("slct"); var desc117 = new ActionDescriptor(); var idnull = charIDToTypeID("null"); var ref16 = new ActionReference(); var idLyr = charIDToTypeID("Lyr "); ref16.putName(idLyr, layername); desc117.putReference(idnull, ref16); var idMkVs = charIDToTypeID("MkVs"); desc117.putBoolean(idMkVs, false); var idLyrI = charIDToTypeID("LyrI"); var list8 = new ActionList(); list8.putInteger(8); desc117.putList(idLyrI, list8); executeAction(idslct, desc117, DialogModes.NO); } // 从下往上自动重命名 function layerRename() { var layermaxnanmbe = app.activeDocument.layers.length; for (var a = 0, layearrkey = layermaxnanmbe - 1; a < layermaxnanmbe; a++, layearrkey--) { var layer = app.activeDocument.layers[layearrkey]; layer.name = a + 1; } } // 复制当前图层,并命名 //layearname:被复制图层名 //n:复制的次数编号 function layearCope(layearname,n) { var newlayearname = layearname + "_" + n; var idDplc = charIDToTypeID("Dplc"); var desc2133 = new ActionDescriptor(); var idnull = charIDToTypeID("null"); var ref410 = new ActionReference(); var idLyr = charIDToTypeID("Lyr "); var idOrdn = charIDToTypeID("Ordn"); var idTrgt = charIDToTypeID("Trgt"); ref410.putEnumerated(idLyr, idOrdn, idTrgt); desc2133.putReference(idnull, ref410); var idNm = charIDToTypeID("Nm "); desc2133.putString(idNm, newlayearname); var idVrsn = charIDToTypeID("Vrsn"); desc2133.putInteger(idVrsn, 5); var idIdnt = charIDToTypeID("Idnt"); var list233 = new ActionList(); list233.putInteger(4); desc2133.putList(idIdnt, list233); executeAction(idDplc, desc2133, DialogModes.NO); } //图层透明度(num 0-100) function transparency(num) { var idsetd = charIDToTypeID("setd"); var desc137 = new ActionDescriptor(); var idnull = charIDToTypeID("null"); var ref26 = new ActionReference(); var idLyr = charIDToTypeID("Lyr "); var idOrdn = charIDToTypeID("Ordn"); var idTrgt = charIDToTypeID("Trgt"); ref26.putEnumerated(idLyr, idOrdn, idTrgt); desc137.putReference(idnull, ref26); var idT = charIDToTypeID("T "); var desc138 = new ActionDescriptor(); var idOpct = charIDToTypeID("Opct"); var idPrc = charIDToTypeID("#Prc"); desc138.putUnitDouble(idOpct, idPrc, num); var idLyr = charIDToTypeID("Lyr "); desc137.putObject(idT, idLyr, desc138); executeAction(idsetd, desc137, DialogModes.NO); } //动画方面----> //新建逐桢时间轴 function newFrameTimeline() { var idmakeFrameAnimation = stringIDToTypeID("makeFrameAnimation"); executeAction(idmakeFrameAnimation, undefined, DialogModes.NO); } //新建带渐变的补间动画时间轴 function newMakeTimeline() { var idmakeTimeline = stringIDToTypeID("makeTimeline"); executeAction(idmakeTimeline, undefined, DialogModes.NO); } //新建桢,并且当前选中的桢为新建桢 function newK() { var idDplc = charIDToTypeID("Dplc"); var desc168 = new ActionDescriptor(); var idnull = charIDToTypeID("null"); var ref45 = new ActionReference(); var idanimationFrameClass = stringIDToTypeID("animationFrameClass"); var idOrdn = charIDToTypeID("Ordn"); var idTrgt = charIDToTypeID("Trgt"); ref45.putEnumerated(idanimationFrameClass, idOrdn, idTrgt); desc168.putReference(idnull, ref45); executeAction(idDplc, desc168, DialogModes.NO); } //变更当前帧的时间(最小0.01) function kTime(s) { var idsetd = charIDToTypeID("setd"); var desc179 = new ActionDescriptor(); var idnull = charIDToTypeID("null"); var ref48 = new ActionReference(); var idanimationFrameClass = stringIDToTypeID("animationFrameClass"); var idOrdn = charIDToTypeID("Ordn"); var idTrgt = charIDToTypeID("Trgt"); ref48.putEnumerated(idanimationFrameClass, idOrdn, idTrgt); desc179.putReference(idnull, ref48); var idT = charIDToTypeID("T "); var desc180 = new ActionDescriptor(); var idanimationFrameDelay = stringIDToTypeID("animationFrameDelay"); desc180.putDouble(idanimationFrameDelay, s); var idanimationFrameClass = stringIDToTypeID("animationFrameClass"); desc179.putObject(idT, idanimationFrameClass, desc180); executeAction(idsetd, desc179, DialogModes.NO); } //重置,删除动画 function resetTimeline() { var idDlt = charIDToTypeID("Dlt "); var desc909 = new ActionDescriptor(); var idnull = charIDToTypeID("null"); var ref267 = new ActionReference(); var idanimationClass = stringIDToTypeID("animationClass"); var idOrdn = charIDToTypeID("Ordn"); var idTrgt = charIDToTypeID("Trgt"); ref267.putEnumerated(idanimationClass, idOrdn, idTrgt); desc909.putReference(idnull, ref267); executeAction(idDlt, desc909, DialogModes.NO); } //删除当前选中的桢 function deleteK() { var idDlt = charIDToTypeID("Dlt "); var desc3264 = new ActionDescriptor(); var idnull = charIDToTypeID("null"); var ref1049 = new ActionReference(); var idanimationFrameClass = stringIDToTypeID("animationFrameClass"); var idOrdn = charIDToTypeID("Ordn"); var idTrgt = charIDToTypeID("Trgt"); ref1049.putEnumerated(idanimationFrameClass, idOrdn, idTrgt); desc3264.putReference(idnull, ref1049); executeAction(idDlt, desc3264, DialogModes.NO); }