跳转到内容

PathItem

app.activeDocument.pathItems[index]

指定一个路径项,其中包含定义其几何形状的 PathPoint 对象。

PathItem 类提供了对 Illustrator 中路径的完全访问。

setEntirePath 方法提供了一种非常高效的方式来创建由直线组成的路径。


app.activeDocument.pathItems[index].area

该路径的面积(以平方点为单位)。

如果面积为负,则路径是逆时针方向的。

自相交路径可能包含相互抵消的子区域,这使得即使路径有明显的面积,该值也可能为零。

Number (double);只读。


app.activeDocument.pathItems[index].artworkKnockout

此对象是否用于创建挖空效果,如果是,挖空类型是什么。

KnockoutState


app.activeDocument.pathItems[index].blendingMode

合成对象时使用的混合模式。

BlendModes


app.activeDocument.pathItems[index].clipping

如果为 true,此路径应作为剪切路径使用。

Boolean


app.activeDocument.pathItems[index].closed

如果为 true,此路径是闭合的。

Boolean


app.activeDocument.pathItems[index].controlBounds

对象的边界,包括描边宽度和控件。

4 个数字的数组;只读。


app.activeDocument.pathItems[index].editable

如果为 true,此项目是可编辑的。

Boolean;只读。


app.activeDocument.pathItems[index].evenodd

如果为 true,应使用奇偶规则来确定“内部”。

Boolean


app.activeDocument.pathItems[index].fillColor

路径的填充颜色。

Color


app.activeDocument.pathItems[index].filled

如果为 true,路径被填充。

Boolean


app.activeDocument.pathItems[index].fillOverprint

如果为 true,填充对象下方的图稿应进行叠印。

Boolean


app.activeDocument.pathItems[index].geometricBounds

对象的边界,不包括描边宽度。

4 个数字的数组;只读。


app.activeDocument.pathItems[index].guides

如果为 true,此路径是参考线对象。

Boolean


app.activeDocument.pathItems[index].height

组项目的高度。

Number (double)


app.activeDocument.pathItems[index].hidden

如果为 true,此项目是隐藏的。

Boolean


app.activeDocument.pathItems[index].isIsolated

如果为 true,此对象是隔离的。

Boolean


app.activeDocument.pathItems[index].layer

此项目所属的图层。

Layer;只读。


app.activeDocument.pathItems[index].left

项目左侧的位置(以点为单位,从页面左侧测量)。

Number (double)


app.activeDocument.pathItems[index].length

此路径的长度(以点为单位)。

Number (double)


app.activeDocument.pathItems[index].locked

如果为 true,此项目是锁定的。

Boolean


app.activeDocument.pathItems[index].name

此项目的名称。

String


app.activeDocument.pathItems[index].note

分配给此项目的注释。

String


app.activeDocument.pathItems[index].opacity

对象的不透明度。

范围:0.0 到 100.0

Number (double)


app.activeDocument.pathItems[index].parent

此对象的父对象。

LayerGroupItem


app.activeDocument.pathItems[index].pathPoints

此路径项中包含的路径点。

PathPoints;只读。


app.activeDocument.pathItems[index].pixelAligned

如果为 true,此项目对齐到像素网格。

Boolean


app.activeDocument.pathItems[index].polarity

路径的极性。

PolarityValues


app.activeDocument.pathItems[index].position

pluginItem 对象左上角的位置(以点为单位),格式为 [x, y]。不包括描边宽度。

2 个数字的数组;只读。


app.activeDocument.pathItems[index].resolution

路径的分辨率(以每英寸点数 (dpi) 为单位)。

Number (double)


app.activeDocument.pathItems[index].selected

如果为 true,此项目被选中。

Boolean


app.activeDocument.pathItems[index].selectedPathPoints

路径中所有选中的路径点。

PathPoints;只读。


app.activeDocument.pathItems[index].sliced

如果为 true,项目被切片。

默认值:false

Boolean


app.activeDocument.pathItems[index].strokeCap

线帽的类型。

StrokeCap


app.activeDocument.pathItems[index].strokeColor

路径的描边颜色。

Color


app.activeDocument.pathItems[index].stroked

如果为 true,路径应描边。

Boolean


app.activeDocument.pathItems[index].strokeDashes

虚线长度。设置为空对象 {} 表示实线。

Object


app.activeDocument.pathItems[index].strokeDashOffset

虚线图案中默认开始的距离。

Number (double)


app.activeDocument.pathItems[index].strokeJoin

路径的连接类型。

StrokeJoin


app.activeDocument.pathItems[index].strokeMiterLimit

当默认描边连接设置为斜接时,此属性指定何时将连接转换为斜切(方形)。默认的斜接限制为 4 表示当点的长度达到描边宽度的四倍时,连接将从斜接连接转换为斜切连接。值为 1 表示斜切连接。

范围:1 到 500。

默认值:4

Number (double)


app.activeDocument.pathItems[index].strokeOverprint

如果为 true,描边对象下方的图稿应进行叠印。

Boolean


app.activeDocument.pathItems[index].strokeWidth

描边的宽度(以点为单位)。

Number (double)


app.activeDocument.pathItems[index].tags

此项目中包含的标签。

Tags;只读。


app.activeDocument.pathItems[index].top

项目顶部的位置(以点为单位,从页面底部测量)。

Number (double)


app.activeDocument.pathItems[index].typename

引用对象的类名。

String;只读。


app.activeDocument.pathItems[index].uRL

分配给此项目的 Adobe URL 标签的值。

String


app.activeDocument.pathItems[index].visibilityVariable

绑定到项目的可见性变量。

Variable


app.activeDocument.pathItems[index].visibleBounds

项目的可见边界,包括描边宽度。

4 个数字的数组;只读。


