论坛帮助 |
社区圈子 |
日历事件 |
2022-09-12, 17:01 | #1 | |||
|
||||
正式会员
等级: 四袋长老
|
////色组下 建多个专色色板///////// var docRef = app.activeDocument;//当前文件 // 建色组,若存在即忽略 var swatchGroup = null; var swatchGroupExists = false; for (var i = 0; i < docRef.swatchGroups.length; i++) { if (docRef.swatchGroups[i].name == "色组") { swatchGroup = docRef.swatchGroups[i]; swatchGroupExists = true; } } if (!swatchGroupExists) { addSpotColorToSwatches(60, 100, 0, "我要红", "色组"); function addSpotColorToSwatches(L, a, b, swatchName, swatchGroupName) { var swatchgroup = app.activeDocument.swatchGroups.add(); swatchgroup.name = swatchGroupName; var color = new LabColor(); color.l = L; color.a = a; color.b = b; var newSpot = app.activeDocument.spots.add(); newSpot.colorType = ColorModel.SPOT; newSpot.spotKind = SpotColorKind.SPOTLAB; newSpot.color = color; newSpot.name = File.encode(swatchName); // 色板到色组 swatchgroup.addSpot(newSpot); newSpot.name = File.decode(newSpot.name); } } ////end//// 现在只能是一个组一个专,若更多的专色,同一个色组,怎么写呢? |
|||
2022-09-13, 09:00 | 只看该作者 #2 | |||
|
||||
高级会员
等级: 六袋长老
|
代码:
var docRef = app.activeDocument; var swatchGroupName = "我的专色组"; try { var swatchgroup = docRef.swatchGroups.getByName(swatchGroupName); } catch (e) { var swatchgroup = docRef.swatchGroups.add(); swatchgroup.name = swatchGroupName; }; addSpotColorToSwatches(60, 100, 0, "专色1"); addSpotColorToSwatches(40, 80, 0, "专色2"); addSpotColorToSwatches(20, 60, 0, "专色3"); addSpotColorToSwatches(10, 40, 0, "专色4"); function addSpotColorToSwatches(L, a, b, swatchName) { var color = new LabColor(); color.l = L; color.a = a; color.b = b; var newSpot = docRef.spots.add(); newSpot.colorType = ColorModel.SPOT; newSpot.spotKind = SpotColorKind.SPOTLAB; newSpot.color = color; swatchgroup.addSpot(newSpot); newSpot.name = swatchName; };
__________________
无个性,不签名! |
|||
2022-09-13, 09:56 | 只看该作者 #3 | |||
|
||||
正式会员
等级: 四袋长老
|
引用:
单独执行多次没问题 此帖于 2022-09-13 10:20 被 baiju 编辑. |
|||