【问题标题】:Counting Photoshop Clipping Path Points计算 Photoshop 剪切路径点
【发布时间】:2019-01-14 05:32:21
【问题描述】:

我正在尝试制作一个 Javascript 脚本,它可以提醒我文件中有多少剪切路径以及它有多少锚点。 (如果剪切路径太复杂,InDesign 会在我们环境中的某些计算机上崩溃)

我在脚本指南中找到了对象 PathPoint 和 PathPointInfo,但我似乎无法让它工作。

到目前为止我所做的是这个

// pathCount 

// enable double clicking from the Macintosh Finder or the Windows Explorer
#target photoshop

// in case we double clicked the file
app.bringToFront();

var activeDoc = app.activeDocument;


var totalPathItemCount = activeDoc.pathItems.length;

//myPathItem.subPathItems.length;

var myPathItem = activeDoc.pathItems.getByName("CLIPPING");

var mySubPathItem = myPathItem.subPathItems;

var clippingPathPointCount = myPathItem.pathPoints.length;



alert("There are " + totalPathItemCount + " paths and CLIPPING has " + clippingPathPointCount " points " );

【问题讨论】:

  • 我想报告路径“CLIPPING”的锚点总数。

标签: javascript photoshop extendscript


【解决方案1】:

使用for statement 遍历每个subPathItem,并将锚点的计数(即每个subPathItem)添加到clippingPathTotalAnchorCount 变量中。例如:

#target photoshop

app.bringToFront();

var activeDoc = app.activeDocument;
var totalPathItemCount = activeDoc.pathItems.length;

// Specifically for the path named "CLIPPING"...
var myPathItem = activeDoc.pathItems.getByName("CLIPPING");
var mySubPathItems = myPathItem.subPathItems;
var mySubPathItemCount = mySubPathItems.length;

// Loop over each subpath of the path named "CLIPPING".
// The count of anchor points for each subpath are added to the total.
var clippingPathTotalAnchorCount = 0;
for (var i = 0; i < mySubPathItemCount; i++) {
  clippingPathTotalAnchorCount += mySubPathItems[i].pathPoints.length;
}

alert("The document has " + totalPathItemCount + " path(s).\r" +
    "The path named CLIPPING has " + mySubPathItemCount + " subpaths,\r" +
    "with a total of " + clippingPathTotalAnchorCount + " anchor points.");

【讨论】:

    【解决方案2】:

    //Index the item in teh collection with [0]
    var mySubPathItem = myPathItem.subPathItems[0];

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-18
      • 1970-01-01
      • 1970-01-01
      • 2013-04-17
      • 1970-01-01
      • 1970-01-01
      • 2016-08-01
      • 2015-09-16
      相关资源
      最近更新 更多