app.activeDocument.pathItems[index].width

项目的宽度。

Number (double)


app.activeDocument.pathItems[index].wrapInside

如果为 true,文本框架对象应在此对象内部换行。

Boolean


app.activeDocument.pathItems[index].wrapOffset

围绕此对象换行文本时使用的偏移量。

Number (double)


app.activeDocument.pathItems[index].wrapped

如果为 true,围绕此对象换行文本框架对象(文本框架必须位于对象上方)。

Boolean


app.activeDocument.pathItems[index].zOrderPosition

此项目在包含该项目的组或图层(parent)中的堆叠顺序中的位置。

Number;只读。


app.activeDocument.pathItems[index].duplicate([relativeObject][, insertionLocation])

创建所选对象的副本。

参数类型描述
relativeObjectObject, 可选要复制到的对象
insertionLocationElementPlacement, 可选插入元素的位置

PathItem


app.activeDocument.pathItems[index].move(relativeObject, insertionLocation)

移动对象。

参数类型描述
relativeObjectObject要移动元素的对象
insertionLocationElementPlacement, 可选移动元素到的位置

PathItem


app.activeDocument.pathItems[index].remove()

删除此对象。

无。


app.activeDocument.pathItems[index].resize(
scaleX,
scaleY
[,changePositions]
[,changeFillPatterns]
[,changeFillGradients]
[,changeStrokePattern]
[,changeLineWidths]
[,scaleAbout]
)

缩放图稿项,其中 scaleX 是水平缩放因子,scaleY 是垂直缩放因子。100.0 = 100%。

参数类型描述
scaleXNumber (double)水平缩放因子
scaleYNumber (double)垂直缩放因子
changePositionsBoolean, 可选是否影响图稿对象的位置和方向
changeFillPatternsBoolean, 可选是否变换填充图案
changeFillGradientsBoolean, 可选是否变换填充渐变
changeStrokePatternBoolean, 可选是否变换描边图案
changeLineWidthsNumber (double), 可选缩放线宽的量
scaleAboutTransformation, 可选用作锚点的点,用于变换

无。


app.activeDocument.pathItems[index].rotate(
angle
[,changePositions]
[,changeFillPatterns]
[,changeFillGradients]
[,changeStrokePattern]
[,rotateAbout]
)

相对于当前旋转角度旋转图稿项。

如果 angle 值为正,则对象逆时针旋转;如果值为负,则顺时针旋转。

参数类型描述
angleNumber (double)旋转元素的角度量
changePositionsBoolean, 可选是否影响图稿对象的位置和方向
changeFillPatternsBoolean, 可选是否变换填充图案
changeFillGradientsBoolean, 可选是否变换填充渐变
changeStrokePatternBoolean, 可选是否变换描边图案
rotateAboutTransformation, 可选用作锚点的点,用于变换

无。


app.activeDocument.pathItems[index].setEntirePath(pathPoints)

使用 [x, y] 坐标对的数组设置路径。

参数类型描述
pathPoints[x, y] 坐标对的数组要设置的点坐标数组

无。


app.activeDocument.pathItems[index].transform(
transformationMatrix
[, changePositions]
[, changeFillPatterns]
[, changeFillGradients]
[, changeStrokePattern]
[, changeLineWidths]
[, transformAbout]
)

通过应用变换矩阵来变换图稿项。

参数类型描述
transformationMatrixMatrix要应用的变换矩阵
changePositionsBoolean, 可选是否更改位置
changeFillPatternsBoolean, 可选是否更改填充图案
changeFillGradientsBoolean, 可选是否更改填充渐变
changeStrokePatternBoolean, 可选是否更改描边图案
changeLineWidthsNumber (double), 可选缩放线宽的量
transformAboutTransformation, 可选用作锚点的点,用于变换

无。


app.activeDocument.pathItems[index].translate(
[deltaX]
[, deltaY]
[, transformObjects]
[, transformFillPatterns]
[, transformFillGradients]
[, transformStrokePatterns]
)

相对于当前位置重新定位图稿项,其中 deltaX 是水平偏移量,deltaY 是垂直偏移量。

参数类型描述
deltaXNumber (double), 可选水平偏移量
deltaYNumber (double), 可选垂直偏移量
transformObjectsBoolean, 可选是否变换对象
transformFillPatternsBoolean, 可选是否变换填充图案
transformFillGradientsBoolean, 可选是否变换填充渐变
transformStrokePatternsBoolean, 可选是否变换描边图案

无。


app.activeDocument.pathItems[index].zOrder(zOrderCmd)

在组或图层(父对象)的堆叠顺序中排列图稿项的位置。

参数类型描述
zOrderCmdZOrderMethod堆叠顺序排列方法

无。


// 将路径项的描边和填充设置为随机选择的色板的颜色
if (app.documents.length > 0 && app.activeDocument.pathItems.length > 0) {
var doc = app.activeDocument;
for (var i = 0; i < doc.pathItems.length; i++) {
var pathRef = doc.pathItems[i];
pathRef.filled = true;
pathRef.stroked = true;
var swatchIndex = Math.round(Math.random() * (doc.swatches.length - 1));
pathRef.fillColor = doc.swatches[swatchIndex].color;
pathRef.strokeColor = doc.swatches[swatchIndex].color;
}
}

// 此脚本演示了 setEntirePath 方法的使用。
// 创建一个由10条直线组成的新开放路径
if (app.documents.length > 0) {
var lineList = [];
for (i = 0; i < lineList.length; i++) {
lineList.push([i * 10 + 50, ((i - 5) ^ 2) * 5 + 50];
}
app.defaultStroked = true;
newPath = app.activeDocument.pathItems.add();
newPath.setEntirePath(lineList);
}