考虑到翻译的一些专业术语以及精确性,关于API的整体描述部分保留了原文,对API具体的属性及作用进行翻译,请根据需求进行调整,虽然是vbsciprt的版本,但是python也可以调用的,调用方法自行搜索
ADOBE® ILLUSTRATOR®
ADOBE ILLUSTRATOR 2024 SCRIPTING REFERENCE:VBSCRIPT
2024 Adobe Incorporated. All rights reserved.
Adobe Illustrator 2024 Scripting Reference: VBScript
If this guide is distributed with software that includes an end user agreement, this guide, as well as the software
described in it, is furnished under license and may be used or copied only in accordance with the terms of such license. Except as permitted by any such license, no part of this guide may be reproduced, stored in a retrieval system, or
transmitted, in any form or by any means, electronic, mechanical, recording, or otherwise, without the prior written
permission of Adobe Incorporated. Please note that the content in this guide is protected under copyright law even if it is not distributed with software that includes an end user license agreement.
The content of this guide is furnished for informational use only, is subject to change without notice, and should not be construed as a commitment by Adobe Incorporated. Adobe Incorporated assumes no responsibility or liability for any errors or inaccuracies that may appear in the informational content contained in this guide.
Please remember that existing artwork or images that you may want to include in your project may be protected under copyright law. The unauthorized incorporation of such material into your new work could be a violation of the rights of the copyright owner. Please be sure to obtain any permission required from the copyright owner.
Any references to company names in sample templates are for demonstration purposes only and are not intended to refer to any actual organization.
Adobe, the Adobe logo, Acrobat, Illustrator, Macromedia, and Photoshop are either registered trademarks or trademarks of Adobe Incorporated in the United States and/or other countries.
Macintosh is a trademark of Apple Computer, Incorporated, registered in the United States and other countries. Windows is either a registered trademark or trademark of Microsoft Corporation in the United States and other countries.
JavaScript and all Java-related marks are trademarks or registered trademarks of Sun Microsystems, Incorporated in the United States and other countries.
All other trademarks are the property of their respective owners.
Adobe Incorporated, 345 Park Avenue, San Jose, California 95110, USA. Notice to U.S. Government End Users. The
Software and Documentation are “Commercial Items,” as that term is defined at 48 C.F.R. §2.101, consisting of
“Commercial Computer Software”and “Commercial Computer Software Documentation,” as such terms are used in 48 C.F.R. §12.212 or 48 C.F.R. §227.7202, as applicable. Consistent with 48 C.F.R. §12.212 or 48 C.F.R. §§227.7202-1 through 227.7202-4, as applicable, the Commercial Computer Software and Commercial Computer Software Documentation are being licensed to U.S. Government end users (a) only as Commercial Items and (b) with only those rights as are granted to all other end users pursuant to the terms and conditions herein. Unpublished-rights reserved under the copyright
laws of the United States. Adobe Incorporated, 345 Park Avenue, San Jose, CA 95110-2704, USA. For U.S. Government End Users, Adobe agrees to comply with all applicable equal opportunity laws including, if appropriate, the provisions of
Executive Order 11246, as amended, Section 402 of the Vietnam Era Veterans Readjustment Assistance Act of 1974 (38 USC 4212), and Section 503 of the Rehabilitation Act of 1973, as amended, and the regulations at 41 CFR Parts 60-1
through 60-60, 60-250, and 60-741. The affirmative action clause and regulations contained in the preceding sentence shall be incorporated by reference.
Contents
1 VBScript Object Reference 8
1 VBScript Object Reference
This reference section describes the objects and methods in the Illustrator VBScript type library. All of the classes in the type library are presented alphabetically. The chapter concludes with an enumerations
reference which lists all of the enumerations in the Illustrator type library.
Each class listing includes the following:
b Properties of the class — These include value type, read-only status, and an explanation.
b Methods for the class — Value types needed by the method are shown in boldface. Enumerated
values are linked to the Chapter 2, “Enumerations Reference.” Required terms are shown in plain face. All items surrounded by brackets ([ ]) are optional.
b Script examples — These example are intended to illustrate concepts, and do not necessarily
represent the best or most efficient way to construct a VBScript script. They contain little error
checking, and assume that the proper context exists for the scripts to execute in (for instance, that there is a document open or items selected).
Each script contains a single subroutine that can be pasted into any event in a VBScript form if you are using the VBScript development environment. A standard button click event is used for all examples. If you are using a built-in VBScript editor in a VBA application, you can paste the script into a macro
routine. In either case, modify the Sub statement in the example to work with your situation.
For an overview of how the Illustrator object model is structured, see Adobe Illustrator 2024 Scripting Guide.
Page 9
Application
The Adobe Illustrator application object, which contains all other Illustrator objects.
Application properties
Property | Value type | What it is |
---|---|---|
ActionIsRunning | Boolean | Read-only. If true, an action is still running. 只读。如果为 true,则表示动作仍在运行中。 |
ActiveDocument | Document | The active (frontmost) document in Illustrator. 当前(前台)Illustrator 文档对象。 |
Application | Application | Read-only. The Illustrator Application object. 只读。Illustrator 应用程序对象本身。 |
BrowserAvailable | Boolean | Read-only. If true, a Web browser is available. 只读。如果为 true,则表示系统可用 Web 浏览器。 |
BuildNumber | String | Read-only. The application’s build number. 只读。应用程序的构建号。 |
ColorSettingsList | Variant | Read-only. The list of color-settings files currently available for use. 只读。当前可供使用的颜色设置文件列表。 |
CoordinateSystem | AiCoordinateSystem | The coordinate system currently in use,document or artboard. 当前正在使用的坐标系统,可以是文档坐标系统或画板坐标系统。 |
DefaultColorSettings | String | Read-only. The default color-settings file for the current application locale. 只读。当前应用程序语言环境下的默认颜色设置文件。 |
Documents | Documents | Read-only. The documents in the application. 只读。应用程序中的所有文档集合。 |
FlattenerPresetsList | Variant | Read-only. The list of flattener style names currently available for use. 只读。当前可供使用的展平样式名称列表。 |
FreeMemory | Long | Read-only. The amount of unused memory (in bytes) within the Illustrator partition. 只读。Illustrator 分区中未使用的内存(以字节为单位)数量。 |
HomeScreenVisible | Boolean | Read-only. If true, the Home screen is visible. 只读。如果为 true,则表示主页屏幕可见。 |
Locale | String | Read-only. The application’s locale. 只读。应用程序的语言环境设置。 |
Name | String | Read-only. The application’s name (not related to the filename of the application file). 只读。应用程序的名称(与应用程序文件名无关)。 |
PasteRememberLayers | Boolean | Read-only. If true, the paste operation maintains the layer structure. 只读。如果为 true,则粘贴操作会保留图层结构。 |
Path | String | Read-only. The file path to the application. 只读。应用程序的文件路径。 |
PDFPresetsList | Variant Array of String | Read-only. The list of preset PDF-options names available for use. 只读。当前可供使用的预设 PDF 选项名称列表。 |
PPDFileList | Variant Array of Strings | Read-only. The list of PPD files currently available for use. 只读。当前可供使用的 PPD 文件列表。 |
Preferences | Preferences | Read-only. The application preferences. 只读。应用程序的偏好设置。 |
PrinterList | Variant | Read-only. A list of available printers. 只读。可用打印机的列表。 |
PrintPresetsList | Variant | Read-only. The list of preset printing-options names currently available for use. 只读。当前可供使用的预设打印选项名称列表。 |
ScriptingVersion | String | Read-only. The version of the Scripting plug-in. 只读。脚本插件版本。 |
Selection | Variant Array of objects | All currently selected objects in the active (frontmost) document. 当前(前台)文档中所有选定的对象集合。 |
StartupPresetsList | Variant | Read-only. The list of presets available for creating a new document. 只读。用于创建新文档时可选择的预设列表。 |
TextFonts | TextFonts | Read-only. The installed fonts. 只读。已安装的所有字体集合。 |
TracingPresetList | Variant Array of String | Read-only. The list of preset tracing-options names available for use. 只读。当前可供使用的预设描摹选项名称列表。 |
UserInteractionLevel | AiUserInteractionL evel | The allowed level of interaction with users in the form of dialogs and message boxes. 允许用户交互级别,即对话框和消息框形式的用户交互程度。 |
Version | String | Read-only. The version of the Illustrator application 只读。Illustrator 应用程序的版本号。 |
Visible | Boolean | Read-only. If true, the application is visible.只读。如果为 true,则表示应用程序窗口可见。 |
Application methods
Method | Returns | What it does |
---|---|---|
ConcatenateMatrix (matrix as Matrix,secondMatrix as Matrix) | Matrix | Concatenates two matrices. 将两个矩阵连接(拼接)在一起。 |
ConcatenateRotationMatrix (matrix as Matrix,angle as Double) | Matrix | Concatenates a rotation to a transformation matrix. 向变换矩阵中添加一个旋转。 |
ConcatenateScaleMatrix (matrix as Matrix,[, scaleX as Double][, scaleY as Double]) | Matrix | Concatenates a scale to a transformation matrix. 向变换矩阵中添加一个缩放变换。 |
ConcatenateTranslationMatrix (matrix as Matrix,[, deltaX as Double][, deltaY as Double]) | Matrix | Concatenates a translation to a transformation matrix. 向变换矩阵中添加一个平移变换。 |
ConvertSampleColor(SourceColorSpace as AiImageColorSpace,SourceColor as ColorComponents,DestColorSpace as AiImageColorSpace,ColorConvertPurpose as AiColorConvertPurpose [,SourceHasAlpha as Boolean][,DestHasAlpha as Boolean]) | array of ColorCom ponents | Converts a sample-component color from one color space to another. 将样本颜色从一个颜色空间转换到另一个颜色空间。 |
Copy() | Nothing | Copies the current selection to the clipboard. 复制当前选择内容至剪贴板。 |
Cut() | Nothing | Cuts the current selection to the clipboard. 剪切当前选择内容至剪贴板。 |
DeleteWorkspace(workspaceName as String) | Boolean | Deletes a workspace. 删除指定的工作区。 |
DoJavaScript(JavaScriptCode as String,[, Arguments as Variant Array][, ExecutionMode as AiJavaScriptExecutionMode]) | String | Executes the specified JavaScript® code. 执行指定的 JavaScript 代码。 |
DoJavaScriptFile(JavaScriptFile as File,[, Arguments as Variant Array][, ExecutionMode as AiJavaScriptExecutionMode]) | String | Executes the specified JavaScript file. 执行指定的 JavaScript 文件。 |
DoScript(Action as String,From as String[, dialogs as Boolean]) | Nothing | Plays an action from the Actions palette.NOTE: Use DoScript only if you intend to run your script from an application external to Illustrator, such as the Windows® Script Host. Calling DoScript when running a script from Illustrator’s File > Scripts menu may yield unexpected results. 播放“动作”面板中的指定动作。注意:仅当您打算从 Illustrator 外部的应用程序(如 Windows Script Host)运行脚本时使用 DoScript。如果在 Illustrator 的“文件 > 脚本”菜单下运行脚本并调用 DoScript,可能会得到意外结果。 |
GetIdentityMatrix() | Matrix | Returns an identity matrix. 返回一个单位矩阵。 |
GetPPDFileInfo(Name as String) | PPDFileI nfo | Gets detailed file information for specified PPD file. 获取指定 PPD 文件的详细信息。 |
GetPresetFileOfType(PresetType as AiDocumentPresetType) | String | Returns the full path to the default document profile for the specified preset type. 返回指定预设类型对应的默认文档配置文件的完整路径。 |
GetPresetSettings(Preset as String) | Document Preset | Retrieves the tracing-option settings from the template with a given preset name. 从具有给定预设名称的模板获取描摹选项设置。 |
GetRotationMatrix([Angle as Double]) | Matrix | Returns a transformation matrix containing a single rotation.NOTE: Requires a value in degrees. For example, 30 rotates the object 30 degrees counterclockwise; -30 rotates the object 30 degrees clockwise. 返回包含单一旋转的变换矩阵。注:参数为度数,例如30表示逆时针旋转30度,-30表示顺时针旋转30度。 |
GetScaleMatrix([scaleX as Double][, scaleY as Double]) | Matrix | Returns a transformation matrix containing a single scale.NOTE: Requires a value in percentage. For example, 60 scales the object to 60% of its original size; 200 doubles the object’s bounds. 返回包含单一缩放的变换矩阵。注:参数为百分比,例如60表示将对象缩放至原尺寸的60%,200表示将对象放大一倍。 |
GetScriptableHelpGroup() | variant | Gets the scriptable help group object that represents the search widget in the app bar. 获取代表应用程序顶部搜索小部件的可脚本帮助组对象。 |
GetTranslationMatrix([deltaX as Double][, deltaY as Double]) | Matrix | Returns a transformation matrix containing a single translation.NOTE: Requires a value in points. For example,{100,200} moves the object 100 pt.to the right and 200 pt. up; a minus before each number moves the object left and down. 返回包含单一平移的变换矩阵。注:参数为点数,例如{100,200}表示将对象向右移动100pt、向上移动200pt;负值表示向反方向移动。 |
InvertMatrix(matrix as Matrix) | Matrix | Inverts a matrix. 计算并返回一个矩阵的逆矩阵。 |
IsEqualMatrix(matrix as Matrix,secondMatrix as Matrix) | Boolean | Checks whether two matrices are equal. 检查两个矩阵是否相等。 |
IsSingularMatrix(matrix as Matrix) | Boolean | Checks whether a matrix is singular and cannot be inverted. 检查一个矩阵是否奇异(不可逆)。 |
LoadColorSettings(fileSpec as String) | Nothing | Loads color settings from specified file, or, if file is empty, turns color management off. 从指定文件加载颜色设置,若文件为空则关闭颜色管理功能。 |
Open(file as String,[documentColorSpace as AiDocumentColorSpace], [options as Object]) | Document | Opens the specified file document.If called to open a pre-Illustrator 9 document that contains both RGB and CMYK colors, supply DocumentColorSpace in order to convert all colors to the specified color space. If not supplied,Illustrator displays a dialog to the user. 打开指定的文件文档。对于包含RGB和CMYK颜色的Illustrator 9之前的文档,在打开时应提供documentColorSpace参数以将所有颜色转换至指定的颜色空间,否则Illustrator会显示对话框询问用户。 |
Paste | Nothing | Pastes the clipboard content into the current document. 将剪贴板内容粘贴到当前文档中。 |
Quit | Nothing | Quits Illustrator. 退出 Illustrator 应用程序。 |
Redo | Nothing | Redoes the most recently undone transaction. 恢复最近一次撤销的操作。 |
Redraw() | Nothing | Forces Illustrator to redraw all its windows. 强制 Illustrator 重新绘制其所有窗口。 |
ResetWorkspace | Boolean | Resets the current workspace. 重置当前工作区。 |
SaveWorkspace(workspaceName as String) | Boolean | Saves a new workspace. 保存新的工作区。 |
ShowPresets(fileSpec as String) | Nothing | Gets the presets from the file. 从文件中获取预设。 |
SwitchWorkspace(workspaceName as String) | Boolean | Switches to a workspace. 切换至指定的工作区。 |
TranslatePlaceholderText(text as String) | Nothing | Translates the placeholder text to regular text; a way to enter unicode points in hex values. 将占位符文本转换为常规文本,用于输入Unicode十六进制编码点值。 |
Undo | Nothing | Undoes the most recent transaction. 撤销最近执行的操作。 |
Opening a document
Set appRef = CreateObject("Illustrator.Application")
Set docRef = appRef.Open("C:\temp\aFile.ai")
Accessing the selection
In Illustrator, the application’s Selection can be accessed as well as modified. The selection will contain Empty when there are no selected objects. To deselect all objects in the current document, set the
selection to Empty, as the following example shows.
Set appRef = CreateObject("Illustrator.Application")
appRef.activeDocument.Selection = Empty
A reference to a text range is returned when there is an active insertion point in the contents of a TextFrame. Similarly, a reference to a range of text is returned when characters are selected in the contents of a TextFrame.
Executing an action
You can run an action from the Action Palette from a script by using the DoScript method. When you do this, the control returns to your script before the action has completed. Use the ActionIsRunning
property to test for when the action has completed before executing any other VBScript methods (see the Windows.DoAction example). You can also use the Sleep method defined on the WScript object to insert a pause to test this property, as in the following example:
Set appRef = CreateObject("Illustrator.Application")
appRef.DoScript "Opacity 60 (selection)", "Default Actions"
WHILE(appRef.ActionIsRunning)
WScript.sleep 1000
WEND
msgbox "Done"
Invoking JavaScript
DoJavaScript and DoJavaScriptFile can be used to invoke scripts written in JavaScript for Illustrator.
The first argument to DoJavaScript is a string that must evaluate to a valid JavaScript expression. For example, the following script displays an alert using the JavaScript alert method.
appRef.DoJavaScript "alert(
This example returns the number of open documents.
Set myNumberOfDocuments = appRef.DoJavaScript("documents.length;")
MsgBox myNumberOfDocuments
Copy and paste between documents
This script uses the application property ActiveDocument to copy the current document’s selection to the clipboard before pasting it into our new document. This script also demonstrates how to create a new
document with a specific color space and dimensions.
'Duplicates the selected item in the current document to a new document
Set appRef = CreateObject("Illustrator.Application")
If appRef.Documents.Count > 0 Then
If Not IsEmpty(appRef.ActiveDocument.selection) Then
appRef.ActiveDocument.Copy
Set newDocument = appRef.Documents.Add(aiDocumentCMYKColor,250, 400)
newDocument.Paste
End If
End If
Page 16
Artboard
An Artboard object represents a single artboard in a document. There can be between 1 to 100 artboards in one document.
Artboard properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。Illustrator 应用程序对象本身,表示该画板所属的应用上下文。 |
ArtboardRect | Rect | Size and position of the artboard. 画板的大小和位置,即画板的矩形区域坐标信息。 |
Name | String | The unique identifying name of the artboard. 画板的唯一标识名称。 |
Parent | Document | Read-only. The name of the object that is this Artboard object’s parent. 只读。此 Artboard 对象父级的对象名,即包含该画板的文档对象。 |
RulerOrigin | Point | Ruler origin of the artboard, relative to the left top corner of the artboard. 画板标尺原点,相对于画板左上角的坐标位置。 |
RulerPAR | Double | Pixel aspect ratio, used in ruler visualization if the units are pixels. Range: 0.1 to 10.0 像素长宽比(Pixel Aspect Ratio),当单位设置为像素时,在标尺可视化中使用。范围:0.1 到 10.0。 |
ShowCenter | Boolean | Show center mark. 是否显示中心标记(center mark)。 |
ShowCrossHairs | Boolean | Show cross hairs. 是否显示十字线(cross hairs)定位辅助线。 |
ShowSafeAreas | Boolean | Show title and action safe areas (for video). 是否显示标题安全区和动作安全区(主要用于视频制作场景)。 |
Artboard methods
Method | Returns | What it does |
---|---|---|
Delete() | Nothing | Deletes this artboard object. You cannot remove the last artboard in a document. 删除此画板对象。需要注意的是,不能删除文档中的最后一个画板,即任何时候文档至少需要保留一个画板。 |
page 17
Artboards
A collection of artboards.
Artboards properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。表示该对象所属的Illustrator应用程序对象。 |
Count | Long | Read-only. The number of objects in the collection. 只读。表示集合中对象的数量。 |
Parent | Document | Read-only. The document that contains this object. 只读。包含此对象的文档对象,即该对象所在的父级文档。 |
Artboards methods
Method | Returns | What it does |
---|---|---|
Add(rect as ArtboardRect) | Artboard | Creates a new Artboard object. 根据给定的ArtboardRect参数创建并返回一个新的Artboard对象。 |
GetActiveArtboardIndex() | Long | Retrieves the index position of the active artboard in the document 获取文档中当前活动画板在其所在文档中的索引位置。 |
GetByName(artboardName as String) | Artboard | Retrieves an artboard object from the list by its unique identifying name. 通过唯一的名称标识符从列表中检索一个画板对象。 |
Index(item as DataSets) | Long | Returns the index position of the object within the collection. 返回集合中指定对象在其内部的索引位置,但此处的“DataSets”类型可能有误,请确认是否应为Artboard类型。 |
Insert(rect as ArtboardRect,index as Long) | Nothing | Creates a new artboard object and inserts it at the given index in the list. 根据给定的ArtboardRect参数创建一个新的画板对象,并将其插入到列表中的指定索引位置。 |
Item(itemKey) | Artboard | Returns an object reference to the object identified by itemKey (name or index). 通过itemKey(名称或索引)返回对集合中特定Artboard对象的引用。 |
Remove(index as Long) | Nothing | Deletes an artboard object. You cannot remove the last artboard in a document. 删除指定索引位置处的画板对象。需要注意的是,不能移除文档中的最后一个画板。 |
SetActiveArtboardIndex (index as Long) | Nothing | Makes a specific artboard active and makes it current in the iteration order. 设置指定索引位置处的画板为活动状态,并使其成为迭代顺序中的当前画板。 |
page 18
AutoCADFileOptions
Options for opening an AutoCAD drawing, used with the Open method.
AutoCADFileOptions properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。表示Illustrator应用程序本身的对象,提供对全局应用级别的功能和设置的访问。 |
CenterArtwork | Boolean | If true, center the artwork that is created on the artboard. Default is true. 如果设为true,则在画板上创建的艺术品将被居中。默认值为true。 |
GlobalScaleOption | AiAutoCADGlobalScaleOption | How to scale the drawing on import. Default is 1 定义导入时如何缩放图形。默认值为1,表示按原尺寸导入。 |
GlobalScalePercent | Double | The value when globalScaleOption is 2 aiScaleByValue, expressed as a percentage. Range: 0.0 to 100.0 Default is 100.0 当GlobalScaleOption设置为2(aiScaleByValue)时,用百分比表示的缩放值。范围:0.0到100.0,默认值为100.0。 |
MergeLayers | Boolean | If true, the layers of the artwork are merged. Default: false 如果设为true,将合并艺术品的所有图层。默认值为false,即保持图层结构不变。 |
Parent | Document | Read-only. The document that contains this object. 只读。包含该对象的文档,表示此画板所属的整体文档上下文。 |
ScaleLineweights | Boolean | If true, scales line weights by the same factor as the rest of the drawing. Default is false. 如果设为true,则线条粗细会按照与其余绘图相同的比例进行缩放。默认值为false。 |
SelectedLayoutName | String | Name of the layout in the drawing to import. 指定要导入图纸中的布局名称。 |
Unit | AiAutoCADUnit | The unit to map to. Default is 3 aiMillimeters. 用于映射单位的目标单位。默认值为3(aiMillimeters),即毫米。 |
UnitScaleRatio | Double | The ratio by which to scale while mapping units. Default is 1.0 在单位映射过程中使用的比例因子。默认值为1.0,表示不改变单位比例。 |
page 19
Brush
A brush in an Illustrator document. Illustrator brushes can be accessed, but not created or deleted, from a script.
Brush properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。表示Illustrator应用程序自身的对象,提供了对整个应用级功能和设置的访问权限。 |
Name | String | The Brush name. 画笔的名称,用于标识和区分不同的画笔样式。 |
Parent | Object | Read-only. The container object. 只读。容器对象,代表该画笔所属的上下文对象,通常是包含此画笔的集合或库。例如,在Illustrator中,这可能是指向包含此画笔的文档或画笔库的对象。 |
Brush methods
Method | Returns | What it does |
---|---|---|
ApplyTo(artItem as PageItem) | Nothing | Applies the brush to a specific art item. 将此画笔应用于指定的美术项目(Art Item)。该方法会将当前画笔样式应用于给定的PageItem对象,例如路径、形状或其他可以使用画笔描边的Illustrator元素。 |
Applying a Brush
'Creates a new group, adds a duplicate of each selected item to the group
'then applies a brush to each item in the group
Set appRef = CreateObject("Illustrator.Application")
If appRef.Documents.Count > 0 Then
If Not IsEmpty(appRef.Selection) Then
selectedItems = appRef.Selection
startIndex = LBound(selectedItems)
endIndex = UBound(selectedItems)
Set newGroup = appRef.ActiveDocument.GroupItems.Add
For i = startIndex To endIndex
Set artItem = selectedItems(i)
Set dupItem = artItem.Duplicate(newGroup, aiPlaceAtEnd)
appRef.ActiveDocument.Brushes(2).ApplyTo artItem
Next
End If
End If
page 20
Brushes
A collection of brushes in a document.
Brushes properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。Illustrator应用程序对象。表示该集合所属的整个Illustrator应用程序实例。 |
Count | Long | Read-only. Long. The number of objects in the collection. 只读。长整型数值。表示集合中对象的数量,即当前包含的对象个数。 |
Parent | Object | Read-only. The document that contains this object. 只读。对象。表示包含此对象的父级对象,通常在Illustrator中指的是包含当前集合的文档对象。这意味着访问此属性会返回一个指向该集合所在文档的引用。 |
Brushes methods
Method | Returns | What it does |
---|---|---|
Index(item as Brush) | Long | Returns the index position of the object within the collection. 返回指定画笔对象在集合中的索引位置。给定一个Brush对象作为参数,此方法会返回该画笔在当前集合中所处的索引号。 |
Item(itemKey) | Brush | Returns an object reference to the object identified by itemKey (name or index). 通过名称或索引获取并返回集合中特定画笔对象的引用。当提供itemKey作为名称或索引时,该方法会返回对应于该键值的Brush对象实例。 |
Get all brushes in a document
'Counts the number of brushes in the current document
'and stores in numBrushes
Set appRef = CreateObject("Illustrator.Application")
If appRef.Documents.Count > 0 Then
numBrushes = appRef.ActiveDocument.Brushes.Count
End If
page 21
CharacterAttributes
Specifies the properties of a character contained in a text frame. A CharacterStyle object associates attributes with a text range. See “CharacterStyle” on page 27.
NOTE: Character attributes do not have default values and are undefined until explicitly set.
CharacterAttributes properties
Property | Value Type | What it is |
---|---|---|
AkiLeft | Double | The amount of inter-glyph space added to the left side of the glyph in Japanese text (in thousandths of an em). 在日语文本中,为字形左侧增加的字间间距量(以千分之一em为单位)。 |
AkiRight | Double | The amount of inter-glyph spacing added to the right side of the glyph in Japanese text (in thousandths of an em). 在日语文本中,为字形右侧增加的字间间距量(以千分之一em为单位)。 |
Alignment | AiStyleRunAlignmentType | The character alignment type. 字符对齐方式。 |
AlternateGlyphs | AiAlternateGlyphsForm | Specifies which kind of alternate glyphs are used. 指定使用的替代字形种类。 |
Application | Application | Read-only. The Illustrator Application object. 只读。指向Adobe Illustrator应用程序的对象,可以访问和控制整个应用程序的功能。 |
AutoLeading | Boolean | If true, automatic leading is used. 如果为真,则表示使用自动行距。 |
BaselineDirection | AiBaselineDirectionType | The Japanese text baseline direction. 日语文本的基线方向。 |
BaselinePosition | AiFontBaselineOption | The baseline position of text. 文本的基线位置。 |
BaselineShift | Double | The amount of shift (in points) of the text baseline. 文本基线相对于默认位置的偏移量(以点为单位)。 |
Capitalization | AiFontCapsOption | Specifies whether the text is normal, all uppercase, all small caps, or a mix of small caps and lowercase. 指定文本是否为正常、全大写、全小写或小写字母与大写字母混合。 |
ConnectionForms | Boolean | If true, OpenType® connection forms are used. 如果为真,则表示使用OpenType®连接形式。 |
ContextualLigature | Boolean | If true, contextual ligatures are used. 如果为真,则表示使用上下文连字。 |
DiscretionaryLigature | Boolean | If true, discretionary ligatures are used. 如果为真,则表示使用可选连字。 |
FigureStyle | AiFigureStyleType | The number style in an OpenType font. 在OpenType字体中的数字样式。 |
FillColor | Object | The color of the text fill. 文本填充的颜色。 |
Fractions | Boolean | If true, OpenType fractions are used. 如果为真,则使用OpenType分数形式。 |
HorizontalScale | Double | The horizontal scaling factor (as a percentage). 水平缩放因子(以百分比表示)。 |
Italics | Boolean | If true, the Japanese font supports italics. 如果为真,则表示日文字体支持斜体样式。 |
KerningMethod | AiAutoKernType | The kerning method. 字间距调整方法。 |
Language | AiLanguageType | The language of the text. 文本的语言类型。 |
Leading | Double | The amount of space between two lines of text, in points. 两行文本之间的间距量(以点为单位)。 |
Ligature | Boolean | If true, ligatures are used. 如果为真,则启用连字功能。 |
NoBreak | Boolean | If true, no break is allowed. 如果为真,则不允许换行断开。 |
OpenTypePosition | AiFontOpenTypePositionOption | The OpenType baseline position. OpenType字体的基线位置选项。 |
Ordinals | Boolean | If true, OpenType ordinals are used. 如果为真,则使用OpenType序数符号。 |
Ornaments | Boolean | If true, OpenType ornaments are used. 如果为真,则使用OpenType装饰字符。 |
OverprintFill | Boolean | If true, overprint the fill of the text. 如果为真,则允许填充颜色叠印。 |
OverprintStroke | Boolean | If true, overprinting of the stroke of the text is allowed. 如果为真,则允许描边叠印。 |
Parent | Object | Read-only. The object’s container. 只读。该对象所处的容器。 |
ProportionalMetrics | Boolean | If true, proportional metrics in Japanese OpenType are used. 如果为真,则在日文OpenType中使用比例度量。 |
Rotation | Double | The character rotation angle. 字符旋转的角度。 |
Size | Double | The font size in points. 字体大小,以点为单位。 |
StrikeThrough | Boolean | If true, characters are struck-through by a line. 如果为真,则字符会被一条线划过。 |
StrokeColor | Object | The color of the text stroke. 文本描边的颜色。 |
StrokeWeight | Double | Line width of stroke. 描边线宽。 |
StylisticAlternates | Boolean | If true, OpenType stylistic alternates are used. 如果为真,则使用OpenType风格替换字符。 |
Swash | Boolean | If true, OpenType swash characters are used. 如果为真,则使用OpenType花饰字符。 |
TateChuYokoHorizontal | Long | The Tate-Chu-Yoko horizontal adjustment in points. Tate-Chu-Yoko水平调整量,以点为单位。Tate-Chu-Yoko是日文中的一种排版方式,用于调整竖排文本中横写字符的水平位置。 |
TateChuYokoVertical | Long | The Tate-Chu-Yoko vertical adjustment in points. Tate-Chu-Yoko垂直调整量,以点为单位。 |
TextFont | TextFont | The font used for the character. 用于字符的字体。 |
Titling | Boolean | If true, OpenType titling alternates are used. 如果为真,则使用OpenType标题风格替换字符。 |
Tracking | Long | The tracking or range kerning amount in thousandths of an em. 字间距或范围字距调整量,以千分之一em为单位。 |
Tsume | Double | The percentage of space reduction around a Japanese character. 日文字体周围空间减缩的百分比。 |
Underline | Boolean | If true, characters are underlined. 如果为真,则对字符进行下划线处理。 |
VerticalScale | Double | Character vertical scaling factor. 字符垂直缩放因子。 |
WariChuCharactersAfterBreak | Long | Specifies how the characters in Wari-Chu text (an inset note in Japanese text) are divided into two or more lines. 指定在Wari-Chu文本(日语文本中的插入注解)中换行后分割字符的方式。 |
WariChuCharactersBeforeBreak | Long | Specifies how the characters in Wari-Chu text (an inset note in Japanese text) are divided into two or more lines. 指定在Wari-Chu文本(日语文本中的插入注解)中换行前分割字符的方式。 |
WariChuEnabled | Boolean | If true, Wari-Chu is enabled. 如果为真,则启用Wari-Chu功能。 |
WariChuJustification | AiWariChuJustificationType | The Wari-Chu justification. Wari-Chu的对齐方式。 |
WariChuLineGap | Long | The Wari-Chu line gap. Wari-Chu的行间距。 |
WariChuLines | Long | The number of Wari-Chu (multiple text lines fit into a space meant for one) lines. Wari-Chu(多行文本适应单行空间)行的数量。 |
WariChuScale | Double | The Wari-Chu scale. Wari-Chu的缩放比例。 |
Setting character attributes
'Opens a document and adds a simple text frame, then
'uses the CharacterAttributes object to increment
'the horizontal and vertical scale of each character.
Set appRef = CreateObject("Illustrator.Application")
Set docRef = appRef.Documents.Add()
Set textRef = docRef.TextFrames.Add()
textRef.Contents = "I'd rather be scripting!"
textRef.Top = 500
textRef.Left = 40
dSize = 100
iCount = textRef.Characters.Count
i = 1
Dim charRef
Do While (i < (iCount + 1))
dSize = dSize * 1.1
textRef.TextRange.Characters(i).CharacterAttributes.HorizontalScale = dSize
textRef.TextRange.Characters(i).CharacterAttributes.VerticalScale = dSize
i = i + 1
Loop
page 25
Characters
A collection of TextRange objects in which each represents a single character.
Characters properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. Application that the collection belongs to. 只读属性。表示该集合所属的应用程序对象,即这个集合是哪个应用程序的一部分。 |
Count | Long | Read-only. Number of elements in the collection. 只读属性。表示集合中元素的数量,即集合内包含的项目的总数。 |
Parent | Object | Read-only. The object’s container. 只读属性。表示该集合所在的容器对象,即此集合直接隶属于哪一个父级对象 |
Characters methods
Method | Returns | What it does |
---|---|---|
Add(contents as String[, relativeObject as TextFrame][, insertionLocation as AiElementPlacement]) | TextRange | Adds a new character with specified text contents at the specified location in the current document. If location is not specified,adds the new character to the containing text frame after the current text selection or insertion point. 在当前文档的指定位置添加包含指定文本内容的新字符。如果未指定位置,则在当前文本选择或插入点之后的文本框中添加新字符。 |
AddBefore(contents as String) | TextRange | Adds a character before the current text selection or insertion point. 在当前文本选择或插入点之前添加一个字符。 |
Index(itemPtr as TextRange) | Long | Returns the index position of the object within the collection. 返回给定TextRange对象在集合中的索引位置。 |
RemoveAll() | Nothing | Deletes every element in the collection. 删除集合中的所有元素,即清空整个集合。 |
Counting characters
'Counts the number of characters in the current document
'and stores the result in numChars
Set appRef = CreateObject("Illustrator.Application")
If appRef.Documents.Count > 0 Then
numChars = 0
For Each textArt In appRef.ActiveDocument.TextFrames
Set textArtRange = textArt.TextRange
numChars = numChars + textArtRange.length
Next
End If
page 27
CharacterStyle
A named style that specifies character attributes. For an example, see CharacterStyles.
CharacterStyle properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. Application to which the collection belongs. 只读。该集合所属的应用程序,即此字符样式是在哪个Illustrator应用中定义的。 |
CharacterAttributes | CharacterAttributes | Read-only. The character properties for the style. 只读。表示该字符样式的字符属性集合,包括字体、大小、颜色、行距等各种字符样式相关的详细设定。 |
Name | String | The character style’s name. 字符样式的名称,用于在Illustrator中标识和引用该样式。 |
Parent | Object | Read-only. The object’s container. 只读。包含当前对象的容器对象,通常是指定字符样式所在的文档或样式集。 |
CharacterStyle methods
Method | Returns | What it does |
---|---|---|
ApplyTo(textItem as Object[, clearingOverrides as Boolean]) | Nothing | Applies the character style to the text object or objects. 将此字符样式应用于指定的文本对象或多个文本对象。可选参数clearingOverrides指明是否在应用样式时清除已存在的自定义格式覆盖,默认情况下,如果不设置该参数,则可能会保留原有的一些格式覆盖设置。 |
Delete() | Nothing | Deletes the object. 删除当前的字符样式对象。执行此操作后,文档中使用该字符样式的文本将不再应用该样式,除非有其他样式替代它或者恢复为默认样式。 |
page 28
CharacterStyles
A collection of character styles.
CharacterStyles properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. Application to which the collection belongs. 只读。表示该集合所属的应用程序实例,即这个集合是哪个Adobe Illustrator应用的一部分。 |
Count | Long | Read-only. Number of elements in the collection. 只读。表示集合中元素的数量,即集合内包含的项目的总数。 |
Parent | Object | Read-only. The object’s container. 只读。表示该集合所在的容器对象,即此集合直接隶属于哪一个父级对象。例如,在Illustrator中,如果这个集合是一个文档中的图层集合,那么Parent属性将指向该文档对象。 |
CharacterStyles methods
Method | Returns | What it does |
---|---|---|
Add(Name as String) | CharacterStyle | Creates a named character style. 通过给定的名称创建一个新的字符样式,并返回该新创建的CharacterStyle对象。 |
Index(itemPtr as CharacterStyle) | Long | Returns the index position of the object within the collection. 返回指定CharacterStyle对象在集合中的索引位置,即查找并返回给定CharacterStyle实例在整个集合中所处的位置序号。 |
Item(itemKey) | CharacterStyle | Returns an object reference to the object identified by itemKey (name or index). 根据itemKey(可以是名称或索引)返回CharacterStyle对象引用,即通过名称或索引获取并返回集合中的特定字符样式对象。 |
RemoveAll() | Nothing | Deletes all objects in this collection. 删除当前集合内的所有字符样式对象,清空整个集合。 |
Create and apply character styles
'Opens a document, adds 3 text frames,
'creates a new character style and applies it to
'each of the text frames
Set appRef = CreateObject("Illustrator.Application")
'Create a new document add a 3 simple text items
Set docRef = appRef.Documents.Add()
Set textRef1 = docRef.TextFrames.Add()
textRef1.Contents = "Scripting is fun!"
textRef1.Top = 700
textRef1.Left = 50
Set textRef2 = docRef.TextFrames.Add()
textRef2.Contents = "Scripting is easy!"
textRef2.Top = 625
textRef2.Left = 100
Set textRef3 = docRef.TextFrames.Add()
textRef3.Contents = "Everyone should script!"
textRef3.Top = 550
textRef3.Left = 150
appRef.Redraw
'Create a new character style
Set charStyle = docRef.CharacterStyles.Add("BigRed")
'Create a red color
Set colorRed = CreateObject("Illustrator.RGBColor")
colorRed.Red = 255
'Set character attributes of the new style
With charStyle.CharacterAttributes
.Size = 40
.Tracking = -50
.Capitalization = 0 'aiNormalCaps
.FillColor = colorRed
End With
'Apply style to each textFrame in the document
charStyle.ApplyTo textRef1.TextRange
charStyle.ApplyTo textRef2.TextRange
charStyle.ApplyTo textRef3.TextRange
page 30
CMYKColor
A CMYK color specification, used to apply a CMYK color to a layer or art item.
If the color space of a document is RGB and you specify the color value for a page item in that document using CMYK, Illustrator translates the CMYK color specification into an RGB color specification. The same thing happens if the document’s color space is CMYK and you specify colors using RGB. Since this translation can lose information, you should specify colors using the class that matches the document’s actual color space.
CMYKColor properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。表示该颜色对象所属的Adobe Illustrator应用程序实例,提供了访问和控制整个应用程序的功能。 |
Black | Double | The black color value. Range: 0.0 to 100.0 黑色分量值,范围在0.0到100.0之间,用于CMYK色彩模式中的黑色部分强度设置。 |
Cyan | Double | The cyan color value. Range: 0.0 to 100.0 青色分量值,范围在0.0到100.0之间,用于CMYK色彩模式中的青色部分强度设置。 |
Magenta | Double | The magenta color value. Range: 0.0 to 100.0 洋红色分量值,范围在0.0到100.0之间,用于CMYK色彩模式中的洋红色部分强度设置。 |
Yellow | Double | The yellow color value. Range: 0.0 to 100.0 黄色分量值,范围在0.0到100.0之间,用于CMYK色彩模式中的黄色部分强度设置。 |
Setting CMYK colors
'Creates a new CMYK color and applies it to the first path item
Set appRef = CreateObject("Illustrator.Application")
Set newCMYKColor = CreateObject("Illustrator.CMYKColor")
'Get a reference to the frontmost path in the document
Set frontPath = appRef.ActiveDocument.PathItems(1)
'Set color values for the CMYK objects
newCMYKColor.Black = 0
newCMYKColor.Cyan = 30.4
newCMYKColor.Magenta = 32
newCMYKColor.Yellow = 0
frontPath.Filled = True
frontPath.fillColor = newCMYKColor
page 31
Color info
An abstract parent class for all color classes used in Illustrator. Subclasses are:
GradientColor
GrayColor
LabColor
NoColor
PatternColor
RGBColor
SpotColor
page 32
CompoundPathItem
Compound paths are objects composed of multiple intersecting paths, resulting in transparent interior spaces where the original paths overlapped. The PathItems property provides access to the paths that make up the compound path.
All paths in a compound path share property values. Therefore, if you set the value of a property of any one of the paths in the compound path, all other paths’ matching property will be updated to the new value.
Paths contained within a compound path or group in a document are returned as individual paths when a script asks for the paths contained in the document. However, paths contained in a compound path or
group are not returned when a script asks for the paths in a layer which contains the compound path or group.
CompoundPathItem properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。表示该对象所属的Adobe Illustrator应用程序实例,可用于访问和控制整个应用程序的功能。 |
ArtworkKnockout | AiKnockoutState | Is this object used to create a knockout? If so, what kind of knockout? 指示此对象是否被用作镂空效果,并且如果是的话,是何种类型的镂空效果。 |
BlendingMode | AiBlendModes | The mode used when compositing an object. 在组合对象时所采用的混合模式,决定对象如何与下方图层的内容相互融合。 |
ControlBounds | Variant Array of 4 Doubles | Read-only. The bounds of the object including stroke width and controls. 只读。包括描边宽度和控制点在内的对象边界范围。 |
Editable | Boolean | Read-only. If true, the object is editable. 只读。如果为true,则表示该对象可编辑。 |
GeometricBounds | Variant Array of 4 Doubles | Read-only. The bounds of the object excluding stroke width. 只读。不包括描边宽度的对象边界范围。 |
Height | Double | The height of the object, excluding stroke width, calculated from the GeometricBounds. 对象的高度(排除描边宽度),基于GeometricBounds计算得出。 |
Hidden | Boolean | If true, this object is hidden. 如果为true,则表示该对象已被隐藏。 |
IsIsolated | Boolean | If true, this object is isolated. 如果为true,则表示该对象已被隔离显示。 |
Layer | Layer | Read-only. The layer to which this object belongs. 只读。表示此对象所在的图层。 |
Left | Double | The position of the left side of the item (in points, measured from the left side of the page). 对象左边缘的位置(以点为单位,从页面左边开始测量)。 |
Locked | Boolean | If true, the object is locked. 如果为true,则表示该对象被锁定,不可编辑或移动。 |
Name | String | The name of this object. 对象的名称。 |
Note | String | The note assigned to this object. 分配给此对象的注释文本。 |
Opacity | Double | The opacity of the object. Range: 0.0 to 100.0 对象的不透明度,范围在0.0到100.0之间,其中100代表完全不透明。 |
Parent | Document | Read-only. The document that contains this object. 只读。包含此对象的父级文档。 |
PathItems | PathItems | Read-only. The path art items in this compound path. 只读。复合路径中的所有路径艺术项目元素。 |
Position | Variant Array of 2 Doubles | The position (in points) of the top left corner of the item, in the format [x, y]. Does not include stroke weight. 对象左上角的位置(以点为单位),格式为[x, y],不包括描边宽度。 |
Selected | Boolean | If true, the object is selected. 如果为true,则表示该对象已被选中。 |
Sliced | Boolean | If true, the CompoundPathItem is sliced. Default: false 如果为true,则表示复合路径项被切片处理。默认值为false。 |
Tags | Tags | Read-only. The tags contained in this object. 只读。该对象所包含的标签集合。 |
Top | Double | The position of the top of the item (in points, measured from the bottom of the page). 对象顶部的位置(以点为单位,从页面底部开始测量)。 |
URL | String | The value of the Adobe URL tag assigned to this object. 分配给此对象的Adobe URL标签值。 |
VisibilityVariable | Variable | The VisibilityVariable bound to this object. 与此对象绑定的可见性变量。 |
VisibleBounds | Variant Array of 4 Doubles | Read-only. The visible bounds of the object including stroke width. 只读。包括描边宽度在内的对象可见边界范围。 |
Width | Double | The width of the object, excluding stroke width, calculated from the GeometricBounds. 对象的宽度(排除描边宽度),基于GeometricBounds计算得出。 |
WrapInside | Boolean | If true, the text frame object are wrapped inside this object. 如果为true,则文本框对象将被环绕在这个对象内部。 |
WrapOffset | Double | The offset to use when wrapping text around this object. 当环绕此对象排列文本时使用的偏移量。 |
Wrapped | Boolean | If true, wrap text frame objects around this object (text frame must be above the object). 如果为true,则允许文本框对象围绕此对象进行环绕排版(前提是文本框位于该对象上方)。 |
ZOrderPosition | Long | Read-only. The position of this art item within the stacking order of the group or layer (Parent) that contains the art item. 只读。此艺术项目在其所在的组或图层(父级容器)内堆叠顺序中的位置索引。 |
CompoundPathItem methods
Method | Returns | What it does |
---|---|---|
Copy() | Nothing | Copies the compound path to the clipboard. The associated document must be the frontmost document. 复制复合路径到剪贴板。要求与该对象关联的文档必须是当前最前端的文档。 |
Cut() | Nothing | Cuts the compound path onto the clipboard. The associated document must be the frontmost document. 将复合路径剪切到剪贴板。同样需要关联文档为最前端文档。 |
Delete() | Nothing | Deletes the object. 删除该复合路径对象。 |
Duplicate([relativeObject as Object],[insertionLocation as AiElementPlacement]) | Object | Duplicates the compound path,optionally specifying the location and position for the copy. 复制复合路径,可选地指定副本的位置和插入点。 |
Move(relativeObject as Object,insertionLocation as AiElementPlacement) | Nothing | Moves the object, specifying the new location and position. 移动对象,指定新的位置和排列方式。 |
Resize(scaleX as Double,scaleY as Double,[, changePositions as Boolean][, changeFillPatterns as Boolean][, changeFillGradients as Boolean] [, changeStrokePattern as Boolean] [, changeLineWidths as Double][, scaleAbout as AiTransformation]) | Nothing | Scales the compound path where scaleX is the horizontal scaling factor (as a percentage) and scaleY is the vertical scaling factor; 100.0 = 100% 按指定的比例因子(水平缩放比例scaleX和垂直缩放比例scaleY)缩放复合路径;100.0表示不缩放(即100%)。还可以选择是否同时改变对象的位置、填充图案、填充渐变、描边图案及线条宽度,并可以选择缩放基准点。 |
Rotate(angle as Double,[, changePositions as Boolean][, changeFillPatterns as Boolean][, changeFillGradients as Boolean][, changeStrokePattern as Boolean][, rotateAbout as AiTransformation]) | Nothing | Rotates the art item relative to the current rotation. The object is rotated counter-clockwise if the Angle value is positive, clockwise if the value is negative. 根据给定的角度逆时针或顺时针旋转艺术项目。可以设置是否同时变换对象的位置、填充图案、填充渐变和描边图案,以及选择旋转中心点。 |
Transform(transformationMatrix as Matrix,[, changePositions as Boolean][, changeFillPatterns as Boolean][, changeFillGradients as Boolean][, changeStrokePattern as Boolean][, changeLineWidths as Double][, transformAbout as AiTransformation]) | Nothing | Transforms the compound path by applying the specified transformation matrix. 通过应用指定的转换矩阵来变换复合路径。同样可以控制是否改变对象的位置、填充图案、填充渐变、描边图案和线条宽度,以及选择变换基准点。 |
Translate([deltaX as Double][, deltaY as Double][, transformObjects as Boolean][, transformFillPatterns as Boolean][, transformFillGradients as Boolean][, transformStrokePatterns as Boolean]) | Nothing | Repositions the compound path relative to the current position,where deltaX is the horizontal offset and deltaY is the vertical offset. 根据给定的横向偏移量deltaX和纵向偏移量deltaY重新定位复合路径相对于当前位置的位置。也可以选择是否同时变换对象、填充图案、填充渐变和描边图案。 |
ZOrder(zOrderCmd as AiZOrderMethod) | Nothing | Arranges the compound path’s position in the stacking order of the group or layer (Parent) that contains the object. 调整复合路径在包含此对象的组或图层中的堆叠顺序。 |
Selecting paths in a document
This example demonstrates how to select all of the paths in a document that are not part of a compound path or a group by testing the type of the Parent property with a TypeName function.
'Selects path items in the current document that are not
'compound paths
Set appRef = CreateObject("Illustrator.Application")
counter = 0
If appRef.Documents.Count > 0 Then
If appRef.ActiveDocument.PathItems.Count > 0 Then
For Each pathArt In appRef.ActiveDocument.PathItems
If (Not TypeName(pathArt.Parent) = "CompoundPathItem") Then
pathArt.Selected = True
counter = counter + 1
Else
pathArt.Selected = False
End If
Next
End If
End If
Creating a compound path
This example demonstrates how to create a new compound path containing three PathItems. The
example then modifies the stroke of the paths in the compound path. Note that when you modify the properties of a PathItem inside a compound path you affect all paths contained in the compound path. The example also shows how to access swatches in a document by name.
'Creates a new compound path item, adds 3 new
'path items, then sets the stroke of the compound path
Set appRef = CreateObject("Illustrator.Application")
Set frontDocument = appRef.ActiveDocument
Set activeLayer = frontDocument.activeLayer
Set newCompoundPath = activeLayer.CompoundPathItems.Add
'Create the path items
Set newPath = newCompoundPath.PathItems.Add
newPath.SetEntirePath Array(Array(30, 50), Array(30, 100))
Set newPath = newCompoundPath.PathItems.Add
newPath.SetEntirePath Array(Array(40, 100), Array(100, 100))
Set newPath = newCompoundPath.PathItems.Add
newPath.SetEntirePath Array(Array(100, 110), Array(100, 300))
'Set the stroke of the compound path
newPath.Stroked = True
newPath.StrokeWidth = 3.5
newPath.StrokeColor = frontDocument.Swatches(8).Color
page 37
CompoundPathItems
A collection of compound paths.
CompoundPathItems properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。该集合所属的Adobe Illustrator应用程序对象,可用于访问和控制整个应用程序的功能。 |
Count | Long | Read-only. The number of objects in the collection. 只读。表示集合中包含的对象数量。 |
Parent | Document | Read-only. The document that contains this object. 只读。包含当前对象的父级文档对象,即这个集合所在的上下文是某个Illustrator文档。 |
CompoundPathItem methods
Method | Returns | What it does |
---|---|---|
Add() | CompoundPathItem | Creates a new CompoundPathItem object. 创建并返回一个新的复合路径项目(CompoundPathItem)对象。 |
Index(item as CompoundPathItem) | Long | Returns the index position of the object within the collection. 返回指定的复合路径项目(CompoundPathItem)在集合中的索引位置。 |
Item(itemKey) | CompoundPathItem | Returns an object reference to the object identified by itemKey (name or index). 通过itemKey(可以是名称或索引)返回一个指向集合中特定复合路径项目对象的引用。 |
RemoveAll() | Nothing | Deletes all objects in this collection. 删除当前集合中的所有复合路径项目对象,清空整个集合。 |
Counting compound paths
'Counts the compound path items in the current document and
'stores in numCPaths
Set appRef = CreateObject("Illustrator.Application")
If appRef.Documents.Count > 0 Then
numCPaths = appRef.ActiveDocument.Layers(1).CompoundPathItems.Count
End If
page 38
DataSet
A set of data used for dynamic publishing. A dataset allows you to collect a number of variables and their dynamic data into one object. To create a DataSet object, you must have at least one variable bound to an art item.
For more information, see the Variable class and the section on “Dynamic Objects and Symbols” in Adobe Illustrator 2024 Scripting Guide.
For a sample script that uses a DataSet object, see DataSets.
DataSet properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。表示该数据集所属的Adobe Illustrator应用程序对象,可以用来访问和控制整个应用程序的功能。 |
Name | String | The name of the DataSet. 数据集的名称,用于标识和区分不同的数据集。 |
Parent | Document | Read-only. The name of the object that is this DataSet object’s parent. 只读。表示此数据集对象的父级对象名称,即包含此数据集的Illustrator文档对象。 |
DataSet methods
Method | Returns | What it does |
---|---|---|
Delete() | Nothing | Deletes the object. 删除该数据集对象。 |
Display() | Nothing | Displays the DataSet. 显示或激活此数据集,使其在Illustrator中可见并可供编辑。 |
Update() | Nothing | Updates the DataSet. 更新数据集的内容,通常用于与外部数据源同步,确保数据显示为最新的状态。 |
page 39
DataSets
A collection of DataSet objects.
DataSets properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。表示该数据集所属的Adobe Illustrator应用程序对象,通过它可以访问整个Illustrator应用的功能和属性。 |
Count | Long | Read-only. The number of datasets in the collection. 只读。表示集合中数据集的数量,即当前文档或上下文中包含的数据集总数。 |
Parent | Document | Read-only. The name of the object that is this DataSet object’s parent. 只读。表示此数据集对象的父级对象名称,即包含这个数据集的文档对象。 |
DataSets methods
Method | Returns | What it does |
---|---|---|
Add() | DataSet | Creates a new DataSet object. 创建并添加一个新的数据集(DataSet)对象到集合中。 |
Index(item as DataSets) | Long | Returns the index position of the object within the collection. 返回指定数据集(DataSets)在当前集合中的索引位置。 |
Item(itemKey) | DataSet | Returns an object reference to the object identified by itemKey (name or index). 通过itemKey(可以是名称或索引)返回集合中特定数据集(DataSet)对象的引用。 |
RemoveAll() | Nothing | Deletes all objects in this collection. 从集合中删除所有数据集对象,清空整个集合。 |
Creating datasets
'Creates two variables (visibility and text),
'creates two datasets using different variable
'values then displays each dataset
Set appRef = CreateObject("Illustrator.Application")
Set docRef = appRef.Documents.Add()
'Create a visibility variable
Set itemRef = docRef.PathItems.Rectangle(600, 200, 150, 150)
Set colorRef = CreateObject("Illustrator.RGBColor")
colorRef.Red = 255
itemRef.FillColor = colorRef
Set visibilityVar = docRef.Variables.Add()
visibilityVar.Kind = 2 'aiVisibility
itemRef.VisibilityVariable = visibilityVar
'Create a text variable
Set textRef = docRef.TextFrames.Add
textRef.Contents = "Text Variable, dataset 1"
textRef.Top = 400
textRef.Left = 200
Set textVar = docRef.Variables.Add
textVar.Kind = 3 'aiTextual
textRef.ContentVariable = textVar
'Create dataset 1
Set ds1 = docRef.DataSets.Add()
'Change data and create dataset 2
itemRef.Hidden = True
textRef.Contents = "Text Variable, dataset 2"
Set ds2 = docRef.DataSets.Add()
'Display datasets
ds1.Display
ds2.Display
page 41
Document
An Illustrator document. Documents are contained in the Application object.
一份Illustrator文档。文档包含在Application对象中。
The default document settings—those properties starting with the word “Default”—are global settings that affect the current document. Be sure to modify these default properties only when a document is open. Note that if you set default properties to desired values before creating new objects, you can streamline your scripts, eliminating the need to specify properties such as FillColor and Stroked that have analogous default properties.
默认文档设置(那些以“Default”开头的属性)是全局设置,它们会影响当前打开的文档。请确保仅在文档打开状态下修改这些默认属性。请注意,如果在创建新对象之前将默认属性设置为所需值,您可以简化脚本编写,从而无需指定诸如FillColor和Stroked等具有相应默认属性的属性,从而提高脚本效率。
A document’s DocumentColorSpace, Height, and Width can be set only when the document is created. Once a document is created, these properties cannot be changed.
文档的DocumentColorSpace、Height和Width属性只能在创建文档时设置。一旦文档创建完成,这些属性就无法更改。
The frontmost document can be referred to as either AppRef.ActiveDocument or AppRef.Documents(1).
最前面的文档可以使用AppRef.ActiveDocument或AppRef.Documents(1)来引用。
Document properties
Property | Value type | What it is |
---|---|---|
ActiveDataSet | DataSet | The active DataSet object in the document. 文档中的当前活动数据集对象。 |
ActiveLayer | Layer | The active Layer in the document. 文档中的当前活动图层。 |
ActiveView | View | Read-only. The document’s current View. 只读。文档当前的视图状态。 |
Application | Application | Read-only. The Illustrator Application object. 只读。Illustrator 应用程序对象,表示与该文档相关的主应用程序。 |
Artboards | Artboards | Read-only. All artboards in the document. 只读。文档中所有画板的集合。 |
Brushes | Brushes | Read-only. The Brushes contained in the document. 只读。文档中包含的所有画笔(刷子)对象的集合。 |
CharacterStyles | CharacterStyles | Read-only. The list of character styles in this document. 只读。文档中所有字符样式的列表。 |
CompoundPathItems | CompoundPathItems | Read-only. The CompoundPathItems contained in the document. 只读。文档中包含的所有复合路径项目的集合。 |
CropBox | Variant Array of 4 Doubles | The boundary of the document’s cropping box for output.A document does not have a default CropBox. In order to read this property you have to set the CropBox first. 文档输出时裁剪框的边界坐标数组。文档默认没有裁剪框,要读取此属性需先设置 CropBox。 |
CropStyle | AiCropOptions | The style of the document’s cropping box. 文档裁剪框的样式。 |
DataSets | DataSet | Read-only. A DataSets collection in the document. 只读。文档中数据集集合。 |
DefaultFillColor | Color info | The Color to fill new paths if default filled is true. 如果默认填充为 true,则用于填充新路径的颜色信息。 |
DefaultFilled | Boolean | If true, a new path are filled. 如果为 true,则新创建的路径默认会被填充颜色。 |
DefaultFillOverprint | Boolean | If true, the art beneath a filled object are overprinted by default. 如果为 true,则默认情况下填充的对象会覆盖其下方的艺术内容。 |
DefaultStrokeCap | AiStrokeCap | Default type of line capping for paths created. 新创建路径的默认线端样式。 |
DefaultStrokeColor | Color info | The stroke color for new paths if default stroked is true. 如果默认描边为 true,则用于描边新路径的颜色信息。 |
DefaultStroked | Boolean | If true, the new path are stroked. 如果为 true,则新创建的路径默认会被描边。 |
DefaultStrokeDashes | Variant Array of Doubles | The default lengths for dashes and gaps in dashed lines, starting with the first dash length, followed by the first gap length,and so on. 默认虚线和间隙长度的数组,按顺序列出第一个虚线段长度、第一个间隙长度,以此类推。 |
DefaultStrokeDashOffset | Double | The default distance into the dash pattern at which the pattern are started for new paths. 对于新路径,开始应用虚线模式时相对于起点的偏移量。 |
DefaultStrokeJoin | AiStrokeJoin | Default type of joints in new paths. 新创建路径的默认线接合样式。 |
DefaultStrokeMiterLimit | Double | When a default stroke join is set to mitered, this property specifies when the join will be converted to beveled (squared-off) by default. The default miter limit of 4 means that when the length of the point reaches four times the stroke weight, the join switches from a miter join to a bevel join. Range: 1 to 500; a value of 1 specifies a bevel join. 当默认的线接合样式设置为尖角时,此属性指定何时将接合转换为斜角(倒角)样式。默认的斜接限制为4表示当尖角长度达到描边宽度的四倍时,接合方式从尖角变为斜角。范围:1至500;值为1表示使用斜角接合。 |
DefaultStrokeOverprint | Boolean | If true, the art items beneath a stroked object are overprinted by default. 如果为 true,则默认情况下描边对象下的艺术内容会被覆盖打印。 |
DefaultStrokeWidth | Double | The default width of stroke for new paths. 新路径的默认描边宽度。 |
DocumentColorSpace | AiDocumentColorSpace | Read-only. The color specification system to use for this document’s color space. 只读。文档颜色空间使用的颜色规范系统。 |
FullName | String | Read-only. The file associated with the document, which includes the complete path to the file. 只读。与文档关联的文件名及其完整路径。 |
GeometricBounds | Variant Array of 4 Doubles | Read-only. The bounds of the illustration excluding the stroke width of any objects in the document. 只读。排除文档中任何对象描边宽度后,插图的边界框坐标数组。 |
Gradients | Gradients | Read-only. The Gradients collection contained in the document. 只读。文档中包含的所有渐变集合。 |
GraphicStyles | GraphicStyles | Read-only. The GraphicStyles contained in the document. 只读。文档中包含的所有图形样式集合。 |
GraphItems | GraphItems | Read-only. The GraphItems collection contained in the document. 只读。文档中包含的所有图表项目集合。 |
GroupItems | GroupItems | Read-only. The GroupItems collection contained in the document. 只读。文档中包含的所有群组项目的集合。 |
Height | Double | Read-only. The height of the document, calculated from the GeometricBounds. 只读。根据几何边界计算出的文档高度。 |
InkList | Variant Array | Read-only. The list of inks in this document. 只读。文档中的油墨列表。 |
KinsokuSet | Object | Read-only. The Kinsoku set of characters that cannot begin or end a line of Japanese text. 只读。日语文本中不能开始或结束一行的禁则字符集。 |
Layers | Layers | Read-only. The layers contained in the document. 只读。文档中包含的所有图层集合。 |
LegacyTextItems | LegacyTextItems | Read-only. The legacy text items in the document. 只读。文档中存在的旧版文本项集合。 |
MeshItems | MeshItems | Read-only. The mesh art items contained in the document. 只读。文档中包含的所有网格艺术项目集合。 |
MojikumiSet | Object | Read-only. A list of predefined Mojikumi sets that specify the spacing for the layout and composition of Japanese text. 只读。预定义的用于指定日语文本布局和排版间距的 Mojikumi 集合列表。 |
Name | String | Read-only. The document’s name (not the complete file path to the document). 只读。文档的名称(不包括文档的完整文件路径)。 |
NonNativeItems | NonNativeItems | Read-only. The non-native art items in this document. 只读。文档中非原生艺术项的集合。 |
OutputResolution | Double | Read-only. The current output resolution for the document in dots per inch (dpi). 只读。文档当前的输出分辨率,单位为每英寸点数(dpi)。 |
PageItems | PageItems | Read-only. The PageItems (contains all art item classes) contained in the document. 只读。文档中包含的所有页面项目(包含了所有艺术项目类别)的集合。 |
PageOrigin | Variant Array of 2 Doubles | The zero-point of the page in the document without margins, relative to the overall height and width. 只读。文档中页面零点(无页边距)相对于整体高度和宽度的位置数组。 |
ParagraphStyles | ParagraphStyles | Read-only. The list of paragraph styles in this document. 只读。文档中所有段落样式的列表。 |
Parent | Application | Read-only. The application that contains this document. 只读。包含该文档的应用程序对象。 |
Path | String | Read-only. The file associated with the document, which includes the complete path to the file. 只读。与文档关联的文件及其完整路径。 |
PathItems | PathItems | Read-only. The PathItems contained in this document. 只读。此文档中包含的所有路径项目集合。 |
Patterns | Patterns | Read-only. The patterns contained in this document. 只读。此文档中包含的所有图案集合。 |
PlacedItems | PlacedItems | Read-only. The PlacedItems contained in this document. 只读。此文档中包含的所有置入项目集合。 |
PluginItems | PluginItems | Read-only. The PluginItems contained in this document. 只读。此文档中包含的所有插件项集合。 |
PrintTiles | Boolean | Read-only. If true, this document is tiled when printed. 只读。如果为 true,则表示此文档在打印时会被分块(平铺)。 |
RasterEffectSettings | RadialRepeatConfig | The document’s raster effect settings. 文档的栅格效果设置。 |
RasterItems | RasterItems | Read-only. The raster items contained in this document. 只读。此文档中包含的所有栅格项目集合。 |
RulerOrigin | Variant Array of 2 Doubles | The zero-point of the rulers in the document relative to the bottom left corner. 相对于左下角,文档中标尺的零点坐标数组。 |
RulerUnits | AiRulerUnits | Read-only. The default measurement units for the rulers in the document. 只读。文档中标尺使用的默认度量单位。 |
Saved | Boolean | If true, the document has not been changed since the last time it was saved. 如果为 true,则表示自上次保存以来,文档未发生任何更改。 |
Selection | Variant Array of objects | The array of references to the objects in this document’s current selection. 当前文档中所选对象引用的数组。 |
ShowPlacedImages | Boolean | Read-only. If true, placed images are displayed in the document. 只读。如果为 true,则表示在文档中显示置入的图像。 |
SplitLongPaths | Boolean | Read-only. If true, long paths are split when printing. 只读。如果为 true,则表示在打印时长路径会被分割。 |
Spots | Spots | Read-only. The SpotColors contained in this document. 只读。此文档中包含的所有专色集合。 |
Stationery | Boolean | Read-only. If true, the file is a stationery file. 只读。如果为 true,则表示该文件是一个信纸文件。 |
Stories | Stories | Read-only. The story items in this document. 只读。此文档中的故事项目集合。 |
Swatches | Swatches | Read-only. The swatches in this document. 只读。此文档中的调色板集合。 |
SwatchGroups | SwatchGroups | Read-only. The swatch groups in this document. 只读。此文档中的调色板组集合。 |
SymbolItems | SymbolItems | Read-only. The symbol items in this document. 只读。此文档中的符号项目集合。 |
Symbols | Symbols | Read-only. The symbols in this document. 只读。此文档中的符号集合。 |
Tags | Tags | Read-only. The tags in this document. 只读。此文档中的标签集合。 |
TextFrames | TextFrames | Read-only. The text frames in this document. 只读。此文档中的文本框架集合。 |
TileFullPages | Boolean | Read-only. If true, full pages are tiled when printing this document. 只读。如果为 true,则表示在打印此文档时会平铺整个页面。 |
UseDefaultScreen | Boolean | Read-only. If true, the printer’s default screen is used when printing this document. 只读。如果为 true,则表示在打印此文档时将使用打印机的默认网点大小。 |
Variables | Variables | Read-only. The variables in this document. 只读。此文档中的变量集合。 |
VariablesLocked | Boolean | If true, the Variables in this document are locked. 如果为 true,则表示此文档中的变量被锁定,不可编辑或修改。 |
Views | Views | Read-only. The views in this document. 只读。此文档中的视图集合。 |
VisibleBounds | Variant Array of 4 Doubles | Read-only. The visible bounds of the document, including stroke width of any objects in the illustration. 只读。包括插图中所有对象描边宽度在内的可见边界坐标数组。 |
Width | Double | Read-only. The width of this document, calculated from the GeometricBounds. 只读。根据几何边界计算出的文档宽度。 |
XMPString | String | The XMP metadata packet associated with this document. 与此文档关联的XMP(可扩展元数据平台)元数据包字符串内容。 |
Document methods
Method | Returns | What it does |
---|---|---|
Arrange([layoutStyle as AiDocumentLayoutStyle]) | Nothing | Arranges multiple documents in the given layout style. 按照给定的布局样式排列多个文档。 |
Activate() | Nothing | Brings the first window associated with the document to the front. 将与该文档关联的第一个窗口激活并置于最前端。 |
Close([Saving as AiSaveOptions]) | Nothing | Closes the document. 关闭文档,可选择是否保存更改。 |
Capture(ImageFile as File,windowSize as Point) | Nothing | Captures the current document window to the target TIFF image file. 抓取当前文档窗口内容并保存为指定的目标TIFF图像文件中。 |
ConvertCoordinate(Coordinate as Point,Source as AiCoordinateSystem,Destination as AiCoordinateSystem) | Nothing | Converts the coordinate system used for a single point between artboard and document coordinate systems. 在画板坐标系统和文档坐标系统之间转换单个点的坐标系统。 |
Copy() | Nothing | Copies the current selection in the document to the clipboard; the associated document must be the frontmost document. 复制当前文档中的选定内容到剪贴板,要求该文档是当前最前面的文档。 |
Cut() | Nothing | Cuts the current selection in the document to the clipboard; the associated document must be the frontmost document. 剪切当前文档中的选定内容到剪贴板,要求该文档是当前最前面的文档。 |
Export(ExportFile as String,ExportFormat as AiExportType,[Options as Object]) | Nothing | Exports the document to the specified file using one of the export file formats. Options for various formats are collected in ExportOptionsFormat objects. The appropriate file extension is automatically appended to the file name, except for Photoshop® documents. For these, you must include the file extension ( .psd) in the file specification. 使用指定的导出格式将文档导出到指定的文件。针对不同格式的选项被收集在ExportOptionsFormat对象中。对于除Photoshop®文档以外的所有格式,会自动添加相应的文件扩展名。对于Photoshop文档,需要在文件规范中包含文件扩展名(.psd)。 |
ExportPDFPreset(File as String) | Nothing | Exports the current PDF preset values to the file. 将当前PDF预设值导出到指定文件。 |
ExportPerspectiveGridPreset(File as String) | Nothing | Exports the current perspective grid preset values to the file. 将当前透视网格预设值导出到指定文件。 |
ExportPrintPreset(File as String) | Nothing | Exports the current print preset values to the file. 将当前打印预设值导出到指定文件。 |
ExportVariables(Filename as String) | Nothing | Exports the current variables from this document to the file. 将当前文档中的变量导出到指定文件。 |
FitArtboardToSelectedArt([Index as Long]) | boolean | Resizes the artboard at the given index to fit currently selected art. Index default is 0. Returns true on success. 根据当前选中的艺术元素调整指定索引处画板大小以适应其内容。默认索引为0。成功时返回true。 |
GetPerspectiveActivePlane() | AiPerspectiveGridPlaneType | Retrieves the active plane of the active perspective grid of the document. 获取文档中活动透视网格的活动平面。 |
GetScreenMode () | NormalScreenMode FullScreenWithMenuMode FullScreenNoMenuMode PresentationMode | The mode of display for this view. 获取当前视图的显示模式。 |
GetViewMode () | OverprintPreview PixelPreview DefaultPreview | The view mode for this view. 获取当前视图的查看模式。 |
HidePerspectiveGrid() | boolean | Hides the current active grid for the document. If no grid is visible, does nothing. Returns true if a grid is hidden. 隐藏当前文档的活动透视网格。如果透视网格未显示,则不执行操作,并在成功隐藏时返回true。 |
ImageCapture(ImageFile as File,[ClipBounds as Rect],[Options as ImageCaptureOptions]) | Nothing | Captures the artwork content within the clipping boundaries in this document as a raster image, and writes the image data to a specified file. If the bounds parameter is omitted, captures the entire artwork. 将此文档内指定裁剪边界的矢量艺术内容捕捉为光栅图像,并将图像数据写入到指定文件中。若省略bounds参数,则捕获整个艺术品内容。 |
ImportCharacterStyles(FileSpec as String) | Nothing | Loads the character styles from the Illustrator file. 从Illustrator文件加载字符样式。 |
ImportParagraphStyles(FileSpec as String) | Nothing | Loads the paragraph styles from the Illustrator file. 从Illustrator文件加载段落样式。 |
ImportPDFPreset(FileSpec as String[, ReplacingPreset as Boolean]) | Nothing | Loads all PDF presets from a file. 从文件中加载所有PDF预设,可选是否替换现有预设。 |
ImportPerspectiveGridPreset(FileSpec as String[, PerspectivePreset as String]) | Nothing | Loads a named perspective-grid preset from a file, or, if no name is given, all presets in the file. 从文件中加载命名的透视网格预设,若未提供名称,则加载文件中的所有预设。 |
ImportPrintPreset(PrintPreset as String FileSpec as String) | Nothing | Loads the named print preset from the file. 从文件中加载指定名称的打印预设。 |
ImportVariables(Filename as String) | Nothing | Imports Variables from the specified file into this document. 从指定文件导入变量到当前文档。 |
IsRulerVisible () | boolean | If true, the ruler is visible. 如果为true,则表示标尺可见。 |
IsTransparencyGridVisible () | boolean | If true, the transparency grid is visible. 如果为true,则表示透明网格可见。 |
Paste() | Nothing | Pastes the contents of the clipboard into the current layer of the document; if the document is the frontmost then all pasted objects remain selected after the paste. 将剪贴板的内容粘贴到当前文档的当前图层中;如果文档是最前面的,则粘贴后的所有对象保持选中状态。 |
PrintOut(Options as PrintOptions) | Nothing | Prints the document. 打印文档。 |
Rasterize(SourceArt as Variant,[, ClipBounds as Rect,][,Options as RasterizeOptions]) | PageItem | Rasterizes the source art(s) within the specified clip bounds. The source art(s) is disposed of as a result of the rasterization. 根据指定的裁剪边界对源艺术元素进行栅格化处理。栅格化后,源艺术元素会被丢弃并以PageItem形式返回结果。 |
RearrangeArtboards([ArtboardLayout as AiDocumentArtboardLayout, ArtboardRowsOrCols as Long,ArtboardSpacing as Long,ArtboardMoveArtwork as Boolean]) | boolean | Rearranges artboards in the document. All arguments are optional. Default layout style is aiGridByRow.The second argument specifies the number of rows or columns, as appropriate for the chosen layout style, in the range[1…DocNumArtboards-1], or 1(the default) for single row/column layouts.Spacing is a number of pixels, default 20.When last argument is true (the default), artwork is moved with the artboards. 重新排列文档中的画板。所有参数都是可选的,默认布局样式为aiGridByRow。第二个参数指定了根据所选布局样式所需的行数或列数,在[1…DocNumArtboards-1]范围内,对于单行/单列布局默认为1。间距是以像素为单位的数值,默认为20。最后一个参数为true(默认值)时,随画板移动其中的艺术作品。 |
Save() | Nothing | Saves the document in its current location. 保存当前文档至其当前位置。 |
SaveAs([SaveIn as String][, Options as:EPSSaveOptions/IllustratorSaveOptions/PDFSaveOptions]) | Nothing | Saves the document in the specified file as an Illustrator, EPS, or PDF file. 将文档以Illustrator、EPS或PDF格式保存到指定的文件中。 |
SelectObjectsOnActiveArtboard() | boolean | Selects the objects on the currently active artboard. Returns true on success. 选择当前活动画板上的对象。成功时返回true。 |
SelectPerspectivePreset(PresetPreset as String) | boolean | Selects a predefined preset to define grid for the current document. Returns true on success. 选择预定义的透视网格预设,用于为当前文档定义透视网格。成功时返回true。 |
SetPerspectiveActivePlane(PerspectiveGridPlane as AiPerspectiveGridPlaneType) | boolean | Sets the active plane of the active perspective grid of the document. Returns true on success. 设置文档当前活动透视网格的活动平面。成功时返回true。 |
ShowPerspectiveGrid() | boolean | Shows the current active grid for the document, or if no grid is active, shows the default grid. Returns true on success. 显示当前文档的活动透视网格;如果尚未激活任何透视网格,则显示默认透视网格。成功时返回true。 |
WindowCapture(ImageFile as String,WindowSize as Point) | Nothing | Captures the current document to the target TIFF image file. 将当前文档窗口内容捕获并保存为目标TIFF图像文件。 |
WriteAsLibrary(File,libraryType) | File AiLibraryType | Writes the document to a file as a library of specified type. 将文档写入一个文件,作为指定类型的库文件。 |
Closing documents
If you close the document, you should set your document reference to Nothing to prevent your script accidentally trying to access closed documents.
'Closes the frontmost document without saving
Set appRef = CreateObject("Illustrator.Application")
Set docRef = appRef.Documents(1)
docRef.Close 2' aiDoNotSaveChanges
Set docRef = Nothing
Creating a document with defaults
'Sets the default stroke and fill in the current document to false
Set appRef = CreateObject("Illustrator.Application")
If (appRef.Documents.Count = 0) Then
Set frontDocument = appRef.Documents.Add
Else
Set frontDocument = appRef.Documents(1)
End If
frontDocument.DefaultFilled = False
frontDocument.DefaultStroked = False
page 50
Documents
A collection of documents.
Documents properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。Illustrator应用程序对象。这提供了对整个Illustrator应用程序的访问权限,可用于执行全局操作或查询应用程序级别的属性。 |
Count | Long | Read-only. The number of objects in the collection. 只读。集合中对象的数量。表示当前集合中包含的元素或对象的总数。 |
Parent | Object | Read-only. The parent of this object. 只读。该对象的父级对象。这是指当前对象所在的上级对象,比如一个集合可能是另一个对象的成员,那么这个“Parent”属性就指向那个上级对象。在Illustrator中,这可能是指定对象属于的图层、文档、画板或者其他容器类对象。 |
Documents methods
Method | Returns | What it does |
---|---|---|
Add([documentColorSpace As AiDocumentColorSpace][, width as Double][, height as Double][, numArtBoards as Long][, artboardLayout as AiDocumentArtboardLayout] [, artboardSpacing as Double][, artboardRowsOrCols as Long]) | Document | Creates a new document using optional parameters and returns a reference to the new document. 通过可选参数创建一个新的文档,如颜色空间、宽度、高度、画板数量、画板布局、画板间距和画板行数或列数,并返回对新创建文档的引用。 |
AddDocument(startupPreset as String[, presetSettings as DocumentPreset][, showOptionsDialog as Boolean) | Document | Creates a document from the preset, replacing any provided setting values, and returns a reference to the new document. 使用预设设置创建一个文档,可以替换提供的任何预设值,并显示选项对话框(如果需要),然后返回对新创建文档的引用。 |
Index(item as Document) | Long | Returns the index position of the object within the collection. 返回集合中指定文档对象在其所在位置的索引号。 |
Item(itemKey) | Document | Returns an object reference to the object identified by itemKey (name or index). 根据itemKey(名称或索引号)返回对集合中特定文档对象的引用。 |
Creating a document with a color space
python
'Creates a new RGB document
Set appRef = CreateObject("Illustrator.Application")
appRef.Documents.Add 1 'aiDocumentRGBColor
DocumentPreset
A preset document template to use when creating a new document with AddDocument.
DocumentPreset properties
Property | Value type | What it is |
---|---|---|
ArtboardLayout | AiDocumentArtboardLayout | The layout of artboards in the new document. Default: AiGridByRow 新建文档中画板的布局方式。默认值:AiGridByRow(按行排列) |
ArtboardRowsOrCols | Long | The number of rows (for rows layout) or columns (for column layout) of artboards. Range: 1 to (NumArtboards - 1) or 1 for single row or column layouts. Default: 1 新建文档中画板的行数(对于行布局)或列数(对于列布局)。范围:1 到 (NumArtboards - 1)或在单行或单列布局时为1。默认值:1 |
ArtboardSpacing | Double | The spacing between artboards in the new document. Default: 20.0 新建文档中画板之间的间距。默认值:20.0(单位通常为点) |
Application | Application | Read-only. The Illustrator Application object. 只读。Illustrator应用程序对象。 |
DocumentColorSpace | AiDocumentColorSpace | The color space for the new document. 新建文档的颜色空间设置。 |
DocumentPreviewMode | AiDocumentPreviewMode | The preview mode for the new document. 新建文档的预览模式设置。 |
DocumentRasterResolution | AiDocumentRasterResolution | The raster resolution for the new document. 新建文档的栅格分辨率设置。 |
DocumentTitle | String | The document title. 文档的标题。 |
DocumentTransparencyGrid | AiDocumentTransparencyGrid | The transparency grid color for the new document. 新建文档的透明网格颜色设置。 |
DocumentUnits | AiRulerUnits | The ruler units for the new document. 新建文档的标尺单位设置。 |
Height | Double | The height in points. Default is 792.0 文档的高度,单位为点。默认值:792.0(即11英寸) |
NumArtboards | Long | The number of artboards for the new document. Range: 1 to 100. Default: 1 新建文档中的画板数量。范围:1到100。默认值:1 |
Width | Double | The width in points. Default is 612.0 文档的宽度,单位为点。默认值:612.0(即8.5英寸) |
EPSSaveOptions
Options that may be supplied when saving a document as an Illustrator EPS file. EPSSaveOptions can be supplied only in conjunction with the document SaveAs method. All properties are optional.
EPSSaveOptions properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。表示Illustrator应用程序对象本身。 |
ArtboardRange | string | If SaveMultipleArtboards is true, this is considered for multi-asset extraction, which specifies the artboard range. An empty string extracts all the artboards.Default: empty string 如果SaveMultipleArtboards为真,则在提取多资产时考虑此设置,用于指定要提取的艺术板范围。空字符串表示提取所有艺术板。默认值:空字符串 |
CMYKPostScript | Boolean | If true, CMYK PostScript® is used. 如果为真,则使用CMYK PostScript®格式。 |
Compatibility | AiCompatibility | Illustrator version compatibility for the EPS file format.Default: 24 EPS文件格式的Illustrator版本兼容性。默认值:24(即Illustrator 24版兼容) |
CompatibleGradientPrinting | Boolean | If true, a raster item of the gradient or gradient mesh are created so the object can be printed on PostScript level 2 printers. Default: false 如果为真,在PostScript Level 2打印机上打印渐变或渐变网格时,会创建一个栅格项以确保对象可以被打印。默认值:false |
EmbedAllFonts | Boolean | If true, fonts are included in the EPS file. 如果为真,则将字体嵌入到EPS文件中。 |
EmbedLinkedFiles | Boolean | If true, linked image files are included in the saved document. 如果为真,则将链接的图像文件包含在保存的文档中。 |
FlattenOuput | AiOutputFlattening | How should transparency be flattened for file formats older than Illustrator 9 or greater. 指定对于早于Illustrator 9版本或更高版本的文件格式如何处理透明度压平。 |
IncludeDocumentThumbnails | Boolean | If true, the thumbnail image of the EPS artwork is included. 如果为真,则包含EPS作品的缩略图。 |
Overprint | AiPDFOverprint | The style of overprinting. Default: 1 覆印样式。默认值:1 |
PostScript | AiEPSPostScriptLevel Enum Specifies the PostScript level to use when saving the file. 指定保存文件时使用的PostScript级别。 | |
Preview | AiEPSPreview | Format for the EPS preview image. EPS预览图像的格式。 |
SaveMultipleArtboards | boolean | If true, all artboards or range of artboards are saved. Default: false 如果为真,则保存所有艺术板或指定范围内的艺术板。默认值:false |
Saving to EPS
#Saves the current document to dest in EPS format
#dest contains the full path and file name to save to
Sub exportFileAsEPS (dest)
Set appRef = CreateObject("Illustrator.Application")
Set newSaveOptions = CreateObject("Illustrator.EPSSaveOptions")
If appRef.Documents.Count > 0 Then
newSaveOptions.CMYKPostScript = True
newSaveOptions.EmbedAllFonts = True
Set frontDocument = appRef.ActiveDocument
frontDocument.SaveAs dest, newSaveOptions
End If
End Sub
page 54
ExportForScreens
Options that may be supplied when exporting a document/asset(s)/artboard(s).
ExportForScreensType
Property | Value type | What it is |
---|---|---|
toFolder | File path | The folder where the exported documents/assets/artboards are saved. 导出的文档/资产/艺术板保存的目标文件夹。 |
se_jpeg100/se_jpeg2 0/se_jpeg50/se_jpeg8 0/se_pdf/se_png24/s e_png8/se_svg | File type | The file type in which the document is exported. For example, ExportForScreensType.se_jpeg100. 指定要导出的文档的文件类型。例如:ExportForScreensType.se_jpeg100表示以JPEG格式且质量为100%导出。 |
withOptions | Any | Options for the file type specified. For further information,please refer to ExportOptionsJPEG, ExportOptionsPNG24, ExportOptionsPNG8, ExportOptionsSVG 指定文件类型的相关导出选项。具体信息请参考ExportOptionsJPEG、ExportOptionsPNG24、ExportOptionsPNG8和ExportOptionsSVG等类中提供的选项。 |
itemtoexport | Item to export | An item that needs to be exported. For example, a document, artboard, or asset. 需要导出的项目,可以是文档、艺术板或某个资产。 |
filenameprefix | String | String prepended to each file name. 添加到每个导出文件名前缀的字符串。 |
ExportForScaleType
Property | Value type | What it is |
---|---|---|
Factor | Long | Scale artwork by factors like 1x, 2x, 3x and so on, where 1x means 72 ppi. 通过倍数(如1x、2x、3x等)来缩放艺术作品,其中1x表示72 ppi。 |
Height | Long | Scale artwork by specifying artwork height in pixels like 100px, 124px etc. Width of the artwork is adjusted automatically to maintain the aspect ratio. 通过指定像素高度(如100px、124px等)来缩放艺术作品,宽度会自动调整以保持宽高比。 |
Resolution | Long | Scale artwork by specifying resolution in ppi like 72 ppi, 100 ppi, 144 ppi etc 通过指定分辨率(如72 ppi、100 ppi、144 ppi等)来缩放艺术作品。 |
Width | Long | Scale artwork by specifying artwork width in pixels like 100px, 124px etc. Height of the artwork is adjusted automatically to maintain the aspect ratio. 通过指定像素宽度(如100px、124px等)来缩放艺术作品,高度会自动调整以保持宽高比。 |
page 55
ExportOptionsAutoCAD
Options for exporting a document as an AutoCAD file, used with the Document Export method. All properties are optional.
When you export a document, the default file extension (DWG) is appended automatically. You should not include a file extension in the file specification. To override the default AutoCAD export format, use the ExportFileFormat property.
ExportOptionsAutoCAD properties
Property | Value type | What it is |
---|---|---|
AlterPathsForAppearance | Boolean | If true, paths are altered (if needed) to maintain appearance.Default: false 如果为真,则在必要时调整路径以保持外观。默认:false |
Application | Application | Read-only. The Illustrator Application object. 只读属性。Illustrator应用程序对象,提供对Illustrator应用本身的操作访问权限。 |
Colors | AiAutoCADColors | The number of colors to export into the AutoCAD file. 导出到AutoCAD文件中的颜色数量设置。 |
ConvertTextToOutlines | Boolean | If true, text is converted to outlines. Default: false 如果为真,则将文本转换为轮廓。默认:false |
ExportFileFormat | AiAutoCADExportFileFormat | The file format to which to export. Default: 1 指定要导出的文件格式。默认:1(代表某个特定的AutoCAD格式) |
ExportOption | AiAutoCADExportOption | Whether to preserve appearance or editability during export. Default: 1 控制在导出过程中是否保留图形外观或可编辑性。默认:1(表示某种预设选项) |
ExportSelectedArtOnly | Boolean | If true, only selected artwork is exported. Default: false 如果为真,则仅导出选定的艺术品。默认:false |
RasterFormat | AiAutoCADRasterFormat | The format in which to export raster art. 指定导出栅格图像的格式。 |
ScaleLineweights | Boolean | If true, line weights are scaled by the same scaling factor as the rest of the drawing. Default: false 如果为真,则按照与图纸其余部分相同的缩放因子来缩放线宽。默认:false |
Unit | AiAutoCADUnit | Measurement units from which to map. 测量单位,用于确定从何种单位映射至AutoCAD中。 |
UnitScaleRatio | Double | The ratio by which to scale output. 输出的比例系数,即缩放输出的比例大小。 |
Version | AiAutoCADCompatibility | The release of AutoCAD to export to. Default: 5 ’aiAutoCADRelease24 指定要导出到的AutoCAD版本。默认:5 ‘aiAutoCADRelease24’(表示兼容AutoCAD Release 24或类似版本) |
page 56
ExportOptionsGIF
Options that may be supplied when exporting a document as a GIF file. See the Document Export method for additional details.
When you export a document, the appropriate file extension is appended automatically. You should not include a file extension in the file specification.
ExportOptionsGIF properties
Property | Value type | What it is |
---|---|---|
AntiAliasing | Boolean | If true, the exported image is anti-aliased. Default: true 如果为真,则导出的图像会进行抗锯齿处理,以改善边缘平滑度。默认:true |
Application | Application | Read-only. The Illustrator Application object. 只读属性。Illustrator应用程序对象,提供了对整个Illustrator应用的操作访问权限。 |
ArtBoardClipping | Boolean | If true, the exported image is clipped to the art board. Default: false 如果为真,则导出的图像将被裁剪到画板边界内。默认:false |
ColorCount | Long | The number of colors in the exported image’s color table. Range: 2 to 256. Default: 128 导出图像颜色表中颜色的数量。范围:2至256,默认:128 |
ColorDither | AiColorDitherMethod | The method used to dither colors in the exported image. Default: &H4466736E 在导出图像中使用的颜色抖动方法。默认:&H4466736E(代表某种特定的抖动算法) |
ColorReduction | AiColorReductionMethod | The method used to reduce the number of colors in the exported image.Default: &H536C7476 用于减少导出图像中颜色数量的方法。默认:&H536C7476(表示某种颜色减色算法) |
DitherPercent | Long | The amount that the colors of the exported image are dithered, where 100.0 is 100% 导出图像的颜色抖动程度,100.0代表100%。 |
HorizontalScale | Double | The horizontal scaling factor applied to the exported image, where 100.0 is 100%. Default: 100.0 应用于导出图像的水平缩放因子,100.0代表100%缩放(即无缩放)。默认:100.0 |
InfoLossPercent | Long | The level of information loss allowed during compression, where 100.0 is 100%. Default: 0 允许在压缩过程中损失的信息级别,100.0代表100%(即最大允许信息损失)。默认:0 |
Interlaced | Boolean | If true, the exported image is interlaced. Default: false 如果为真,则导出的图像采用交错显示模式。默认:false(非交错显示) |
Matte | Boolean | If true, the art board is matted with a color. Default: true 如果为真,则使用指定颜色为画板添加边框或背景填充(即“垫片”效果)。默认:true |
MatteColor | RGBColor | The color to use when matting the art board. Default: white 用于给画板添加边框或背景填充的颜色。默认:白色 |
SaveAsHTML | Boolean | If true, the exported image is saved with an accompanying HTML file. Default: false 如果为真,则导出的图像会伴随一个HTML文件一起保存。默认:false(仅保存图像文件而不生成HTML文件) |
Transparency | Boolean | If true, the exported image uses transparency. Default: true 如果为真,则导出的图像会保留并使用透明度信息。默认:true(即图像支持透明效果) |
VerticalScale | Double | The vertical scaling factor applied to the exported image, where 100.0 is 100%. Default: 100.0 应用于导出图像的垂直缩放因子,100.0代表100%缩放(即无缩放)。默认:100.0 |
WebSnap | Long | How much should the color table be changed to match the web palette, where 100 is maximum. Default: 0 表示颜色表应调整的程度以匹配网页调色板,100为最大程度匹配。默认:0(表示不进行调整以匹配网页调色板) |
Exporting as GIF
#Exports the current document as GIF to dest
#dest contains the full path and file name to save to
Sub exportFileAsGIF (dest)
Set appRef = CreateObject("Illustrator.Application")
Set gifExportOptions = CreateObject("Illustrator.ExportOptionsGIF")
If appRef.Documents.Count > 0 Then
gifExportOptions.AntiAliasing = False
gifExportOptions.ColorCount = 64
gifExportOptions.ColorDither = 1147564910 #aiDiffusion
Set docRef = appRef.ActiveDocument
Call docRef.Export (dest, 6, gifEportOptions) #6 = aiGIF
End If
End Sub
page 58
ExportOptionsJPEG
Options that may be supplied when exporting a document as a JPEG file. See the Document Export method for additional details.
When you export a document, the appropriate file extension is appended automatically. You should not include a file extension in the file specification.
ExportOptionsJPEG
Property | Value type | What it is |
---|---|---|
AntiAliasing | Boolean | If true, the exported image is anti-aliased. Default: true 如果为真,则导出的图像进行抗锯齿处理,以提升边缘平滑度。默认:true |
Application | Application | Read-only. The Illustrator Application object. 只读属性。表示Illustrator应用程序本身的对象引用,提供了对整个Illustrator应用的操作访问权限。 |
ArtBoardClipping | Boolean | If true, the exported image is clipped to the art board. Default: false 如果为真,则导出的图像会被裁剪至画板大小。默认:false |
BlurAmount | Double | The amount of blur to apply to the exported image. Range: 0.0 to 2.0. Default: 0.0 应用于导出图像的模糊程度。范围:0.0到2.0,默认:0.0(即不添加模糊效果) |
HorizontalScale | Double | The horizontal scaling factor applied to the exported image, where 100.0 is 100%. Default: 100.0 应用于导出图像的水平缩放因子,100.0代表100%缩放(即无缩放)。默认:100.0 |
Matte | Boolean | If true, the art board is matted with a color. Default: true 如果为真,则在导出时使用指定颜色为画板添加边框或背景填充。默认:true |
MatteColor | RGBColor | The color to use when matting the art board. Default: white 用于给画板添加边框或背景填充的颜色。默认:白色 |
Optimization | Boolean | If true, the exported image is optimized for web viewing. Default: true 如果为真,则导出的图像会针对网页查看进行优化。默认:true |
QualitySetting | Long | The quality of the exported image. Range: 0 to 100. Default: 30 导出图像的质量设置。范围:0到100,默认:30(质量级别越高,图像细节保留越多,文件可能越大) |
SaveAsHTML | Boolean | If true, the exported image is saved with an accompanying HTML file. Default: false 如果为真,则导出的图像会伴随一个HTML文件一起保存。默认:false(仅保存图像文件而不生成HTML文件) |
VerticalScale | Double | The vertical scaling factor applied to the exported image, where 100.0 is 100%. Default: 100.0 应用于导出图像的垂直缩放因子,100.0代表100%缩放(即无缩放)。默认:100.0 |
Exporting to JPEG
#Exports the current document as JPEG to dest
#dest contains the full path and file name to save to
Sub exportFileAsJPEG (dest)
Set appRef = CreateObject("Illustrator.Application")
Set jpegExportOptions = CreateObject("Illustrator.ExportOptionsJPEG")
If appRef.Documents.Count > 0 Then
jpegExportOptions.AntiAliasing = False
jpegExportOptions.QualitySetting = 70
Set docRef = appRef.ActiveDocument
Call docRef.Export (dest, 1, jpegExportOptions) ' 1 = aiJPEG
End If
End Sub
page 60
ExportOptionsPhotoshop
Options that may be supplied when exporting a document as an Adobe Photoshop® file. See the Document Export method for additional details.
When you export a document, the appropriate file extension is appended automatically. You should not include a file extension in the file specification.
All properties are optional.
ExportOptionsPhotoshop properties
Property | Value type | What it is |
---|---|---|
AntiAliasing | Boolean | If true, the exported image is anti-aliased. Default: true 如果设置为true,则导出的图像将进行抗锯齿处理,以消除边缘像素的锯齿效果。默认:true |
Application | Application | Read-only. The Illustrator Application object. 只读属性。表示Illustrator应用程序自身的对象,用于访问和操作整个Illustrator应用。 |
ArtboardRange | string | If SaveMultipleArtboards is true, this is considered for multi-asset extraction, which specifies the artboard range. An empty string extracts all the artboards. Default: empty string 如果SaveMultipleArtboards设为true,此属性用于多资产提取时指定要导出的艺术板范围。空字符串表示提取所有艺术板。默认:空字符串 |
EditableText | Boolean | If true, text objects are exported as editable text layers. Default: true 若为true,则文本对象在导出时会作为可编辑的文字层保存。默认:true |
EmbedICCProfile | Boolean | If true, an ICC profile are embedded in the exported file. Default: false 若为true,则会在导出文件中嵌入ICC色彩配置文件。默认:false |
ImageColorSpace | AiImageColorSpace | The color space of the exported file. |
MaximumEditability | Boolean | If true, preserve as much of the original document’s structure as possible when exporting. Default: true 若为true,在导出过程中尽可能保留原始文档结构以便后期编辑。默认:true |
Resolution | Double | The resolution of the exported file in dots per inch. Range: 72 to 2400. Default: 150 导出文件的分辨率,单位为每英寸点数(DPI)。范围:72至2400,默认:150 DPI |
SaveMultipleArtboards | boolean | If true, all artboards or range of artboards are saved. Default: false 若为true,则保存所有或指定范围内的多个艺术板。默认:false(仅保存当前选择的艺术板) |
Warnings | Boolean | If true, a warning dialog are displayed because of conflicts in the export settings. Default: true 若为true,当因导出设置冲突而产生警告时,将显示警告对话框。默认:true |
WriteLayers | Boolean | If true, the document layers are preserved in the exported file. Default: true 若为true,则在导出文件中保持文档中的图层结构。默认:true(即保留下各图层信息) |
Exporting to Photoshop
This example exports the current document as a Photoshop 5 file with layers.
#Exports the current document as PSD (Photoshop) to dest
#dest contains the full path and file name to save to
Sub exportFileAsPSD (dest)
Set appRef = CreateObject("Illustrator.Application")
Set psdExportOptions = CreateObject("Illustrator.ExportOptionsPhotoshop")
If appRef.Documents.Count > 0 Then
psdExportOptions.Resolution = 150
Set docRef = appRef.ActiveDocument
Call docRef.Export (dest, 2, psdExportOptions) #2 = aiPhotoshop
End If
End Sub
CHAPTER 1: VBScript Object Reference ExportOptionsPNG8 62
page 62
ExportOptionsPNG8
Options that may be supplied when exporting a document as an 8-bit PNG file. See the Document Export method for additional details.
When you export a document, the appropriate file extension is appended automatically. You should not include a file extension in the file specification.
ExportOptionsPNG8 properties
Property | Value type | What it is |
---|---|---|
AntiAliasing | Boolean | If true, the exported image is anti-aliased. Default: true 如果为 true,则导出的图像会进行抗锯齿处理。默认值:true |
Application | Application | Read-only. The Illustrator Application object. 只读。Illustrator 应用程序对象。 |
ArtBoardClipping | Boolean | If true, the exported image is clipped to the art board. Default: false 如果为 true,导出的图像将被裁剪至画板内。默认值:false |
ColorCount | Long | The number of colors in the exported image’s color table. Range: 2 to 256. Default: 128 导出图像颜色表中的颜色数量。范围:2 至 256。默认值:128 |
ColorDither | AiColorDitherMethod | The method used to dither colors in the exported image. Default: &H4466736E 用于在导出图像中抖动颜色的方法。默认值:&H4466736E |
ColorReduction | AiColorReductionMethod | The method used to reduce the number of colors in the exported image.Default: &H536C7476 用于减少导出图像中颜色数量的方法。默认值:&H536C7476 |
DitherPercent | Long | Specifies how much the colors of the exported image are dithered, where 100.0 is 100% 指定导出图像的颜色的抖动程度,其中 100.0 表示 100% |
HorizontalScale | Double | The horizontal scaling factor applied to the exported image, where 100.0 is 100%. Default: 100.0 应用于导出图像的水平缩放因子,其中 100.0 表示不缩放(100%)。默认值:100.0 |
Interlaced | Boolean | If true, the exported image are interlaced. Default: false 如果为 true,则导出的图像将以交错方式显示。默认值:false |
Matte | Boolean | If true, the art board is matted with a color. Default: true 如果为 true,则画板边缘会被特定颜色填充(打底色)。默认值:true |
MatteColor | RGBColor | The color to use when matting the art board. Default: white 用于填充画板背景的颜色。默认值:白色 |
SaveAsHTML | Boolean | If true, the exported image is saved with an accompanying HTML file. Default: false 如果为 true,则导出的图像将与一个配套的 HTML 文件一起保存。默认值:false |
Transparency | Boolean | If true, the exported image uses transparency. Default: true 如果为 true,则导出的图像将包含透明度信息。默认值:true |
VerticalScale | Double | The vertical scaling factor applied to the exported image, where 100.0 is 100%. Default: 100.0 应用于导出图像的垂直缩放因子,其中 100.0 表示不缩放(100%)。默认值:100.0 |
WebSnap | Long | Specifies how much the color table are changed to match the Web palette, where 100 is maximum. Default: 0 指定颜色表改变的程度以匹配网页安全色盘,其中 100 表示最大匹配程度。默认值:0 |
Exporting to PNG8
This example exports the current document as a PNG8 file.
'Exports the current document as PNG8 to dest
'dest contains the full path and file name to save to
Sub exportFileAsPNG (dest)
Set appRef = CreateObject("Illustrator.Application")
Set png8ExportOptions = CreateObject("Illustrator.ExportOptionsPNG8")
If appRef.Documents.Count > 0 Then
png8ExportOptions.AntiAliasing = False
png8ExportOptions.Interlaced = True
Set docRef = appRef.ActiveDocument
Call docRef.Export (dest, 4, png8ExportOptions) ' 4 = aiPNG8
End If
End Sub
page 64
ExportOptionsPNG24
Options that may be supplied when exporting a document as a 24-bit PNG file. See the Document Export method for additional details.
When you export a document, the appropriate file extension is appended automatically. You should not include a file extension in the file specification.
ExportOptionsPNG24 properties
Property | Value type | What it is |
---|---|---|
AntiAliasing | Boolean | If true, the exported image is anti-aliased. Default: true 若设置为 true,则导出的图像会应用抗锯齿效果,使得边缘更平滑。默认值:true |
Application | Application | Read-only. The Illustrator Application object. 只读属性。表示Illustrator应用程序自身的一个引用或实例。 |
ArtBoardClipping | Boolean | If true, the exported image is clipped to the art board. Default: false 如果该值为 true,则在导出图像时将裁剪至画板边界内。默认值:false |
HorizontalScale | Double | The horizontal scaling factor applied to the exported image, where 100.0 is 100%. Default: 100.0 应用于导出图像的水平缩放比例,100.0 表示不缩放(即原尺寸的100%)。默认值:100.0 |
Matte | Boolean | If true, the art board is matted with a color. Default: true 若设为 true,则会在画板周围添加一个颜色边框(垫底色)。默认值:true |
MatteColor | RGBColor | The color to use when matting the art board. Default: white 用于填充画板背景边框的颜色。默认值:白色 |
SaveAsHTML | Boolean | If true, the exported image is saved with an accompanying HTML file. Default: false 若设置为 true,则导出图像的同时还会生成一个配套的HTML文件。默认值:false |
Transparency | Boolean | If true, the exported image uses transparency. Default: true 若设置为 true,则导出的图像将包含透明度信息。默认值:true |
VerticalScale | Double | The vertical scaling factor applied to the exported image, where 100.0 is 100%. Default: 100.0 应用于导出图像的垂直缩放比例,100.0 表示不缩放(即原尺寸的100%)。默认值:100.0 |
Exporting to PNG24
This example exports the current document as a PNG24 file with specific options.
#Exports current document as PNG24 to dest
#dest contains the full path and file name to save to
Sub exportFileAsPNG (dest)
Set appRef = CreateObject("Illustrator.Application")
Set png24ExportOptions = CreateObject("Illustrator.ExportOptionsPNG24")
If appRef.Documents.Count > 0 Then
png24ExportOptions.AntiAliasing = False
png24ExportOptions.Transparency = False
Set docRef = appRef.ActiveDocument
Call docRef.Export (dest, 5, png24ExportOptions) #5 = aiPNG24
End If
End Sub
page 66
ExportOptionsSVG
Options that may be supplied when exporting a document as a SVG file. See the Document Export method for additional details.
When you export a document, the appropriate file extension is appended automatically. You should not include a file extension in the file specification.
ExportOptionsSVG properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。Illustrator应用程序的对象,用于访问和操作整个Illustrator应用。 |
ArtboardRange | String | A range of artboards to save, if SaveMultipleArtboards is true. A comma-delimited list of artboard names., or the empty string to save all artboards. Default: empty string 如果SaveMultipleArtboards设为true,则指定要保存的艺术板范围。以逗号分隔的艺术板名称列表,或者空字符串表示保存所有艺术板。默认:空字符串 |
Compressed | Boolean | If true, the exported file is compressed. Default: false 如果设置为true,则导出的文件将被压缩。默认:false(即不压缩) |
CoordinatePrecision | Long | The decimal precision for element coordinate values.Range: 1 to 7. Default: 3 元素坐标值的小数精度。范围:1到7,默认:3 |
CSSProperties | AiSVGCSSPropertyLocation | Specifies how the CSS properties of the document are included in the exported file 指定文档中的CSS属性如何包含在导出的文件中。 |
DocumentEncoding | AiSVGDocumentEncoding | Specifies how the text in the document is encoded. Default: 1 指定文档中文本的编码方式。默认:1(对应某个特定的文本编码格式) |
DTD | AiSVGDTDVersion | The SVG version to which the file should conform.Default: 2 指定导出文件应遵循的SVG版本。默认:2(通常指SVG 1.1或更高版本) |
EmbedRasterImages | Boolean | If true, all raster images contained in the document are embedded in the saved file. 如果为true,则文档中包含的所有栅格图像都会嵌入到保存的文件中。 |
FontSubsetting | AiSVGFontSubsetting | The font glyphs included in the export file. 指定导出文件中包含的字体字形子集。 |
FontType | AiSVGFontType | The type of font included in the exported file. Default: 1 aiCEFFont 指定导出文件中包含的字体类型。默认:1 aiCEFFont(通常指使用SVG内嵌字体,如SVG中的SVG字体或CFF OpenType字体) |
IncludeFileInfo | Boolean | If true, the XMP (Extensible Metadata Platform) metadata are included in the output file. Default: false 如果设置为true,则在输出文件中包含XMP(Extensible Metadata Platform)元数据信息。默认:false(即不包含XMP元数据) |
IncludeUnusedStyles | Boolean | If true, save unused styles in the exported file. Default: false 如果设置为true,则在导出文件中保存未使用的样式。默认:false(即不保存未使用的样式) |
IncludeVariablesAndDatasets | Boolean | If true, Variables and Datasets are included. Default:false 如果设置为true,则变量和数据集将被包含在导出内容中。默认:false(即不包含变量和数据集) |
OptimizeForSVGViewer | Boolean | If true, the Adobe namespace is included. Default: false 如果设置为true,则在文件中包含Adobe命名空间以优化与Adobe SVG Viewer的兼容性。默认:false |
PreserveEditability | Boolean | If true, preserve Illustrator editing capability when exporting the document.Default: false 如果设置为true,则在导出文档时保留Illustrator的编辑能力。默认:false(即可能丢失部分编辑功能) |
SaveMultipleArtboards | boolean | If true, save the artboards specified by artboardRange in the exported file. Default: false 如果设置为true,则按照ArtboardRange指定的艺术板范围,在导出文件中保存多个艺术板。默认:false(仅保存当前选择的艺术板) |
Slices | Boolean | If true, preserve slice data in exported document. Default: false 如果设置为true,则在导出文档中保留切片数据。默认:false(即不保存切片数据) |
SVGAutoKerning | Boolean | If true, SVG automatic kerning is allowed in the file. Default:false 如果设置为true,则允许文件中使用SVG自动字间距调整。默认:false(即不启用SVG自动字间距调整) |
SVGTextOnPath | Boolean | If true, the SVG text-on-path construct is allowed in the file. Default: false 如果设置为true,则允许文件中使用SVG文本沿路径排列的功能。默认:false(即不允许文本沿路径排列) |
Exporting to SVG
#Exports the current document as SVG to dest
#dest contains the full path and file name to save to
Sub exportFileAsSVG (dest)
Set appRef = CreateObject("Illustrator.Application")
Set svgExportOptions = CreateObject("Illustrator.ExportOptionsSVG")
If appRef.Documents.Count > 0 Then
svgExportOptions.EmbedRasterImages = True
svgExportOptions.FontSubsetting = 7 #aiAllGlyphs
Set docRef = appRef.ActiveDocument
Call docRef.Export (dest, 3, svgExportOptions) #3 = aiSVG
End If
End Sub
page 68
ExportOptionsTIFF
Options that may be supplied when exporting a document as a TIFF file. See the Document Export method for additional details.
When you export a document, the appropriate file extension is appended automatically. You should not include a file extension in the file specification.
All properties are optional.
ExportOptionsTIFF properties
Property | Value type | What it is |
---|---|---|
AntiAliasing | boolean | If true, the exported image should be anti-aliased. Default: true 如果设置为true,则导出的图像将进行抗锯齿处理,以提高边缘平滑度。默认:true |
ArtboardRange | string | If SaveMultipleArtboards is true, this is considered for multi-asset extraction, which specifies the artboard range. An empty string extracts all the rtboards. Default: empty string 如果SaveMultipleArtboards设为true,则此属性用于多资产提取时指定要导出的艺术板范围。空字符串表示提取所有艺术板。默认:空字符串 |
ByteOrder | AiTIFFByteOrder | The byte order to use in the new file. 在新文件中使用的字节顺序(通常是LittleEndian或BigEndian)。 |
ImageColorSpace | AiImageColorSpace | The color space of the exported file. Default: aiImageRGB 导出文件的颜色空间。默认:aiImageRGB(即RGB颜色空间) |
IZWCompression | boolean | If true, use IZW compression in the new file. 如果设置为true,则在新文件中使用IZW压缩算法。 |
Resolution | number (double) | Resolution of the exported file in dots per inch (dpi). Range: 72.0 to 2400.0. Default: 150.0 导出文件的分辨率,单位为每英寸点数(DPI)。范围:72.0至2400.0,默认:150.0 DPI |
SaveMultipleArtboards | boolean | If true, all artboards or range of artboards are saved. Default: false 如果设置为true,则保存所有或指定范围内的多个艺术板。默认:false(仅保存当前选择的艺术板) |
Exporting to TIFF format
#Exports the current document as TIFF to dest
#dest contains the full path and file name to save to
Sub exportFileAsTIFF (dest)
Set appRef = CreateObject("Illustrator.Application")
Set tiffExportOptions = CreateObject("Illustrator.ExportOptionsTIFF")
If appRef.Documents.Count > 0 Then
tiffExportOptions.imageColorSpace = 2 #aiImageRGB
tiffExportOptions.resolution = 150
tiffExportOptions.lZWCompression = true
Set docRef = appRef.ActiveDocument
Call docRef.Export (dest, 9, tiffExportOptions) #9 = aiTIFF
End If
End Sub
page 69
ExportOptionsWebP
Options for exporting a document as a WebP fileSee the Document Export method for additional details.
When you export a document, the appropriate file extension is appended automatically. You should not include any file extension in the file specification.
All properties are optional.
ExportOptionsWebP properties
Property | Value type | What it is |
---|---|---|
antiAliasing | AntiAliasingMethod | The type of antialiasing method of the exported image. Default - AntiAliasingMethod.TypeOptimized. 导出图像的抗锯齿方法类型。默认:AntiAliasingMethod.TypeOptimized(优化型抗锯齿) |
losslessCompression | boolean | Indicates whether to have lossless or lossy compression. 指示是否采用无损压缩或有损压缩方式。 |
imageQuality | number (long) | In lossy compression, indicates the quality of the exported image. Default - 100 Range - 0 to 100 在有损压缩时,表示导出图像的质量等级。默认:100 范围:0到100 |
isTransparent | boolean | If true, the exported image use transparency. Default - true. 如果为true,则导出的图像将使用透明度效果。默认:true |
embedICCProfile | boolean | If true, an ICC profile should be embedded in the exported file. Default - true. 如果为true,则应在导出文件中嵌入ICC色彩配置文件。默认:true |
pPI | number (double) | Resolution of the exported file in pixels per inch (ppi). Default - 72.0 Range - 4.0 to 2400.0 导出文件的分辨率,单位为每英寸像素数(PPI)。默认:72.0 范围:4.0至2400.0 |
matteColor | RGBColor | Matte color to be used for background if image is not transparent 如果图像不透明,则用于背景填充的颜色(即衬底色)。 |
typename | string | The class name of the referenced object. 引用对象的类名称。通常用于标识对象的实际类型。 |
Exporting to WebP format
//Exports current document to dest as a WebP file with specified options, dest contains
the full path including the file name
function exportFileToWebP (dest) {
if ( app.documents.length > 0 ) {
var exportOptions = new ExportOptionsWebP();
var type = ExportType.WEBP;
var fileSpec = new File(dest);
exportOptions.isTransparent = true;
exportOptions.imageQuality = 100;
app.activeDocument.exportFile( fileSpec, type, exportOptions );
}
}
CHAPTER 1: VBScript Object Reference FreeHandFileOptions 70
page 70
FreeHandFileOptions
Options for opening a FreeHand file.
FreeHandFileOptions properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。Illustrator应用程序对象,提供了对整个应用程序的访问。 |
ConvertTextToOutlines | Boolean | If true, converts all text to outlines. Default: false 如果设置为 true,则在打开文档时会将所有文本转换为轮廓(路径)。默认值:false |
ImportSinglePage | Boolean | If true, imports only the page specified in the PageToOpen property. Default: true 如果设置为 true,则仅导入指定在 PageToOpen 属性中的页面。适用于打开多页文档的情况。默认值:true |
PageToOpen | Long | The number of the page to import when opening a multipage document. Valid only when ImportSinglePage is true. 当 ImportSinglePage 设置为 true 时,表示要从一个多页文档中打开的页面编号。仅在 ImportSinglePage 为真时有效。 |
Parent | Document | Read-only. The document that contains this object. 只读。包含此对象的文档对象引用,提供对此对象所在文档上下文的访问。 |
page 71
FXGSaveOptions
Specifies options which may be supplied when saving a document as an FXG file. All properties are optional.
FXGSaveOptions properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。Illustrator应用程序对象,提供对整个应用程序的访问和控制。 |
ArtboardRange | string | If SaveMultipleArtboards is true, this is considered for multi-asset extraction, whichspecifies the artboard range. An empty string extracts all the artboards. Default: empty string 如果SaveMultipleArtboards设置为 true,则用于多资源提取时指定画板范围。空字符串表示提取所有画板。默认值:空字符串 |
BlendsPolicy | AiBlendsExpandPolicy | The policy used by FXG to expand blends. Default:AiAutomaticallyConvertBlends FXG 扩展混合模式时所采用的策略,默认为 AiAutomaticallyConvertBlends(自动转换混合效果)。 |
DownsampleLinkedImages | boolean | If true, linked images are downsampled (at 72 dpi).Default: false 若为 true,则链接的图像会被降采样至 72 dpi。默认值:false |
FiltersPolicy | AiFiltersPreservePolicy | The policy used by FXG to preserve filters. Default: 3 FXG 保留滤镜效果时采用的策略,默认为某个特定值(这里未明确指出,默认值应查阅文档确认)。 |
GradientsPolicy | AiGradientsPreservePolicy | The policy used by FXG to preserve gradients. Default:4aiAutomaticallyConvertGradients FXG 保留渐变时采用的策略,默认为 AiAutomaticallyConvertGradients(自动转换渐变)。 |
IncludeUnusedSymbols | boolean | If true, unused symbols are included. Default: false 若为 true,则包含未使用的符号。默认值:false |
PreserveEditingCapabilities | boolean | If true, the editing capabilities of FXG are preserved. Default: true 若为 true,则在 FXG 中保留编辑功能。默认值:true |
SaveMultipleArtboards | boolean | If true, all artboards or range of artboards are saved. Default: false 若为 true,则保存所有画板或指定范围内的画板。默认值:false |
TextPolicy | AiTextPreservePolicy | The policy used by FXG to preserve text. Default:4aiAutomaticallyConvertText FXG 保留文本时采用的策略,默认为 AiAutomaticallyConvertText(自动转换文本)。 |
Version | AiFXGVersion | The version of the FXG file format to create. Default: 2 创建 FXG 文件格式的版本号。默认值:2 |
page 72
Gradient
A gradient definition contained in a document. A script can create new gradients.
Gradient properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。Illustrator 应用程序对象,提供对整个 Illustrator 应用程序的访问和控制。 |
GradientStops | GradientStops | Read-only. The gradient stops contained in this gradient. 只读。该渐变中包含的所有渐变停止点,即渐变颜色和位置的集合。 |
Name | String | The gradient’s name. 此渐变的名称,用于标识和在库中引用该渐变。 |
Parent | Document | Read-only. The document that contains this gradient. 只读。包含此渐变的文档对象,表明该渐变是属于哪个特定Illustrator文档的资源。 |
Type | AiGradientType | The kind of the gradient, either radial or linear. 渐变的类型,可以是径向渐变(radial)或线性渐变(linear),定义了颜色过渡的方向和形状。 |
Gradient methods
Method | Returns | What it does |
---|---|---|
Delete() | Nothing | Deletes the object. |
Creating and applying a gradient
'Creates a new gradient in the current document with 2
'gradient stops, then applies the gradient to the front-
'most path item
Set appRef = CreateObject("Illustrator.Application")
Set frontDocument = appRef.ActiveDocument
'Create a color for both ends of the gradient
Set startColor = CreateObject("Illustrator.RGBColor")
Set endColor = CreateObject("Illustrator.RGBColor")
startColor.Red = 0
startColor.Green = 100
startColor.Blue = 255
endColor.Red = 220
endColor.Green = 0
endColor.Blue = 100
'Create a new gradient
'new gradients always have 2 stops
Set newGradient = frontDocument.Gradients.Add
newGradient.Name = "Gradient created from script"
newGradient.Type = 1 'aiLinearGradient
'Modify the first gradient stop.
Set locationSpecification = newGradient.GradientStops(1)
locationSpecification.RampPoint = 30
locationSpecification.MidPoint = 60
locationSpecification.Color = startColor
'Modify the last gradient stop.
'The MidPoint for the last gradient stop is ignored
Set locationSpecification = newGradient.GradientStops(2)
locationSpecification.RampPoint = 80
locationSpecification.Color = endColor
'construct an Illustrator.GradientColor object referring to the
'newly created gradient
Set ColorOfGradient = CreateObject("Illustrator.GradientColor")
ColorOfGradient.Gradient = newGradient
'now get the frontmost path item and
'apply the new gradient as its fill
Set topPath = frontDocument.PathItems(1)
topPath.Filled = True
topPath.fillColor = ColorOfGradient
page 74
GradientColor
A gradient color specification, used in conjunction with the Gradient property of the Color specification.
A script can create a GradientColor using a reference to an existing gradient in the application. If no
existing gradient object is referenced, a default gradient is supplied. An origin is used to specify the center point of the gradient in this specific gradient color. Single values are used to specify the gradient vector angles and lengths. A matrix may be specified to further transform the gradient color.
GradientColor properties
Property | Value type | What it is |
---|---|---|
Angle | Double | The gradient vector angle in degrees. 渐变矢量的角度,以度为单位。这用于定义线性渐变的方向。 |
Application | Application | Read-only. The Illustrator Application object. 只读。Illustrator 应用程序对象,提供了对整个 Illustrator 应用程序的访问和控制功能。 |
Gradient | Gradient | Reference to the object defining the gradient. 引用定义渐变的对象。这个属性通常指向一个具体的渐变实例,该实例定义了颜色过渡的详细信息。 |
HiliteAngle | Double | The gradient hilite vector angle in degrees. 高亮渐变矢量的角度,同样以度为单位。这用于定义在某些特定情况下(如选择状态)的渐变方向变化。 |
HiliteLength | Double | The gradient hilite vector length. 高亮渐变矢量的长度,决定渐变高亮部分的扩散范围。 |
Length | Double | The gradient vector length. 渐变矢量的长度,影响渐变在填充区域中的延伸程度。 |
Matrix | Matrix | An additional transformation matrix to manipulate the gradient path. 额外的变换矩阵,用于操纵渐变路径。通过此矩阵可以进一步调整渐变的位置、旋转等特性。 |
Origin | Variant Array of 2 Doubles | The gradient vector origin. 渐变矢量的起点,由包含两个双精度浮点数(X 和 Y 坐标)的数组表示。它定义了渐变开始应用的位置。 |
Changing a gradient color
'Creates a new RGB color then applies it as the color
'at the first gradient stop of the first gradient
Set appRef = CreateObject("Illustrator.Application")
Set frontDocument = appRef.Documents.Add(1) ' aiDocumentRGBColor
'Get a reference to the gradient that you want to change
Set firstGradient = frontDocument.Gradients(1)
'Create the new color
Set startColor = CreateObject("Illustrator.RGBColor")
startColor.Red = 0
startColor.Green = 255
startColor.Blue = 0
firstGradient.GradientStops(1).Color = startColor
CHAPTER 1: VBScript Object Reference
page 75
Gradients
A collection of Gradient objects in a document.
Gradients properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。Illustrator应用程序对象,提供了对整个Illustrator应用程序的访问和控制功能。 |
Count | Long | Read-only. The number of objects in the collection. 只读。集合中包含的对象数量,用于表示当前集合中有多少个元素或项目。 |
Parent | Document | Read-only. The parent document of this object. 只读。该对象所属的父文档对象,表明这个集合是属于哪个特定Illustrator文档的一部分。 |
Gradients methods
Method | Returns | What it does |
---|---|---|
Add() | Gradient | Creates a new object 创建并添加一个新的渐变对象到集合中,并返回新创建的渐变对象。 |
Index(item as Gradient) | Long | Returns the index position of the object within the collection. 传入一个Gradient对象,返回该对象在集合中的索引位置(即它在集合中的顺序编号)。 |
Item(itemKey) | Gradient | Returns an object reference to the object identified by itemKey (name or index). 根据传入的键(可以是名称或索引)返回集合中对应对象的引用。如果集合是一个渐变库,则可以通过名称或索引来获取指定的渐变对象。 |
RemoveAll() | Nothing | Deletes all objects in this collection. 删除集合中所有的对象,清空整个集合。此操作不会返回任何值。 |
Removing a gradient
'Deletes the first gradient in the current document
Set appRef = CreateObject("Illustrator.Application")
Set frontDocument = appRef.ActiveDocument
'Get a reference to the gradient that you want to delete
Set gradientToDelete = frontDocument.Gradients(1)
'Now delete the gradient using the collection
frontDocument.Gradients.Remove gradientToDelete
page 76
GradientStop
A gradient stop definition contained in a specific gradient. Represents a point on a gradient that specifies a color change. For an example, see GradientColor.
GradientStop properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。Illustrator应用程序对象,提供了对整个Illustrator应用的访问和控制功能。 |
Color | Color info | The color linked to this gradient stop. 与该渐变停止点关联的颜色。包含颜色的具体RGB、CMYK或其他色彩模式的数值信息。 |
Midpoint | Double | The distance between two GradientStops, in percentage. Range: 13.0 to 87.0 两个相邻GradientStops之间的距离百分比。范围:13.0到87.0,用于在渐变中定义中间颜色的位置。 |
Opacity | Double | The opacity value for the gradient stop. Range: 0.0 to 100.0 渐变停止点的不透明度值。范围:0.0(完全透明)到100.0(完全不透明)。 |
Parent | Document | Read-only. The document that contains this gradient stop. 只读。包含此渐变停止点所在的文档对象,表明该渐变停止点是属于哪个特定Illustrator文档资源的一部分。 |
RampPoint | Double | The location of the color in the blend. Range: 0.0 to 100.0, where 100.0 is 100% 颜色在渐变中的位置。范围:0.0到100.0,其中100.0代表渐变路径长度的100%。这个值决定了渐变颜色变化的关键点。 |
GradientStop methods
Method | Returns | What it does |
---|---|---|
Delete() | Nothing | Deletes the object. |
CHAPTER 1: VBScript Object Reference
page 77
GradientStops
A collection of GradientStop objects in a specific gradient.
GradientStops properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. |
Count | Long | Read-only. The number of objects in the collection. |
Parent | Document | Read-only. The document that contains this object. |
GradientStops methods
Method | Returns | What it does |
---|---|---|
Add() | GradientStop | Creates a new object |
Index(item as GradientStop) | Long | Returns the index position of the object within the collection. |
Item(itemKey) | GradientStop | Returns an object reference to the object identified by itemKey (name or index). |
RemoveAll() | Nothing | Deletes all objects in this collection. |
Adding a new gradient stop
'Adds a new gray gradient stop to an existing gradient
Set appRef = CreateObject("Illustrator.Application")
Set frontDocument = appRef.ActiveDocument
'Get a reference to the gradient that you want to change
Set changeGradient = frontDocument.Gradients(1)
'Get a reference to the gradient stop that is the last one
'before you add a new gradient stop
originalCount = changeGradient.GradientStops.Count
Set lastStop = changeGradient.GradientStops(originalCount)
'add the new gradient stop
Set newStop = changeGradient.GradientStops.Add
'Set the values of the new gradient stop. move the original
'last gradient stop a bit to the left, and
'insert the new gradient stop at the old gradient stop's position
newStop.RampPoint = lastStop.RampPoint
lastStop.RampPoint = lastStop.RampPoint - 10
'Create a new color to apply to the newly created gradient stop
'choose a Gray tint value of 70%
Set newStopColor = CreateObject("Illustrator.GrayColor")
newStopColor.Gray = 70
newStop.Color = newStopColor
page 79
GraphicStyle
Each graphic style defines a set of appearance attributes that you can apply to PageItem objects. Graphic styles are contained in documents. Scripts cannot create new graphic styles.
GraphicStyle properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. |
Name | String | The GraphicStyle name. |
Parent | Document | Read-only. The document that contains this object. |
GraphicStyle methods
Method | Returns | What it does |
---|---|---|
ApplyTo(artItem as PageItem) | Nothing | Applies the GraphicStyle to a specific art item. 将此GraphicStyle应用到指定的PageItem(页面项目),例如路径、组或文本对象,从而改变其外观样式。 |
MergeTo(artItem as PageItem) | Nothing | Merges this style into the current styles of a specified art item. 将此GraphicStyle合并至指定的PageItem当前已有的样式中,即将此样式属性叠加到目标对象现有的样式上,而不是完全替代原有样式。 |
Delete() | Nothing | Deletes the object. 删除这个GraphicStyle对象,从文档中移除该样式,并且所有关联此样式的艺术项目将不再应用该样式。 |
Applying a graphic style
This example duplicates and groups the current selection, applying the second graphic style in the document to the items in the group.
'Creates a new group item, adds a duplicate of each
'selected item to the group then applies a graphic style
'to the group
Set appRef = CreateObject("Illustrator.Application")
If appRef.Documents.Count > 0 Then
If Not IsEmpty(appRef.Selection) Then
mySelection = appRef.Selection
endIndex = UBound(mySelection)
startIndex = LBound(mySelection)
Set newGroup = appRef.ActiveDocument.GroupItems.Add
For i = startIndex To endIndex
Set artItem = mySelection(i)
Set dupItem = artItem.Duplicate(newGroup, aiPlaceAtEnd)
appRef.ActiveDocument.GraphicStyles(2).ApplyTo dupItem
Next
End If
End If
CHAPTER 1: VBScript Object Reference
page 79
GraphicStyles
A collection of graphic styles in a document.
GraphicStyles properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. |
Count | Long | Read-only. The number of objects in the collection. |
Parent | Document | Read-only. The document that contains this object. |
GraphicStyles methods
Method | Returns | What it does |
---|---|---|
Index(item as GraphicStyle) | Long | Returns the index position of the object within the collection. 传入一个GraphicStyle对象,返回该对象在集合中的索引位置。此方法帮助你获取指定样式的在当前集合中的排列顺序编号。 |
Item(itemKey) | GraphicStyle | Returns an object reference to the object identified by itemKey (name or index). 根据传入的键(可以是名称或索引)返回集合中对应的GraphicStyle对象引用。这允许你通过样式名称或其在集合中的索引来访问和操作特定的图形样式对象。 |
RemoveAll() | Nothing | Deletes all objects in this collection. 删除当前集合中的所有GraphicStyle对象,清空整个集合。调用此方法后,集合将不再包含任何元素。 |
Counting graphic styles
'Counts the number of graphic styles in the current document
'and stores in numStyles
Set appRef = CreateObject("Illustrator.Application")
If appRef.Documents.Count > 0 Then
numStyles = appRef.ActiveDocument.GraphicStyles.Count
End If
page 81
GraphItem
A graph artwork item. Scripts cannot create new graph items.
GraphItem properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。Illustrator应用程序对象,提供了对整个Illustrator应用程序的访问和控制功能。 |
ArtworkKnockout | AiKnockoutState | Is this GraphItem used to create a knockout, and if so, what kind. 指示此GraphItem是否用于创建镂空效果及镂空的具体类型。 |
BlendingMode | AiBlendModes | The mode used when compositing an object. 设置该对象在合成时所采用的混合模式(如叠加、正片叠底等)。 |
ContentVariable | Variable | The content variable bound to this GraphItem.It is not necessary to set the type of the ContentVariable before binding. Illustrator automatically sets the type to AiGraph. 与此GraphItem关联的内容变量。绑定前无需设置ContentVariable的类型,Illustrator会自动将其设置为AiGraph类型。 |
ControlBounds | Variant Array of 4 Doubles | Read-only. The bounds of the object including stroke width and controls. 只读。包含描边宽度和控件在内的对象边界范围。 |
Editable | Boolean | Read-only. If true, the GraphItem is editable. 只读。如果为true,则表示此GraphItem可编辑。 |
GeometricBounds | Variant Array of 4 Doubles | Read-only. The bounds of the GraphItem excluding stroke width. 只读。不包括描边宽度的GraphItem边界范围。 |
Height | Double | The height of the GraphItem, calculated on the GeometricBounds. 基于GeometricBounds计算出的GraphItem高度。 |
Hidden | Boolean | If true, this GraphItem is hidden. 如果为true,则表示此GraphItem被隐藏。 |
IsIsolated | Boolean | If true, this GraphItem is isolated. 如果为true,则表示此GraphItem处于隔离状态。 |
Layer | Layer | Read-only. The Layer to which this GraphItem belongs. 只读。此GraphItem所属的图层。 |
Left | Double | The position of the left side of the GraphItem (in points, measured from the left side of the page). GraphItem左侧边缘的位置(以点为单位,从页面左边缘开始测量)。 |
Locked | Boolean | If true, this GraphItem is locked. 如果为true,则表示此GraphItem已被锁定,不可编辑。 |
Name | String | The name of this GraphItem. 此GraphItem的名称。 |
Note | String | The note assigned to this GraphItem. 分配给此GraphItem的注释信息。 |
Opacity | Double | The opacity of the GraphItem. Range: 0.0 to 100.0 GraphItem的不透明度,范围:0.0到100.0。 |
Parent | Layer or GridRepeatConfig | Read-only. The parent of this GraphItem. 只读。此GraphItem的父级对象,可能是图层或某种网格重复配置。 |
Position | Variant Array of 2 Doubles | The position (in points) of the top left corner of the item in the format [x, y]. Does not include stroke weight. 项目左上角位置的坐标数组(格式为[x, y]),以点为单位,不包含描边宽度。 |
Selected | Boolean | If true, this GraphItem is selected. 如果为true,则表示此GraphItem当前被选中。 |
Sliced | Boolean | If true, this GraphItem is sliced. Default: false 如果为true,表示此GraphItem被切片处理。默认值:false |
Tags | Tags | Read-only. The collection of Tags contained in this GraphItem. 只读。此GraphItem包含的标签集合,用于组织和标记图形元素。 |
Top | Double | The position of the top of the item (in points, measured from the bottom of the page). 项目顶部的位置(以点为单位,从页面底部开始测量)。 |
URL | String | The value of the Adobe URL tag assigned to this GraphItem. 分配给此GraphItem的Adobe URL标签的值,可用于超链接功能。 |
VisibilityVariable | Variable | The visibility variable bound to this GraphItem.It is not necessary to set the type of the VisibilityVariable before binding. Illustrator automatically sets the type to AiVisibility. 与此GraphItem关联的可见性变量。绑定前无需设置VisibilityVariable的类型,Illustrator会自动将其设置为AiVisibility类型。 |
VisibleBounds | Variant Array of 4 Doubles | Read-only. The visible bounds of the GraphItem including stroke width. 只读。包括描边宽度在内的GraphItem可见边界范围。 |
Width | Double | The width of the GraphItem, based on the GeometricBounds. 基于GeometricBounds计算出的GraphItem宽度。 |
WrapInside | Boolean | If true, the text frame object is wrapped inside this object. 如果为true,表示文本框对象将被包裹在这个对象内部。 |
WrapOffset | Double | The offset to use when wrapping text around this object. 当文本环绕此对象时使用的偏移量,控制文本与该对象的距离。 |
Wrapped | Boolean | If true, wrap text frame objects around this object (text frame must be above the object). 如果为true,则允许文本框对象围绕此对象进行环绕排版(要求文本框在该对象之上)。 |
ZOrderPosition | Long | Read-only. The position of this GraphItem within the stacking order of the GroupItem or Layer (Parent) that contains the GraphItem. 只读。表示此GraphItem在其所在GroupItem或Layer(父级)中的堆叠顺序位置,即层叠顺序中的索引。 |
GraphItem methods
Method | Returns | What it does |
---|---|---|
Copy() | Nothing | Copies the GraphItem to the clipboard; the associated document must be the frontmost document. 复制GraphItem到剪贴板,操作时关联的文档必须是前台最活跃的文档。 |
Cut() | Nothing | Cuts the GraphItem to the clipboard;the associated document must be the frontmost document. 剪切GraphItem到剪贴板,同样要求关联文档为当前最前面的文档。 |
Delete() | Nothing | Deletes the object. 删除此对象。 |
Duplicate([relativeObject as Object],[insertionLocation as AiElementPlacement]) | Object | Duplicates the art item, optionally specifying the location and position for the copy. 复制图形元素,并可选择指定复制后的插入位置和对齐方式。 |
Move(relativeObject as Object,insertionLocation as AiElementPlacement) | Nothing | Moves the art item, specifying the new location and position. 移动图形元素,指定新的位置和对齐方式。 |
Resize(scaleX as Double,scaleY as Double,[, changePositions as Boolean][, changeFillPatterns as Boolean] [, changeFillGradients as Boolean] [, changeStrokePattern as Boolean] [, changeLineWidths as Double][,scaleAbout as AiTransformation]) | Nothing | Scales the GraphItem where scaleX is the horizontal scaling factor and scaleY is the vertical scaling factor. 100.0 = 100% 按给定的水平缩放因子scaleX和垂直缩放因子scaleY缩放图形元素。100.0表示100%不缩放,可以同时选择是否改变位置、填充图案、填充渐变、描边图案及线宽等属性,并可指定缩放中心点。 |
Rotate(angle as Double,[, changePositions as Boolean][, changeFillPatterns as Boolean][, changeFillGradients as Boolean][, changeStrokePattern as Boolean][, rotateAbout as AiTransformation]) | Nothing | Rotates the GraphItem relative to the current rotation; counter-clockwise if the Angle value is positive, clockwise if the value is negative. 围绕当前旋转角度以顺时针或逆时针对图形元素进行旋转。如果角度值为正,则逆时针旋转;如果为负,则顺时针旋转。可以设置是否更改位置、填充图案、填充渐变、描边图案等相关属性,并指定旋转中心点。 |
Transform(transformationMatrix as Matrix,[, changePositions as Boolean][, changeFillPatterns as Boolean][, changeFillGradients as Boolean][, changeStrokePattern as Boolean][, changeLineWidths as Double][, transformAbout as AiTransformation]) | Nothing | Transforms the GraphItem by applying a transformation matrix. 通过应用一个转换矩阵来变换图形元素。可以控制是否改变位置、填充图案、填充渐变、描边图案及线宽等属性,并指定转换中心点。 |
Translate([deltaX as Double][, deltaY as Double][, transformObjects as Boolean][, transformFillPatterns as Boolean][, transformFillGradients as Boolean][, transformStrokePatterns as Boolean]) | Nothing | Repositions the GraphItem relative to the current position, where deltaX is the horizontal offset and deltaY is the vertical offset. 相对当前位置重新定位图形元素,其中deltaX为水平偏移量,deltaY为垂直偏移量。可以选择是否变换与该元素相关的其他属性。 |
ZOrder(zOrderCmd as AiZOrderMethod)Nothing | Arranges the GraphItem’s position in the stacking order of the group or layer (Parent) of this object. 调整图形元素在组或图层中的堆叠顺序,即其在父级容器内的前后层次关系。 |
Rotating graph items
'Rotates each graph item in the current document 90 degrees.
Set appRef = CreateObject("Illustrator.Application")
'Rotate each graph item 90 degrees
For Each graphRef In appRef.ActiveDocument.GraphItems
graphRef.Rotate 90
Next
appRef.Redraw
page 85
GraphItems
A collection of GraphItem objects.
GraphItems properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. |
Count | Long | Read-only. The number of objects in the collection. |
Parent | Document | Read-only. The document that contains this object. |
GraphItems methods
Method | Returns | What it does |
---|---|---|
Index(item as GraphItem) | Long | Returns the index position of the object within the collection. |
Item(itemKey) | GraphItem | Returns an object reference to the object identified by itemKey (name or index). |
RemoveAll() | Nothing | Deletes all objects in this collection. |
page 86
GrayColor
A grayscale color specification used to apply a gray color to a layer or art item.
GrayColor properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。Illustrator应用程序对象,提供了对整个Adobe Illustrator应用程序的访问和控制功能。 |
Gray | Double | The tint of the gray. Range: 0.0 to 100.0, where 0.0 is black and 100.0 is white. 灰色的深浅度(色调)。范围:0.0至100.0,其中0.0表示黑色,100.0表示白色。该属性通常用于定义或获取一个单色灰度值的颜色信息。 |
Changing word color to gray
'Sets the fill color of the first word in the document to gray
Set appRef = CreateObject("Illustrator.Application")
Set textColor = CreateObject("Illustrator.GrayColor")
'Get a reference to the first word in the active document
Set text = appRef.ActiveDocument.TextFrames(1).TextRange
Set firstWord = text.Words(1)
'Create the new color
textColor.Gray = 45
firstWord.CharacterAttributes.fillColor = textColor
page 87
GridRepeatConfig
Specifies grid repeat art configuration options.
指定网格重复艺术的配置选项。
GridRepeat properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。表示Illustrator应用程序自身的对象,提供了对整个应用程序的访问和控制能力。 |
columnFlipType | AiRepeatGridShiftFlipType | Column flip type of grid repeat art. Default value: NoSF 网格重复艺术中的列翻转类型。默认值:NoSF(不进行水平翻转)。 |
horizontalSpacing | double | Spacing between each rows. Default value: 10 行与行之间的间距。默认值为10个单位。 |
patternType | AiRepeatGridShiftFlipType | Shifts type of grid repeat art. Default value: NoSF 网格重复艺术的平移类型。默认值:NoSF(不进行平移)。 |
rowFlipType | AiRepeatGridShiftFlipType | Row flip type of grid repeat art. Default value: NoSF 网格重复艺术中的行翻转类型。默认值:NoSF(不进行垂直翻转)。 |
verticalSpacing | double | Spacing between each columns. Default value: 10 列与列之间的间距。默认值为10个单位。 |
page 88
GridRepeatItem
Specifies grid repeat item options.
GridRepeatItem properties
Property | Value type | What it is |
---|---|---|
parent | object | Read-only. The object’s container. 只读。表示该对象所在的容器,即父级对象,它可以是更高层级的复合图形、图层或者其他可以包含路径项的容器结构。 |
GridConfig | GridRepeatConfig | Read-only. Grid repeat configuration for repeat art. 只读。网格重复配置信息,针对重复艺术(Pattern或Repeat Grid)设置的具体参数,如平移、翻转等行为方式以及间距等布局属性。 |
URL | String | The value of the Adobe URL tag assigned to this path item. 分配给此路径项(可能是图形、图像或其他元素)的Adobe URL标签值,通常用于链接到外部资源或者嵌入元数据信息。 |
Width | Double | The width of the grid repeat item, based on the GeometricBounds. 基于几何边界(GeometricBounds)计算出的网格重复项目宽度,这是指单个重复单元格在横向上的尺寸大小。 |
GridRepeatItem methods
Method | Returns | What it does |
---|---|---|
duplicate([relativeObject as object][,insertionLocation as Object]) | GridRepeatItem | Creates a duplicate of the selected object. 创建选定对象的副本。此方法会复制指定的网格重复项目,并可选择性地将其插入到相对对象或指定的位置中,然后返回新创建的网格重复项目实例。 |
move(relativeObject as Object,insertionLocation as AiElementPlacement) | GridRepeatItem | Moves the object. 移动对象。此方法将当前的网格重复项目移动到相对于另一个对象的位置上,具体位置由AiElementPlacement参数决定。执行后返回被移动的网格重复项目实例本身。 |
setGridConfiguration(config as GridRepeatConfig, state as AiGridRepeatUpdate) | String | Updates the grid repeat art. 更新网格重复艺术配置。该方法用于设置或修改当前网格重复项目的配置信息(如翻转、平移等行为),使用给定的GridRepeatConfig对象作为新的配置数据,并根据AiGridRepeatUpdate状态来控制如何应用这些更改。方法执行成功后通常会返回一个表示操作结果的字符串信息。 |
page 89
GridRepeatItems
Specifies a collection of grid repeat items.
GridRepeatItems properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. |
parent | object | Read-only. The object’s container. |
count | long | Read-only. The number of elements in the collection. |
GridRepeatItems methods
Method | Returns | What it does |
---|---|---|
Add(SourceArt as Object,[Config as GridRepeatConfig]) | GridRepeatItem | Creates a grid repeat art 创建网格重复艺术。此方法从给定的源对象(SourceArt)创建一个新的网格重复项目,并可选地应用一个自定义的网格配置(GridRepeatConfig)。成功创建后,该方法会返回新生成的网格重复项目实例(GridRepeatItem)。 |
RemoveAll() | Nothing | Deletes all elements. 删除所有元素。此方法用于清空或删除当前容器中的所有网格重复项目或其他相关元素。执行此操作后,不会返回任何值(即返回值类型为无:Nothing)。 |
page 90
AiGridRepeatUpdate
Represents which property of grid repeat gets updated.
GridRepeatUpdate properties
Property | Value type | What it is |
---|---|---|
AiGridAll | constant | Updates all the properties of grid repeat art. 用于更新网格重复艺术的所有属性。调用此属性可能触发对整个网格布局及其所有相关属性的全局重新计算和同步。 |
AiHorizontalSpacing | constant | Updates spacing between rows of grid repeat artwork. 用于更新网格重复艺术品中行与行之间的间距。设置此属性会更改网格布局中同一行内相邻元素之间的水平间距。 |
AiVerticalSpacing | constant | Updates spacing between columns of grid repeat artwork. 更新网格重复艺术品中列与列之间的间距。设置此属性会更改网格布局内不同列之间相邻元素的垂直间距大小。 |
page 91
GroupItem
A grouped set of art items. Group items can contain all of the same page items that a layer can contain, including other nested groups.
Paths contained within a group or compound path in a document are returned as individual paths when a script asks for the paths contained in the document. However, paths contained in a group or compound path are not returned when a script asks for the paths in a layer which contains the group or compound path.
GroupItem properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。指向Illustrator应用程序本身的对象,用于访问和控制整个应用程序的功能。 |
ArtworkKnockout | AiKnockoutState | Is this object used to create a knockout, and if so, what kind. 该对象是否被用于创建镂空效果,如果是的话,属于哪种类型的镂空。 |
BlendingMode | AiBlendModes | The mode used when compositing an object. 在组合对象时所采用的混合模式。 |
Clipped | Boolean | If true, the GroupItem is clipped to the clipping mask. 如果为真,则表示此GroupItem(组项目)受到剪切蒙版的剪裁。 |
CompoundPathItems | CompoundPathItems | Read-only. The CompoundPathItems contained in this GroupItem. 只读。该GroupItem中包含的所有复合路径项目的集合。 |
ControlBounds | Variant Array of 4 Doubles | Read-only. The bounds of the object including stroke width and controls. 只读。包括描边宽度和控件在内的对象边界范围。 |
Editable | Boolean | Read-only. If true, this GroupItem is editable. 只读。如果为真,则表示这个GroupItem可以被编辑。 |
GeometricBounds | Variant Array of 4 Doubles | Read-only. The bounds of the object excluding stroke width. 只读。不包括描边宽度的对象边界范围。 |
GraphItems | GraphItems | Read-only. The raster items contained in this GroupItem. 只读。该GroupItem中包含的所有栅格图像项目的集合。 |
GroupItems | GroupItems | Read-only. The GroupItems contained in this GroupItem. 只读。该GroupItem中嵌套的其他组项目的集合。 |
Height | Double | The height of the GroupItem, based on the GeometricBounds. 基于GeometricBounds计算出的GroupItem的高度。 |
Hidden | Boolean | If true, this GroupItem is hidden. 如果为真,则表示此GroupItem被隐藏。 |
IsIsolated | Boolean | If true, this object is isolated. 如果为真,则表示此对象已被隔离。 |
Layer | Layer | Read-only. The layer to which this GroupItem belongs. 只读。此GroupItem所属的图层对象。 |
Left | Double | The position of the left side of the GroupItem (in points, measured from the left side of the page). GroupItem左边缘的位置(以点为单位,从页面左侧开始测量)。 |
LegacyTextItems | LegacyTextItems | Read-only. The legacy text items in the group. 只读。该组中的遗留文本项目。 |
Locked | Boolean | If true, this GroupItem is locked. 如果为真,则表示此GroupItem已被锁定,无法进行编辑操作。 |
MeshItems | MeshItems | Read-only. The MeshItems contained in this GroupItem. 只读。该GroupItem中包含的所有网格项目的集合。 |
Name | String | The name of this GroupItem. 此GroupItem的名称。 |
NonNativeItems | NonNativeItems | Read-only. The non-native art items in this group. 只读。此组中包含的非原生艺术项目(如导入的SVG或PDF内容)。 |
Note | String | The note assigned to this GroupItem. 分配给此GroupItem的注释。 |
Opacity | Double | The opacity of the object. Range: 0.0 to 100.0 对象的不透明度。范围:0.0到100.0,表示从完全透明到完全不透明。 |
PageItems | PageItems | Read-only. The PageItems contained in this GroupItem. 只读。此GroupItem中包含的所有页面项目的集合。 |
Parent | Document | Read-only. The document that contains this GroupItem. 只读。包含此GroupItem的父级文档对象。 |
PathItems | PathItems | Read-only. The PathItems contained in this GroupItem. 只读。此GroupItem中包含的所有路径项目的集合。 |
PlacedItems | PlacedItems | Read-only. The PlacedItems contained in this GroupItem. 只读。此GroupItem中包含的所有置入(如图片)项目的集合。 |
PluginItems | PluginItems | Read-only. The PluginItems contained in this GroupItem. 只读。此GroupItem中包含的由插件生成的项目的集合。 |
Position | Variant Array of 2 Doubles | The position (in points) of the top left corner of the item in the format [x, y]. Does not include stroke weight. 对象左上角的位置(以点为单位),格式为[x, y]。不包括描边宽度。 |
RasterItems | RasterItems | Read-only. The RasterItems contained in this GroupItem. 只读。此GroupItem中包含的所有栅格图像项目的集合。 |
Selected | Boolean | If true, this GroupItem is selected. 如果为真,则表示此GroupItem被选中。 |
Sliced | Boolean | If true, this GroupItem is sliced. Default: false 如果为真,则表示此GroupItem已被切片处理。默认值为false。 |
SymbolItems | SymbolItems | Read-only. The SymbolItems contained in this GroupItem. 只读。此GroupItem中包含的所有符号项目的集合。 |
Tags | Tags | Read-only. The tags contained in this GroupItem. 只读。此GroupItem中包含的所有标签。 |
TextFrames | TextFrames | Read-only. The TextFrame objects contained in this GroupItem. 只读。此GroupItem中包含的所有文本框对象的集合。 |
Top | Double | The position of the top of the item (in points, measured from the bottom of the page). 该对象顶部的位置(以点为单位,从页面底部开始测量)。 |
URL | String | The value of the Adobe URL tag assigned to this GroupItem. 分配给此GroupItem的Adobe URL标签的值。 |
VisibilityVariable | Variable | The Variable bound to this GroupItem. 与此GroupItem关联的变量。 |
VisibleBounds | Variant Array of 4 Doubles | Read-only. The visible bounds of the GroupItem including stroke width. 只读。包括描边宽度在内的可见边界范围。 |
Width | Double | The width of the GroupItem, based on the GeometricBounds. 基于GeometricBounds计算出的GroupItem的宽度。 |
WrapInside | Boolean | If true, the text frame object are wrapped inside this object. 如果为真,表示文本框对象会被包裹在这个对象内部。 |
WrapOffset | Double | The offset to use when wrapping text around this object. 当环绕此对象排列文本时使用的偏移量。 |
Wrapped | Boolean | If true, wrap text frame objects around this object (text frame must be above the object). 如果为真,表示文本框对象会围绕此对象排列(前提是文本框位于该对象上方)。 |
ZOrderPosition | Long | Read-only. The position of this group item within the stacking order of the group or layer (Parent) that contains this group item. 只读。此GroupItem在其所在群组或层(父级)中的堆叠顺序位置。 |
GroupItem methods
Method | Returns | What it does |
---|---|---|
Copy() | Nothing | Copies the GroupItem to the clipboard; the associated document must be the frontmost document. 复制GroupItem到剪贴板,要求关联的文档是当前最前端文档。 |
Cut() | Nothing | Cuts the GroupItem to the clipboard; the associated document must be the frontmost document. 剪切GroupItem到剪贴板,同样要求关联的文档位于前台。 |
Delete() | Nothing | Deletes the object. 删除该对象。 |
Duplicate([relativeObject as Object],[insertionLocation as AiElementPlacement]) | Object | Duplicates the art item, optionally specifying the location and position for the copy. 复制艺术项目,可选地指定副本的位置和排列方式。 |
Move(relativeObject as Object,insertionLocation as AiElementPlacement) | Nothing | Moves the art item, specifying the new location and position. 移动艺术项目到新的位置。 |
Paste() | Nothing | Inserts the contents of the clipboard at the beginning of the GroupItem. You may only paste into a group that is contained in the active document. 在GroupItem开始处插入剪贴板的内容。只能粘贴到活动文档中包含的群组内。 |
Resize(scaleX as Double,scaleY as Double,[, changePositions as Boolean][, changeFillPatterns as Boolean][, changeFillGradients as Boolean] [, changeStrokePattern as Boolean][, changeLineWidths as Double][, scaleAbout as AiTransformation]) | Nothing | Scales the art item where scaleX is the horizontal scaling factor and scaleY is the vertical scaling factor; 100.0 = 100% 按指定的水平和垂直缩放因子缩放艺术项目;100.0表示100%比例不变。 |
Rotate(angle as Double,[, changePositions as Boolean][, changeFillPatterns as Boolean][, changeFillGradients as Boolean][, changeStrokePattern as Boolean][, rotateAbout as AiTransformation]) | Nothing | Rotates the art item relative to the current rotation. The object is rotated counter-clockwise if the Angle value is positive, clockwise if the value is negative. 以当前旋转为基础,根据给定的角度(正值为逆时针,负值为顺时针)旋转艺术项目。 |
Transform(transformationMatrix as Matrix[, changePositions as Boolean][, changeFillPatterns as Boolean][, changeFillGradients as Boolean][, changeStrokePattern as Boolean][, changeLineWidths as Double][, transformAbout as AiTransformation]) | Nothing | Transforms the art item by applying a transformation matrix. 应用一个变换矩阵来转换艺术项目。 |
Translate([deltaX as Double][, deltaY as Double][, transformObjects as Boolean][, transformFillPatterns as Boolean][, transformFillGradients as Boolean][, transformStrokePatterns as Boolean]) | Nothing | Repositions the art item relative to the current position, where deltaX is the horizontal offset and deltaY is the vertical offset. 根据给定的水平和垂直偏移量相对于当前位置重新定位艺术项目。 |
ZOrder(zOrderCmd as AiZOrderMethod) | Nothing | Arranges the art item’s position in the stacking order of the group or layer (Parent) of this object. 调整艺术项目在所属群组或图层(父级)中的堆叠顺序。 |
Creating a group
It is easy to modify all of the objects contained in a group. This example demonstrates how to simplify your operations on multiple objects by creating a group to contain them.
'Creates a new group in the current document, containing
'a path item, and a text item
Set appRef = CreateObject("Illustrator.Application")
'Create a new group in the active document.
'This will be the group that holds the new triangle art
Set triangleGroup = appRef.ActiveDocument.GroupItems.Add
'Create a triangle and add text inside the group
Set trianglePath = triangleGroup.PathItems.Add
trianglePath.SetEntirePath Array(Array(100, 100), Array(300, 100), Array(200,
Tan(1.0471975) * 100 + 100))
Set captionText = triangleGroup.TextFrames.Add
captionText.Position = Array(100, 100)
captionText.Contents = "A triangle"
page 95
GroupItems
A collection of GroupItem objects.
GroupItems properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。指向Illustrator应用程序本身的对象,提供了对整个应用程序功能的访问权限。 |
Count | Long | Read-only. The number of objects in the collection. 只读。表示集合中包含的对象数量。 |
Parent | Document | Read-only. The document that contains this object. 只读。包含当前对象的父级文档对象,即这个对象所在的文档。 |
GroupItems methods
Method | Returns | What it does |
---|---|---|
Add() | GridRepeatConfig | Creates a new object. 创建一个新的对象实例。 |
CreateFromFile(imagefile as String) | GridRepeatConfig | Creates a GroupItem from a vector graphics file. 从矢量图形文件创建一个GroupItem对象。 |
Index(item as GroupItem) | Long | Returns the index position of the object within the collection. 返回集合中指定的GroupItem对象在其所在位置的索引号。 |
Item(itemkey) | GridRepeatConfig | Returns an object reference to the object identified by itemkey (name or index). 通过itemkey(名称或索引)返回对集合中特定GridRepeatConfig对象的引用。 |
RemoveAll() | Nothing | Deletes all objects in this collection. 删除此集合中的所有对象实例。 |
Importing a file using GroupItems
The following script shows how you can import a JPEG document using the CreateFromFile function. Before running this script you have to create a one-page PDF file and put it in the location.
C:\temp\AiExport.jpg.
'Adds a new group item to the document from a file (dest)
'dest contains the full path and file name of the file
Sub embedPDF (dest)
Set appRef = CreateObject("Illustrator.Application")
Set importedGroup = appRef.ActiveDocument.GroupItems.CreateFromFile (dest)
End Sub
page 96
IllustratorSaveOptions
Options that can be supplied when saving a document as an Illustrator file with the document SaveAs method.
IllustratorSaveOptions properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。指向Illustrator应用程序自身的对象,提供对整个应用程序的访问权限。 |
ArtboardRange | string | If SaveMultipleArtboards is true (which is valid only for Illustrator 13 or earlier), the document is considered for multi-asset extraction, which specifies an artboard range. An empty string extracts all artboards. Default: empty string 如果SaveMultipleArtboards为true(仅适用于Illustrator 13或更早版本),则该文档被视为多资产提取目标,并指定一个画板范围。空字符串表示提取所有画板。默认值:空字符串 |
Compatibility | AiCompatibility | Version of the Illustrator file format to create. Default: 24’ aiIllustrator24 指定要创建的Illustrator文件格式版本。默认值:24’ aiIllustrator24 |
Compressed | Boolean | (Illustrator version 10 or later) If true, the saved file is compressed. Default: true (Illustrator版本10或更高)如果为true,则保存的文件将被压缩。默认值:true |
EmbedICCProfile | Boolean | If true, an ICC profile is embedded in the saved file. 如果为true,则在保存的文件中嵌入ICC色彩配置文件。 |
EmbedLinkedFiles | Boolean | If true, linked image files are included in the saved document (only valid for SaveOptions that specify an Illustrator compatibility of version 7 or later). 如果为true,则链接的图像文件将包含在保存的文档中(仅适用于指定Illustrator兼容性版本7或更高版本的SaveOptions)。 |
FlattenOutput | AiOutputFlattening | Specifies how transparency is flattened for file formats older than Illustrator 9. 为比Illustrator 9版本更旧的文件格式指定如何展平透明度。 |
FontSubsetThreshold | Double | Include a subset of fonts when less than this percentage of characters is used in the document (valid for Illustrator 9 or newer file format). 当文档中使用字符的比例低于此百分比时,将包含字体子集(适用于Illustrator 9或更新版本的文件格式)。 |
PDFCompatible | Boolean | If true, save as a PDF compatible file (version 10 or later). Default: true 如果为true,则以PDF兼容文件格式保存(适用于版本10或更高)。默认值:true |
SaveMultipleArtboards | boolean | If true, all artboards or range of the artboards are saved. Valid for Illustrator 13 or earlier. 如果为true,则保存所有画板或指定范围内的一系列画板。有效于Illustrator 13及更早版本。 |
Saving to Illustrator 8 format
This example illustrates how to save the frontmost document as Illustrator 8 format. Because the document is saved as a version earlier than 9, the example specifies how to convert opacity by breaking paths up into sub-paths to preserve the appearance of the illustration.
'Saves current document in Illustrator format to dest with certain options
'specified in the script, dest contains the full path and file name to save to
Sub exportfileToAi (dest)
Set appRef = CreateObject("Illustrator.Application")
Set saveOptions = CreateObject("Illustrator.IllustratorSaveOptions")
saveOptions.Compatibility = 8'aiIllustrator8
saveOptions.FlattenOutput = 1'aiPreserveAppearance
appRef.Documents(1).SaveAs dest, saveOptions
End Sub
page 98
ImageCaptureOptions
Options for image capture, used with the ImageCapture method. All properties are optional.
这些属性是在使用Illustrator等图形编辑软件中的ImageCapture方法时,可选的图像捕获选项。在调用该方法以导出或抓取画板内容为图像文件时,可以根据需要设置以下参数:
ImageCaptureOptions properties
Property | Value type | What it is |
---|---|---|
AntiAliasing | Boolean | If true, the image result is anti-aliased. Default: false 如果为true,则生成的图像结果进行抗锯齿处理。默认值:false |
Application | Application | Read-only. The Illustrator Application object. 只读。指向Illustrator应用程序自身的对象,提供对整个应用程序的访问权限。 |
Matte | Boolean | If true, the artboard is matted with a color. Default: false 如果为true,则使用颜色为画板添加边框或衬底(即马特效果)。默认值:false |
MatteColor | RGBColor | The color to use for the artboard matte. Default: white 用于画板马特效果的颜色,默认情况下是白色。 |
Resolution | Double | The resolution of the captured image file in points-per-inch (PPI), in the range 72.0 to 2400.0. Default: 150 捕获图像文件的分辨率,单位为每英寸点数(PPI),范围在72.0到2400.0之间。默认值:150 |
Transparency | Boolean | If true, the image result is transparent. Default: false 如果为true,则生成的图像结果包含透明度信息。默认值:false |
CHAPTER 1: VBScript Object Reference
page 99
Ink
Provides information about the ink name and related information.
提供有关油墨名称及其相关信息的信息。
Ink properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。指向Adobe Illustrator应用程序自身的对象,提供对整个应用程序功能的访问权限。 |
InkInfo | InkInfo | The ink information. 包含有关特定墨水详细信息的对象,包括但不限于其化学成分、颜色特性以及在印刷流程中的使用方式等。 |
Name | String | The ink’s name. 墨水的名称,通常是一个标识符或标签,用于区别不同的墨水种类,如Pantone色号、CMYK四色组合或特殊效果墨水的名称。 |
page 100
InkInfo
Specifies ink properties.
InkInfo properties
Property | Value type | What it is |
---|---|---|
Angle | Double | The ink’s screen angle in degrees. Range: -360 to 360 油墨的网点角度,单位为度。范围:-360至360 |
Application | Application | Read-only. The Illustrator Application object. 只读。指向Illustrator应用程序本身的对象,提供对整个应用程序功能的访问权限。 |
CustomColor | Object | The color of the custom ink. 表示自定义油墨的颜色信息。 |
Density | Double | The neutral density. Minimum: 0.0 中性灰密度,最小值为0.0。 |
DotShape | String | The dot shape name. 网点形状的名称。 |
Frequency | Double | The ink’s frequency. Range: 0.0 to 1000.0 油墨的网点频率,范围:0.0至1000.0。 |
Kind | AiInkType | The ink type. 油墨的类型,例如CMYK、专色或其他类型。 |
PrintingStatus | AiInkPrintStatus | The ink printing status. 油墨的打印状态,如已启用、禁用等。 |
Trapping | AiTrappingType | The trapping type. 该油墨所采用的陷印类型,用于解决印刷过程中不同颜色油墨交接处可能出现的问题。 |
TrappingOrder | Long | The order of trapping for the ink. Range: 1 to 4 for CMYK 当应用于CMYK油墨时,该油墨在陷印处理中的顺序,范围是从1到4分别对应C、M、Y、K四色。 |
List inks in a document
'Gets the details of each ink in this document
'and displays them in a text frame
Set appRef = CreateObject("Illustrator.Application")
'create a new document and simple text frame
Set docRef = appRef.Documents.Add()
Set textRef = docRef.TextFrames.Add()
textRef.Top = docRef.Height - 100
textRef.Left = 100
'collect data from each Ink and InkInfo object
For Each inkRef In appRef.ActiveDocument.InkList
sInks = sInks & inkRef.Name
sInks = sInks & vbCrLf & vbTab
sInks = sInks & "Frequency = " & inkRef.InkInfo.Frequency
sInks = sInks & vbCrLf & vbTab
sInks = sInks & "Density = " & inkRef.InkInfo.Density
sInks = sInks & vbCrLf
Next
textRef.Contents = sInks
appRef.Redraw
page 102
InsertionPoint
A location between characters, used to insert new text objects. An insertion point is contained in an InsertionPoints collection.
插入点位于两个字符之间,可用于添加新的文本元素。这样的插入点被包含在一个InsertionPoints集合内。
InsertionPoint properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。指向Adobe Illustrator应用程序本身的对象,允许访问和控制整个应用程序的功能。 |
Characters | Characters | Read-only. All of the characters in the text range. 只读。该文本范围内的所有单个字符的集合。 |
Lines | Lines | Read-only. All the lines in this text range. 只读。该文本范围内包含的所有文本行的集合。 |
Paragraphs | Paragraphs | Read-only. All of the paragraphs in this text range. 只读。该文本范围内所有段落的集合。 |
Parent | Object | Read-only. The object’s container. 只读。此对象所处的容器对象。 |
Story | Story | Read-only. The story of the text range. 只读。与该文本范围相关的文本故事(文本框或文章)。 |
TextRanges | TextRanges | Read-only. All of the text in this text range. 只读。该文本范围内的所有文本子集的集合。可以通过创建新的文本范围来进一步细分文本内容。 |
Words | Words | Read-only. All of the words in this text range. 只读。该文本范围内所有单词的集合。 |
page 103
InsertionPoints
A collection of InsertionPoint objects.
InsertionPoints properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。指向Adobe Illustrator应用程序本身的对象,允许访问和控制整个应用程序的功能。 |
Count | Long | Read-only. Number of elements in the collection. 只读。集合中元素的数量。 |
Parent | TextFrame | Read-only. The object’s container. 只读。该对象所处的容器对象,即包含此对象的文本框。 |
InsertionPoints methods
Method | Returns | What it does |
---|---|---|
Index(itemPtr as TextRange) | Long | Returns the index position of the object within the collection. 通过给定的TextRange对象返回该对象在集合中的索引位置。 |
Item(itemKey) | InsertionPoint | Gets an element from the collection by itemKey (name or index). 根据itemKey(名称或索引)从集合中获取一个元素,这里返回的是InsertionPoint对象。 |
Using insertion point to add spaces
'Creates a new document, adds a text frame then
'uses insertion points to add a space between all characters
Set appRef = CreateObject("Illustrator.Application")
'create a new document and text frame
Set docRef = appRef.Documents.Add()
Set textRef = docRef.TextFrames.Add()
textRef.Contents = "Wouldn't you rather be scripting?"
textRef.Top = 400
textRef.Left = 100
textRef.TextRange.CharacterAttributes.Size = 20
appRef.Redraw
i = 2
Do While (i < textRef.InsertionPoints.Count)
textRef.InsertionPoints(i).Characters.Add (" ")
i = i + 2
Loop
page 104
LabColor
A color specification in the CIE Lab color space, used where a color info object is required.
LabColor properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。指向Adobe Illustrator应用程序本身的对象,允许访问和控制整个应用程序的功能。 |
A | Double | The a (red-green) color value. Range -128.0–128.0. Default: 0.0 代表颜色的a(红-绿)分量值。范围在-128.0至128.0之间,默认值为0.0。 |
B | Double | The b (yellow-blue) color value. Range -128.0–128.0. Default: 0.0 代表颜色的b(黄-蓝)分量值。范围同样在-128.0至128.0之间,默认值为0.0。 |
L | Double | The l (lightness) color value. Range -128.0–128.0. Default: 0.0 代表颜色的亮度(lightness)值。范围同样在-128.0至128.0之间,默认值为0.0。 |
page 105
Layer
A layer in an Illustrator document. Layers may contain nested layers, which are called sublayers in the user interface.
在Illustrator文档中,图层可以包含嵌套的图层,这些在用户界面中被称为子图层。
Layer object contains all of the page items in the layer as elements. Your script can access PageItems as elements of either the Layer object or as elements of the Document object. Only those page items in that layer can be accessed through the Layer object. To see page items in different layers, access them through the document.
Layer对象包含了该图层中的所有页面项目作为元素。在编写脚本时,你可以通过Layer对象或Document对象来访问PageItems作为其元素。只有位于该图层内的页面项目才能通过Layer对象进行访问。若要查看不同图层中的页面项目,则需要通过Document对象来获取它们。
Layer properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。指向Adobe Illustrator应用程序自身的对象,用于访问和控制整个应用程序的功能。 |
ArtworkKnockout | AiKnockoutState | Is this Layer used to create a knockout, and if so, what kind. 指示该图层是否被用作镂空效果的一部分,如果是的话,是哪种类型的镂空效果。 |
BlendingMode | AiBlendModes | The mode used when compositing an object. 在组合对象时所采用的混合模式。 |
Color | RGBColor | The Layer’s selection mark color. 该图层的选择标记颜色。 |
CompoundPathItems | CompoundPathItems | Read-only. The CompoundPathItems contained in this layer. 只读。该图层中包含的所有复合路径项目的集合。 |
DimPlacedImages | Boolean | If true, placed images are rendered as dimmed in this layer. 如果为真,则此图层中的置入图像将以淡化形式显示。 |
GraphItems | GraphItems | Read-only. The GraphItems collection contained in this layer. 只读。该图层中包含的所有图形项目的集合。 |
GroupItems | GroupItems | Read-only. The GroupItems contained in this layer. 只读。该图层中包含的所有组项目的集合。 |
HasSelectedArtwork | Boolean | If true, an object in this Layer has been selected; setting this property to false deselects all objects in the layer. 如果为真,则表示此图层中有对象被选中;将此属性设置为false则会取消选中该图层内所有对象。 |
IsIsolated | Boolean | If true, this Layer is isolated. 如果为真,则表示此图层已被隔离。 |
Layers | Layers | Read-only. The Layers contained in this layer. 只读。该图层中嵌套的子图层集合。 |
LegacyTextItems | LegacyTextItems | Read-only. The legacy text items contained in this layer. 只读。该图层中包含的所有遗留文本项目的集合。 |
Locked | Boolean | If true, this layer is editable. 如果为真,则表示此图层被锁定,不可编辑。 |
MeshItems | MeshItems | Read-only. The MeshItems contained in this layer. 只读。该图层中包含的所有网格项目的集合。 |
Name | String | The name of this layer. 该图层的名称。 |
NonNativeItems | NonNativeItems | The non-native art items in this layer. 该图层中包含的所有非原生艺术项目的集合(如导入的SVG或PDF内容)。 |
Opacity | Double | The opacity of the layer. Range: 0.0 to 100.0 图层的不透明度。范围:0.0到100.0,其中100.0代表完全不透明。 |
PageItems | PageItems | Read-only. The PageItems contained in this layer. 只读。该图层中包含的所有页面项目的集合。 |
Parent | Document or Layer | Read-only. The document or Layer that contains this layer. 只读。包含此图层的父级文档或图层。 |
PathItems | PathItems | Read-only. The PathItems contained in this layer. 只读。该图层中包含的所有路径项目的集合。 |
PlacedItems | PlacedItems | Read-only. The PlacedItems contained in this layer. 只读。该图层中包含的所有置入(如图片)项目的集合。 |
PluginItems | PluginItems | Read-only. The PluginItems contained in this layer. 只读。该图层中包含的由插件生成的项目的集合。 |
Preview | Boolean | If true, this layer is displayed using preview mode. 如果为真,则表示此图层在预览模式下显示。 |
Printable | Boolean | If true, this layer is printed when printing the document. 如果为真,则表示打印文档时会打印出这个图层的内容。 |
RasterItems | RasterItems | Read-only. The RasterItems contained in this layer. 只读。该图层中包含的所有栅格图像项目的集合。 |
Sliced | Boolean | If true, this layer is sliced. 如果为真,则表示此图层已被切片处理。 |
SymbolItems | SymbolItems | Read-only. The SymbolItems contained in this layer. 只读。该图层中包含的所有符号项目的集合。 |
TextFrames | TextFrames | Read-only. The TextFrames contained in this layer. 只读。该图层中包含的所有文本框对象的集合。 |
Visible | Boolean | If true, this layer is visible. 如果为真,则表示此图层可见;否则,将被隐藏。 |
ZOrderPosition | Long | Read-only. The position of this layer within the stacking order of Layers in the document 只读。表示此图层在文档内所有图层层叠顺序中的位置。 |
Layer methods
Method | Returns | What it does |
---|---|---|
Delete() | Nothing | Deletes the object. 删除该图层对象。 |
Move(relativeObject as Object,insertionLocation as AiElementPlacement) | Nothing | Moves the art item, specifying the new location and position.Does not change the position of the object on the art board, but changes the order in which Illustrator draws the objects, and the containment hierarchy. Places the object in the specified container, behind all other such objects. 移动设计元素,指定新的位置和排列方式。此操作不会改变对象在画板上的物理位置,但会改变Illustrator绘制对象的顺序以及对象的包含层次结构。根据指定的插入位置将对象放置到相应的容器中,并将其置于所有同类对象之后。 |
Paste() | Nothing | Pastes the contents of the clipboard into the Layer; if the associated document is the frontmost then all pasted objects remain selected after the paste. 将剪贴板内容粘贴到图层上;如果关联的文档处于最前端,则粘贴后所有新粘贴的对象仍保持选中状态。 |
ZOrder(zOrderCmd as AiZOrderMethod) | Nothing | Arranges the Layer’s position in the stacking order of Layers in this document 按照指定的方式调整该图层在当前文档内所有图层层叠顺序中的位置。其中zOrderCmd参数是AiZOrderMethod类型,可以用来指定将图层前置、后置、置顶或置底等操作。 |
Count layers in a document
'Counts the number of layers in the current document
'and stores in countOfLayers
Set appRef = CreateObject("Illustrator.Application")
'Get a reference to the layers, and obtain the total number
Set frontDocument = appRef.ActiveDocument
countOfLayers = frontDocument.Layers.Count
page 108
Layers
A collection of Layer objects.
Layers properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。表示当前层所属的Adobe Illustrator应用程序对象,可以访问和控制整个应用程序的功能。 |
Count | Long | Read-only. The number of objects in the collection. 只读。表示集合中包含的对象数量,即该层级下的子元素个数。 |
Parent | Object | Read-only. The object that contains this Layer (can be another Layer). 只读。表示包含此图层的对象,可能是另一个图层或者是文档等容器对象,即父级层或顶层容器。 |
Layers methods
Method | Returns | What it does |
---|---|---|
Add() | Layer | Creates a new object. 创建并返回一个新的图层对象。调用此方法后,新创建的图层会添加到当前集合中。 |
Index(item as Layer) | Long | Returns the index position of the object within the collection. 返回指定图层在当前集合中的索引位置。给定一个图层作为参数,该方法将查找该图层在集合中的顺序位置,并以数字形式返回其索引值。 |
RemoveAll() | Nothing | Deletes all objects in this collection. 删除当前集合内的所有图层对象,清空整个集合。调用此方法后,当前集合下所有的图层都将被移除。 |
Deleting layers
'Deletes all layers containing a specified string in their name
Set appRef = CreateObject("Illustrator.Application")
searchString = "Temp"
'Loop through all open documents
layersDeleted = 0
For Each targetDocument In appRef.Documents
countOfLayers = targetDocument.Layers.Count
'Go through layers from the back to avoid changing the
'index of unvisited layers when we remove a layer
For layerIndex = countOfLayers To 1 Step -1
Set targetLayer = targetDocument.Layers(layerIndex)
layerName = targetLayer.Name
If (InStr(layerName, searchString) = 1) Then
targetDocument.Layers.Remove targetLayer
layersDeleted = layersDeleted + 1
End If
Next
Next
page 109
LegacyTextItem
A text object created in Illustrator CS (version 10) or earlier, which is uneditable until converted. To convert legacy text, see ConvertToNative.
在Illustrator CS(版本10)或更早版本中创建的文本对象,在转换之前是不可编辑的。要转换旧版文本,请参考“ConvertToNative”方法。
You can view, move, and print legacy text, but you cannot edit it. Legacy text has an “x” through its bounding box when selected.
您可以查看、移动和打印旧版文本,但不能对其进行编辑。当旧版文本被选中时,其边框框内会有个“x”标识。
LegacyTextItem properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。表示该LegacyTextItem所属的Adobe Illustrator应用程序对象,提供了对整个Illustrator应用进行控制和访问的功能。 |
ArtworkKnockout | AiKnockoutState | Is this object used to create a knockout, and if so, what kind. 指示此对象是否用于创建镂空效果,如果是,则表明是何种类型的镂空效果。 |
BlendingMode | AiBlendModes | The mode used when compositing an object. 在合成对象时所使用的混合模式,定义了对象与其他图层内容如何相互融合。 |
ControlBound | Variant Array of 4 Doubles | Read-only. The bounds of the object including stroke width and controls. 只读。包括描边宽度和控制点在内的对象边界范围。 |
Converted | Boolean | Read-only. If true, the legacy text has been updated to a native text frame item. 只读。如果为true,则表示已将旧版文本更新为原生文本框项目。 |
Editable | Boolean | Read-only. If true, this item is editable. 只读。如果为true,则表示该文本项可以被编辑。 |
GeometricBounds | Variant Array of 4 Doubles | Read-only. The bounds of the object excluding stroke width. 只读。不包括描边宽度的对象边界范围。 |
Height | Double | The height of the LegacyTextItem excluding stroke width, based on the GeometricBounds. LegacyTextItem的高度,不包括描边宽度,基于GeometricBounds计算得出。 |
Hidden | Boolean | If true, this object is hidden. 如果为true,则表示此对象处于隐藏状态。 |
IsIsolated | Boolean | If true, this object is isolated. 如果为true,则表示此对象被隔离显示。 |
Layer | Layer | Read-only. The layer to which this LegacyTextItem belongs. 只读。表示此LegacyTextItem所在的图层。 |
Left | Double | The position of the left side of the item (in points, measured from the left side of the page). 对象左边缘的位置(以点为单位,从页面左边开始测量)。 |
Locked | Boolean | If true, this LegacyTextItem is locked. 如果为true,则表示此LegacyTextItem被锁定,不可编辑或移动。 |
Name | String | The name of this LegacyTextItem. 此LegacyTextItem的名称。 |
Note | String | The note assigned to this LegacyTextItem. 分配给此LegacyTextItem的注释。 |
Opacity | Double | The opacity of the object. Range: 0.0 to 100.0 对象的不透明度,范围在0.0到100.0之间,其中100代表完全不透明。 |
Parent | Object | Read-only. The object that contains this LegacyTextItem. 只读。包含此LegacyTextItem的对象,可能是文档或其他容器对象。 |
Position | Variant Array of 2 Doubles | The position (in points) of the top left corner of the item in the format [x, y]. Does not include stroke weight. 对象左上角的位置,格式为[x, y],不包括描边宽度。单位为点。 |
Selected | Boolean | If true, this object is selected. 如果为true,则表示该对象已被选中。 |
Sliced | Boolean | If true, this LegacyTextItem is sliced. 如果为true,则表示此LegacyTextItem被切片处理。 |
Tags | Tags | Read-only. The tags contained in this LegacyTextItem. 只读。存储在该LegacyTextItem中的所有标签信息。 |
Top | Double | The top position of this LegacyTextItem. 此LegacyTextItem的顶部位置。 |
URL | String | The value of the Adobe URL tag assigned to this LegacyTextItem. 分配给此LegacyTextItem的Adobe URL标签值。 |
VisibilityVariable | Variable | The Variable bound to this LegacyTextItem. 与此LegacyTextItem绑定的可见性变量。 |
VisibleBounds | Variant Array of 4 Doubles | Read-only. The visible bounds of the LegacyTextItem including stroke width. 只读。包括描边宽度在内的LegacyTextItem可见边界范围。 |
Width | Double | The width of the LegacyTextItem excluding stroke width, based on the GeometricBounds. LegacyTextItem的宽度,不包括描边宽度,基于GeometricBounds计算得出。 |
WrapInside | Boolean | If true, the text frame object are wrapped inside this object. 如果为true,则文本框对象将被环绕在这个LegacyTextItem内部。 |
WrapOffset | Double | The offset to use when wrapping text around this object. 当环绕此LegacyTextItem排列文本时使用的偏移量。 |
Wrapped | Boolean | If true, wrap text frame objects around this object (text frame must be above the object). 如果为true,则允许文本框对象围绕此LegacyTextItem进行环绕排版(前提是文本框位于该LegacyTextItem上方)。 |
ZOrderPosition | Long | Read-only. The position of this art item within the stacking order of the group or layer (Parent) that contains the art item. 只读。指示此艺术项目在其所在的组或图层(Parent)内堆叠顺序中的位置索引。 |
LegacyTextItem methods
Method
Returns
What it does
ConvertToNative
()
GridRepea tConfig
Converts the legacy text item to a text frame and deletes the
original legacy text.
Copy
()
Nothing
Copies the legacy text item to the clipboard; the associated document must be the
frontmost document.
Cut
()
Nothing
Cuts the legacy text item to the clipboard; the associated
document must be the
frontmost document.
Duplicate
([relativeObject as Object],
[insertionLocation as AiElementPlacement])
Object
Duplicates the art item,
optionally specifying the
location and position for the
copy.
CHAPTER 1: VBScript Object Reference LegacyTextItem 111
Method
Returns
What it does
Delete
()
Nothing
Deletes the object.
Move
(relativeObject as Object,
insertionLocation as AiElementPlacement)
Nothing
Moves the art item, specifying the new location and position.
Resize
(scaleX as Double,
scaleY as Double
[, changePositions as Boolean]
[, changeFillPatterns as Boolean]
[, changeFillGradients as Boolean] [, changeStrokePattern as Boolean] [, changeLineWidths as Double]
[, scaleAbout as AiTransformation])
Nothing
Scales the art item where
scaleX is the horizontal scaling factor and scaleY is the vertical scaling factor; 100.0 = 100%
Rotate
(angle as Double,
[, changePositions as Boolean]
[, changeFillPatterns as Boolean]
[, changeFillGradients as Boolean]
[, changeStrokePattern as Boolean]
[, rotateAbout as AiTransformation])
Nothing
Rotates the art item relative to the current rotation. The object is rotated counter-clockwise if the Angle value is positive,
clockwise if the value is
negative.
Transform
(transformationMatrix as Matrix,
[, changePositions as Boolean]
[, changeFillPatterns as Boolean]
[, changeFillGradients as Boolean]
[, changeStrokePattern as Boolean]
[, changeLineWidths as Double]
[, transformAbout as AiTransformation])
Nothing
Transforms the art item by
applying a transformation
matrix.
Translate
([deltaX as Double]
[, deltaY as Double]
[, transformObjects as Boolean]
[, transformFillPatterns as Boolean]
[, transformFillGradients as Boolean]
[, transformStrokePatterns as Boolean])
Nothing
Repositions the art item relative to the current position, where deltaX is the horizontal offset and deltaY is the vertical offset.
ZOrder
(zOrderCmd as AiZOrderMethod)
Nothing
Arranges the art item’s position in the stacking order of the
group or layer (Parent) of this object.
CHAPTER 1: VBScript Object Reference
page 112
LegacyTextItems
A collection of LegacyText items.
LegacyTextItems properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. |
Count | Long | Read-only. Number of elements in the collection. |
Parent | Object | Read-only. The object’s container. |
LegacyTextItems methods
Method | Returns | What it does |
---|---|---|
ConvertToNative() | Boolean | Creates text frames from all legacy text items; the original legacy text items are deleted.Returns true if successful. |
Index(itemPtr as LegacyTextItem) | Long | Returns the index position of the object within the collection. |
Item(itemKey) | LegacyTextItem | Returns an object reference to the object identified by itemKey (name or index). |
RemoveAll() | Nothing | Deletes all objects in this collection. |
page 113
Lines
A collection of TextRange objects corresponding to a line of text.
Lines properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. |
Count | Long | Read-only. Number of elements in the collection. |
Parent | Object | Read-only. The object’s container. |
Lines methods
Method | Returns | What it does |
---|---|---|
Index(itemPtr as TextRange) | Long | Returns the index position of the object within the collection. |
Item(itemKey) | TextRange | Returns an object reference to the object identified by itemKey (name or index). |
RemoveAll() | Nothing | Deletes all objects in this collection. |
Counting lines
#Creates an area text item, adds some text, resizes
#the width of the path item containing the text item
#then counts the number of lines and stores in lineCount
#Create area text
textToPlace = "Scripting with Illustrator is fun and easy."
Set appRef = CreateObject("Illustrator.Application")
Set docRef = appRef.Documents.Add()
Set itemRef = docRef.PathItems.Rectangle(500, 200, 50, 300)
Set textRef = docRef.TextFrames.AreaText(itemRef)
textRef.Contents = textToPlace
appRef.Redraw
#Change the path's width and display line count
itemRef.Width = 300
lineCount = textRef.Lines.Count
appRef.Redraw
page 114
Matrix
A transformation matrix specification, used to transform the geometry of objects.
Matrices are used in conjunction with the Transform method and as a property of a number of objects. You can generate an original matrix using the Application methods getIdentityMatrix,getTranslationMatrix, getScaleMatrix, or getRotationMatrix. If you need to apply multiple transformations to objects, it is more efficient to use the matrix suite than to apply the transformations one at a time.
A Matrix is a record containing the matrix values, not a reference to a matrix object. The matrix commands listed above operate on the values of a matrix record. If a command modifies a matrix, a modified matrix record is returned as the result of the command. The original matrix record passed to the command is not modified.
Matrix properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。Illustrator应用程序对象,提供了对整个Illustrator应用的全局访问和控制功能。 |
MValueA | Double | Matrix property a. 矩阵属性a。在图形变换矩阵中代表水平缩放和平移的元素,通常与X轴坐标相关的缩放有关。 |
MValueB | Double | Matrix property b. 矩阵属性b。在二维图形变换矩阵中,用于表示旋转和剪切效果,影响垂直方向上的水平位移或倾斜。 |
MValueC | Double | Matrix property c. 矩阵属性c。同样在二维图形变换矩阵中,表示旋转和剪切效果,影响水平方向上的垂直位移或倾斜。 |
MValueD | Double | Matrix property d. 矩阵属性d。矩阵中的垂直缩放和平移元素,通常与Y轴坐标相关的缩放有关。 |
MValueTX | Double | Matrix property tx. 矩阵属性tx。在变换矩阵中代表沿X轴的平移量。 |
MValueTY | Double | Matrix property ty. 矩阵属性ty。在变换矩阵中代表沿Y轴的平移量。 |
Applying transformations with a matrix
#Creates a new translation and rotation matrix then
#applies it to all items in the current document
Set appRef = CreateObject("Illustrator.Application")
#Move art half an inch to the right and 1.5 inch up on the page
Set moveMatrix = appRef.GetTranslationMatrix(72 * 0.5, 72 * 1.5)
#Add a rotation to the translation -- 10 degrees counterclockwise
Set totalMatrix = appRef.ConcatenateRotationMatrix(moveMatrix, 10)
#Apply the transformation to all art in the document
For Each artItem In appRef.ActiveDocument.PageItems
artItem.Transform totalMatrix
Next
page 115
MeshItem
A gradient mesh art item. Mesh items cannot be created from a script, but can be copied and pasted.
MeshItem properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。Illustrator应用程序对象,提供了对整个Illustrator应用的访问和控制权限。 |
ArtworkKnockout | AiKnockoutState | Is this object used to create a knockout, and if so, what kind. 指示该对象是否用于创建镂空效果及其类型(例如,不透明度、剪切或普通镂空)。 |
BlendingMode | AiBlendModes | The mode used when compositing an object. 定义此对象与其他对象合成时使用的混合模式(如正常、溶解、正片叠底等)。 |
ControlBounds | Variant Array of 4 Doubles | Read-only. The bounds of the object including stroke width and controls. 只读。包括描边宽度和控制点在内的对象边界范围(左下角X、左下角Y、右上角X、右上角Y)。 |
Editable | Boolean | Read-only. If true, this MeshItem is editable. 只读。如果为真,则表示该网格项是可以编辑的。 |
GeometricBounds | Variant Array of 4 Doubles | Read-only. The bounds of the object excluding stroke width. 只读。排除描边宽度后对象本身的几何边界范围(左下角X、左下角Y、右上角X、右上角Y)。 |
Height | Double | The height of the MeshItem, based on the GeometricBounds. 基于几何边界的网格项高度。 |
Hidden | Boolean | If true, this MeshItem is hidden. 如果为真,则表示该网格项是隐藏的,不可见。 |
IsIsolated | Boolean | If true, this object is isolated. 如果为真,则表示此对象已被隔离,具有独立视图层。 |
Layer | Layer | Read-only. The Layer to which this MeshItem belongs. 只读。该网格项所属的图层。 |
Left | Double | The position of the left side of the item (in points, measured from the left side of the page). 项目左侧边缘的位置(以点为单位,从页面左边算起)。 |
Locked | Boolean | If true, this MeshItem is locked. 如果为真,则表示该网格项被锁定,无法编辑。 |
Name | String | The name of this MeshItem. 网格项的名称。 |
Note | String | The note assigned to this MeshItem. 分配给该网格项的注释文本。 |
Opacity | Double | The opacity of the object. Range 0.0 to 100.0 对象的不透明度百分比,范围在0.0到100.0之间。 |
Parent | object | Read-only. The object that contains this MeshItem. 只读。包含此网格项的对象。 |
Position | Variant Array of 2 Doubles | The position (in points) of the top left corner of the item in the format [x, y]. Does not include stroke weight. 项目的左上角位置(以点为单位,格式为[x, y]),不包括描边宽度。 |
Selected | Boolean | If true, this MeshItem is selected. 如果为真,则表示该网格项当前处于选中状态。 |
Sliced | Boolean | If true, this MeshItem is sliced. 如果为真,则表示该网格项已被切片处理,适用于输出至网页或其他交互媒体。 |
Tags | Tags | Read-only. The tags contained in this MeshItem. 只读。该网格项所包含的所有标签。 |
Top | Double | The position of the top of the item (in points,measured from the bottom of the page). 项目顶部边缘的位置(以点为单位,从页面底部向上计算)。 |
URL | String | The value of the Adobe URL tag assigned to this MeshItem. 分配给此网格项的Adobe URL标签值。 |
VisibilityVariable | Variant | The Variable bound to this MeshItem. 与此网格项绑定的变量,可能影响其可见性状态。 |
VisibleBounds | Variant Array of 4 Doubles | Read-only. The visible bounds of the MeshItem including stroke width. 只读。包括描边宽度在内的网格项可见边界范围。 |
Width | Double | The width of the MeshItem, based on the GeometricBounds. 基于几何边界的网格项宽度。 |
WrapInside | Boolean | If true, the text frame object are wrapped inside this object. 如果为真,则表示文字框内的文本将被包裹在这个对象内部。 |
WrapOffset | Double | The offset to use when wrapping text around this object. 当环绕此对象排列文本框对象时使用的偏移量。 |
Wrapped | Boolean | If true, wrap text frame objects around this object (text frame must be above the object). 如果为真,则表明文本框对象会绕着这个对象进行环绕排版(前提是文本框位于该对象之上)。 |
ZOrderPosition | Long | Read-only. The position of this art item within the stacking order of the group or layer (Parent) that contains the art item. 只读。此艺术项在其所在组或图层中的堆叠顺序位置。 |
MeshItem methods
Method | Returns | What it does |
---|---|---|
Copy() | Nothing | Copies the mesh item to the clipboard; the associated document must be the frontmost document. 复制网格项到剪贴板;关联文档必须是最前面的活动文档。 |
Cut() | Nothing | Cuts the mesh item to the clipboard; the associated document must be the frontmost document. 剪切网格项到剪贴板;关联文档必须是最前面的活动文档。 |
Delete() | Nothing | Deletes the object. 删除该对象。 |
Duplicate([relativeObject as Object],[insertionLocation as AiElementPlacement]) | Object | Duplicates the art item, optionally specifying the location and position for the copy. 复制艺术项,可选指定复制内容的位置和插入位置。 |
Move(relativeObject as Object,insertionLocation as AiElementPlacement) | Nothing | Moves the art item, specifying the new location and position. 移动艺术项至新位置,并指定其在新位置中的插入方式。 |
Resize(scaleX as Double,scaleY as Double,[, changePositions as Boolean][, changeFillPatterns as Boolean][, changeFillGradients as Boolean] [, changeStrokePattern as Boolean] [, changeLineWidths as Double][, scaleAbout as AiTransformation]) | Nothing | Scales the art item where scaleX is the horizontal scaling factor and scaleY is the vertical scaling factor; 100.0 = 100% 缩放艺术项,其中scaleX为水平缩放因子,scaleY为垂直缩放因子,100.0表示100%。可以同时选择是否改变元素的位置、填充图案、填充渐变、描边图案以及线宽,并可指定缩放中心点。 |
Rotate(angle as Double,[, changePositions as Boolean][, changeFillPatterns as Boolean][, changeFillGradients as Boolean][, changeStrokePattern as Boolean][, rotateAbout as AiTransformation]) | Nothing | Rotates the art item relative to the current rotation. The object is rotated counter-clockwise if the Angle value is positive, clockwise if the value is negative. 根据当前旋转角度旋转艺术项。若角度值为正,则逆时针旋转;若为负,则顺时针旋转。可以选择是否更改元素位置、填充图案、填充渐变及描边图案,并可指定旋转中心点。 |
Transform(transformationMatrix as Matrix,[, changePositions as Boolean][, changeFillPatterns as Boolean][, changeFillGradients as Boolean][, changeStrokePattern as Boolean][, changeLineWidths as Double][, transformAbout as AiTransformation]) | Nothing | Transforms the art item by applying a transformation matrix. 通过应用一个变换矩阵来转换艺术项。 |
Translate([deltaX as Double][, deltaY as Double][, transformObjects as Boolean][, transformFillPatterns as Boolean][, transformFillGradients as Boolean][, transformStrokePatterns as Boolean]) | Nothing | Repositions the art item relative to the current position, where deltaX is the horizontal offset and deltaY is the vertical offset. 相对于当前位置重新定位艺术项,其中deltaX是水平偏移量,deltaY是垂直偏移量。可以选择是否同时转换元素、填充图案、填充渐变及描边图案。 |
ZOrder(zOrderCmd as AiZOrderMethod) | Nothing | Arranges the art item’s position in the stacking order of the group or layer (Parent) of this object. 调整艺术项在其所在组或图层中的堆叠顺序(层级)。 |
Locking mesh items
#Locks all mesh items in the current document
Set appRef = CreateObject("Illustrator.Application")
For Each meshItem In appRef.ActiveDocument.MeshItems
meshItem.Locked = True
Next
page 118
MeshItems
A collection of gradient mesh art items.
MeshItems properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. |
Count | Long | Read-only. Number of elements in the collection. |
Parent | Object | Read-only. The object’s container. |
MeshItems methods
Method | Returns | What it does |
---|---|---|
Index(itemPtr as MeshItem) | Long | Returns the index position of the object within the collection. |
Item(itemKey) | MeshItem | Returns an object reference to the object identified by itemKey (name or index). |
RemoveAll() | Nothing | Deletes all objects in this collection. |
Copying mesh items between documents
To run this script, have two open documents:
b One document should contain at least one MeshItem.
b The other document can be empty. Make the empty document the frontmost before running the script.
#Copies all mesh items from one document
#to another, with an offset position
Set appRef = CreateObject("Illustrator.Application")
Set sourceDocument = appRef.Documents(1)
Set targetDocument = appRef.Documents.Add
locationOffset = 0
For Each meshItem In sourceDocument.MeshItems
sourceDocument.Activate
meshItem.Copy
targetDocument.Activate
targetDocument.Paste
#Get a reference to the item that was just copied into the document
targetSelection = appRef.selection
If (IsEmpty(targetSelection)) Then
Exit For
End If
Set newMeshItem = targetSelection(0)
newMeshItem.Position = Array(100, 400 + locationOffset)
locationOffset = locationOffset + 50
Next
page 120
NoColor
Represents the “none” color. Assignment of a reference to a NoColor object to the document’s default fill or stroke color, or those of an art item, is equivalent to setting their Filled or Stroked property to False.
NoColor properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. |
Removing a fill color
#Creates 2 overlapping, filled path items, then
#sets the top item to "NoColor" to make the bottom item visible.
Set appRef = CreateObject("Illustrator.Application")
Set docRef = appRef.Documents.Add()
Set itemRef1 = docRef.PathItems.Rectangle(500, 200, 200, 100)
Set itemRef2 = docRef.PathItems.Rectangle(550, 150, 200, 200)
Set colorRef = CreateObject("Illustrator.RGBColor")
colorRef.Blue = 255
itemRef1.FillColor = colorRef
colorRef.Red = 255
colorRef.Blue = 0
itemRef2.FillColor = colorRef
appRef.Redraw
#Create a nocolor object and assign it to the top object
Set noColorRef = CreateObject("Illustrator.NoColor")
itemRef2.FillColor = noColorRef
appRef.Redraw
page 121
NonNativeItem
A non-native artwork item.
NonNativeItem properties
This class inherits all properties of the page item class.
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。Illustrator应用程序对象,提供了对整个Illustrator应用的访问和控制权限。 |
ArtworkKnockout | AiKnockoutState | Indicates whether this object is used to create a knockout, and if so, what kind. 指示该对象是否被用来创建镂空效果及其类型(例如:不透明度、剪切或普通镂空)。 |
BlendingMode | AiBlendModes | The mode used when compositing an object. 定义此对象在合成时使用的混合模式(如正常、溶解、正片叠底等)。 |
ControlBounds | Variant Array of 4 Doubles | Read-only. The bounds of the object, including stroke width and controls. 只读。包含描边宽度及控制点在内的对象边界范围(左下角X坐标、左下角Y坐标、右上角X坐标、右上角Y坐标)。 |
Editable | Boolean | Read-only. If true, this object is editable. 只读。如果为true,则表示该对象是可编辑的。 |
GeometricBounds | Variant Array of 4 Doubles | Read-only. The bounds of the object, excluding stroke width. 只读。排除描边宽度后对象的实际几何边界范围(左下角X坐标、左下角Y坐标、右上角X坐标、右上角Y坐标)。 |
Height | Double | The height of the object, based on GeometricBounds. 基于GeometricBounds计算出的对象高度。 |
Hidden | Boolean | If true, this object is hidden. 如果为true,则表示该对象当前处于隐藏状态。 |
IsIsolated | Boolean | If true, this object is isolated. 如果为true,则表示该对象已隔离,拥有独立视图层。 |
Layer | Layer | Read-only. The layer to which this object belongs. 只读。该对象所属的图层。 |
Left | Double | The position of the left side of the item (in points, measured from the left side of the page). 项目左侧边缘的位置(以点为单位,从页面左边算起)。 |
Locked | Boolean | If true, this object is locked 如果为true,则表示该对象被锁定,不可编辑。 |
Name | String | The name of this object. 对象的名称。 |
Note | String | The note assigned to this object. 分配给该对象的注释文本。 |
Opacity | Double | The opacity of the object. Range: 0.0 to 100.0 对象的不透明度百分比,范围在0.0至100.0之间。 |
Parent | object | Read-only. The object that contains this object. 只读。包含此对象的父级容器对象。 |
Position | Variant Array of 2 Doubles | The position (in points) of the top left corner of the item in the format [x, y]. Does not include stroke weight. 项目的左上角位置(以点为单位,格式为[x, y]),不包括描边宽度。 |
Selected | Boolean | If true, this object is selected. 如果为true,则表示该对象当前已被选中。 |
Sliced | Boolean | If true, this object is sliced. 如果为true,则表示该对象已被切片处理,适用于网页或其他交互媒体输出。 |
Tags | Tags | Read-only. The tags contained in this object. 只读。该对象所包含的所有标签。 |
Top | Double | The position of the top of the item (in points, measured from the bottom of the page). 项目顶部边缘的位置(以点为单位,从页面底部向上计算)。 |
URL | String | The value of the Adobe URL tag assigned to this object. 分配给此对象的Adobe URL标签值。 |
VisibilityVariable | Variable | The Variable bound to this object. 与此对象绑定的变量,可能影响其可见性状态。 |
VisibleBounds | Variant Array of 4 Doubles | Read-only. The visible bounds of the object including stroke width. 只读。包括描边宽度在内的对象可见边界范围。 |
Width | Double | The width of the object, based on GeometricBounds. 基于GeometricBounds计算出的对象宽度。 |
WrapInside | Boolean | If true, the text frame object are wrapped inside this object. 如果为true,则表示文本框内的文本将被包裹在这个对象内部。 |
WrapOffset | Double | The offset to use when wrapping text around this object. 当环绕此对象排列文本框对象时使用的偏移量。 |
Wrapped | Boolean | If true, the text frame objects are wrapped around this object (text frame must be above the object). 如果为true,则表明文本框对象会绕着这个对象进行环绕排版(前提是文本框位于该对象之上)。 |
ZOrderPosition | Long | Read-only. The position of this art item within the stacking order of the group or layer (Parent) that contains the art item. 只读。此艺术项在其所在组或图层中的堆叠顺序位置。 |
NonNativeItem methods
Method | Returns | What it does |
---|---|---|
Copy() | Nothing | Copies the item to the clipboard;the associated document must be the frontmost document. 将对象复制到剪贴板,关联的文档必须是当前最前面的文档。 |
Cut() | Nothing | Cuts the item to the clipboard; the associated document must be the frontmost document. 将对象剪切到剪贴板,关联的文档必须是当前最前面的文档。 |
Delete() | Nothing | Deletes the object. 删除该对象。 |
Duplicate([relativeObject as Object],[insertionLocation as AiElementPlacement]) | Object | Duplicates the art item, optionally with the location and position for the copy. 复制艺术项目,并可以选择性地指定副本的位置和插入位置。 |
Move(relativeObject as Object,insertionLocation as AiElementPlacement) | Nothing | Moves the art item to a new location and position. 将艺术项目移动至新位置,并指定其在新位置中的插入方式。 |
Resize(scaleX as Double,scaleY as Double,[, changePositions as Boolean][, changeFillPatterns as Boolean][, changeFillGradients as Boolean] [, changeStrokePattern as Boolean] [, changeLineWidths as Double][, scaleAbout as AiTransformation]) | Nothing | Scales the art item where scaleX is the horizontal scaling factor and scaleY is the vertical scaling factor; 100.0 = 100% 按指定的水平缩放因子scaleX和垂直缩放因子scaleY缩放艺术项目;100.0表示100%缩放。可以同时选择是否改变元素的位置、填充图案、填充渐变、描边图案以及线宽,并可指定缩放中心点。 |
Rotate(angle as Double,[, changePositions as Boolean][, changeFillPatterns as Boolean][, changeFillGradients as Boolean][, changeStrokePattern as Boolean][, rotateAbout as AiTransformation]) | Nothing | Rotates the art item relative to the current rotation. The object is rotated counter-clockwise if the Angle value is positive, clockwise if the value is negative. 根据当前旋转角度相对地旋转艺术项目。若角度值为正,则逆时针旋转;若为负,则顺时针旋转。可以选择是否更改元素位置、填充图案、填充渐变及描边图案,并可指定旋转中心点。 |
Transform(transformationMatrix as Matrix,[, changePositions as Boolean][, changeFillPatterns as Boolean][, changeFillGradients as Boolean][, changeStrokePattern as Boolean][, changeLineWidths as Double][, transformAbout as AiTransformation]) | Nothing | Transforms the art item by applying a transformation matrix. 通过应用一个变换矩阵来转换艺术项目。 |
Translate([deltaX as Double][, deltaY as Double][, transformObjects as Boolean][, transformFillPatterns as Boolean][, transformFillGradients as Boolean][, transformStrokePatterns as Boolean]) | Nothing | Repositions the art item relative to the current position, where deltaX is the horizontal offset and deltaY is the vertical offset. 根据给定的水平偏移量deltaX和垂直偏移量deltaY相对于当前位置重新定位艺术项目。可以选择是否同时转换元素、填充图案、填充渐变及描边图案。 |
ZOrder(zOrderCmd as AiZOrderMethod) | Nothing | Arranges the art item’s position in the stacking order of the group or layer (Parent) of this object. 调整艺术项目在其所在组或图层(父级)中的堆叠顺序。 |
page 124
NonNativeItems
A collection of non-native items.
NonNativeItems properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. |
Count | Long | Read-only. The number of objects in the collection. |
Parent | Document | Read-only. The document that contains this object. |
NonNativeItems methods
Method | Returns | What it does |
---|---|---|
Index(item as GraphicStyle) | Long | Returns the index position of the object within the collection. |
Item(itemKey) | NonNativeItem | Returns an object reference to the object identified by itemKey (name or index). |
RemoveAll() | Nothing | Deletes all objects in this collection. |
page 125
OpenOptions
Options to use when opening files in Illustrator.
OpenOptions properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。Illustrator应用程序对象,提供对整个应用程序的访问和控制权。 |
ConvertCropAreaToArboard | boolean | Optional. Convert crop areas to artboards when opening a legacy document in Illustrator CS4 or later. When false, crop areas are discarded.Default: true. 可选。在Illustrator CS4或更高版本中打开旧版文档时,将裁剪区域转换为画板。当设置为false时,裁剪区域会被丢弃。默认值:true。 |
ConvertTilesToArboard | boolean | Optional. Convert print tiles to artboards when opening a legacy document in Illustrator CS4 or later. Default: false. 可选。在Illustrator CS4或更高版本中打开旧版文档时,将打印拼贴区域转换为画板。默认值:false。 |
CreateArtboardWithArtworkBoundingBox | boolean | Optional. Create an artboard with the dimensions of the bounding box of the artwork when opening a legacy document in llustrator CS4 or later. Default: false. 可选。在Illustrator CS4或更高版本中打开旧版文档时,根据作品的边界框尺寸创建一个画板。默认值:false。 |
OpenAs | AiLibraryType | Opens the file as an Illustrator library. 以Illustrator库的形式打开文件。 |
Parent | Document | Read-only. The document that contains this object. 只读。包含此对象的父级文档对象。 |
PreserveLegacyArtboard | boolean | Optional. Preserve legacy artboards when opening a legacy document in Illustrator CS4 or later. Default: true. 可选。在Illustrator CS4或更高版本中打开旧版文档时保留原有的画板布局。默认值:true。 |
UpdateLegacyGradientMesh | Boolean | If true, preserves the spot colors in the gradient mesh objects for legacy documents (pre-Illustrator CS4). Default: true 如果为true,则对于由Illustrator CS4之前的版本保存的旧版文档中的渐变网格对象,会保留专色信息。默认值:true。 |
UpdateLegacyText | Boolean | If true, updates all text objects for documents saved with legacy text by Illustrator versions previous to CS. Default: false 如果为true,则针对使用CS版本之前的老式文本格式保存的文档中的所有文本对象进行更新处理。默认值:false。 |
Opening a file and updating legacy text
This script assumes the file C:\temp\LegacyText.ai exists.
#Opens a file containing legacy text and updates the text automatically
#filePath contains the full path and file name of the file
Sub openOptions(filePath)
Set appRef = CreateObject("Illustrator.Application")
#Open a file with legacy text
Set optionsRef = CreateObject("Illustrator.OpenOptions")
optionsRef.UpdateLegacyText = True
Set docRef = appRef.Open(filePath, 1, optionsRef) # 1 = aiDocumentRGBColor
End Sub
page 127
PageItem
Any art item. Every art item and group in a document is a page item. You may refer to a page item as an element of a document, layer, or group item.
The PageItem class gives you complete access to every art item contained in an Illustrator document. The PageItem class is the superclass of all artwork objects in a document. The CompoundPathItem, GroupItem, MeshItem, PathItem, PlacedItem, PluginItem, RasterItem, and TextFrame classes each inherit a set of properties from the PageItem class.
You cannot create a PageItem directly, you must create one of the specific PageItem subclasses, such as PathItem.
PageItem properties
Property | Value type | What it is |
---|---|---|
ArtworkKnockout | AiKnockoutState | Indicates whether the artwork is used to create a knockout. 指示该艺术作品是否用于创建镂空效果。 |
BlendingMode | AiBlendModes | The mode to use when compositing this object. An object is considered composited when its opacity is set to less than 100.0 (100%). 设置此对象在合成时使用的模式。当对象的不透明度设置为小于100.0(即100%)时,认为该对象正在进行合成处理。 |
ControlBounds | Rect | Read-only. The bounds of the object including stroke width and controls. 只读。包括边框宽度和控制点在内的对象边界。 |
Editable | Boolean | Read-only. If true, this page item is editable. 只读。如果为 true,则表示此页面项目可编辑。 |
GeometricBounds | Rect | Read-only. The object’s bounds excluding the stroke width. 只读。不包括描边宽度的对象边界。 |
Height | Real | The height of the page item, calculated from the geometric bounds. Range: 0.0 to 16348.0 根据几何边界计算出的页面项的高度。范围:0.0 到 16348.0 |
Hidden | Boolean | If true, this page item is hidden. 如果为 true,则表示此页面项被隐藏。 |
IsIsolated | Boolean | If true, this object is isolated. 如果为 true,则表示此对象处于孤立状态。 |
Layer | Layer | Read-only. The layer to which this page item belongs. 只读。此页面项所属的图层。 |
Left | Double | The left position of the art item. 艺术项的左位置坐标。 |
Locked | Boolean | If true, this page item is locked. 如果为 true,则表示此页面项已被锁定。 |
Name | String | The name of this page item.此页面项的名称。 |
Note | String | The note assigned to this item. 分配给此项目的注释内容。 |
Opacity | Real | The opacity of this object, where 100.0 is completely opaque and 0.0 is completely transparent. 此对象的不透明度,其中 100.0 表示完全不透明,0.0 表示完全透明。 |
Position | Point | The position (in points) of the top left corner of the item in the format {x, y}. Does not include stroke weight. 以 {x, y} 格式表示的项目左上角的位置(单位为点)。不包含描边宽度。 |
PixelAligned | Boolean | True if this item is aligned to the pixel grid. 如果为 true,则表示该项目与像素网格对齐。 |
Selected | Boolean | If true, this object is selected. 如果为 true,则表示此对象被选中。 |
Sliced | Boolean | If true, preserve slices. 如果为 true,则保留切片信息。 |
Tags | Tags | The collection of tags associated with this page item. 与此页面项关联的标签集合。 |
Top | Double | The top position of the art item. 艺术项的顶部位置坐标。 |
URL | String | The value of the Adobe URL tag assigned to this page item. 分配给此页面项的 Adobe URL 标签值。 |
VisibilityVariable | Anything | The visibility variable to which this page item pathis bound. 与此页面项路径绑定的可见性变量。 |
VisibleBounds | Rect | Read-only. The object’s visible bounds, including stroke width of any objects in the illustration. 只读。包括插图中所有对象描边宽度在内的对象可见边界。 |
Width | Real | The width of the page item, calculated from the geometric bounds. Range: 0.0 to 16348.0 根据几何边界计算出的页面项的宽度。范围:0.0 到 16348.0 |
WrapInside | Boolean | If true, the text frame object should be wrapped inside this object. 如果为 true,则文本框架对象应该按照此对象内部进行环绕排版。 |
WrapOffset | Double | The offset to use when wrapping text around this object. 当围绕此对象排列文本框架对象时使用的偏移量。 |
Wrapped | Boolean | If true, wrap text frame objects around this object (text frame must be above the object). 如果为 true,则将文本框架对象(必须位于此对象上方)环绕在此对象周围。 |
ZOrderPosition | Long | Read-only. The drawing order of the art within its group or layer. 只读。在组或图层内,该图形元素的绘制顺序编号。 |
PageItem methods
Method | Returns | What it does |
---|---|---|
BringInPerspective(PositionX as Double,PositionY as Double,gridPlane as AiPerspectiveGridPlaneType) | Nothing | Places art object(s) in a perspective grid at a specified position and grid plane. 在指定位置和透视网格平面上放置艺术对象(或一组对象)。 |
Copy() | Nothing | Copies the selection to the clipboard. 将选中的内容复制到剪贴板。 |
Cut() | Nothing | Cuts the selection to the clipboard. 将选中的内容剪切到剪贴板。 |
Resize(scaleX as Double,scaleY as Double[,changePositions as Boolean][,changeFillPatterns as Boolean][,changeFillGradients as Boolean] [,changeStrokePattern as Boolean] [,changeLineWidths as Double][,scaleAbout as AiTransformation]) | Nothing | Scales art object(s). 按比例缩放艺术对象(或一组对象),可选择性地同时调整填充图案、填充渐变、描边图案以及线条宽度,并可以选择缩放的基准点。 |
Rotate(angle as Double[,changePositions as Boolean][,changeFillPatterns as Boolean][,changeFillGradients as Boolean][,changeStrokePattern as Boolean][,rotateAbout as AiTransformation]) | Nothing | Rotates art object(s). 旋转艺术对象(或一组对象),可以设置是否同步更改位置、填充图案、填充渐变和描边图案,同时可以指定旋转的基准点。 |
Transform(transformationMatrix as Matrix[,changePositions as Boolean][,changeFillPatterns as Boolean][,changeFillGradients as Boolean][,changeStrokePattern as Boolean][,changeLineWidth as Double][,transformAbout as AiTransformation]) | Nothing | Transforms art object(s) using a transformation matrix. 使用变换矩阵对艺术对象(或一组对象)进行变形操作,可以控制是否同时改变位置、填充图案、填充渐变、描边图案及线条宽度,也可以指定变形的基准点。 |
Translate([deltaX as Double][,deltaY as Double][,transformObjects as Boolean][,transformFillPatterns as Boolean][,transformFillGradents as Boolean][,transformStrokePattern as Boolean]) | Nothing | Repositions art object(s). 重新定位艺术对象(或一组对象),可以通过指定水平和垂直位移量,并可选择是否同时移动关联的填充图案、填充渐变和描边图案。 |
ZOrder(zOrderCmd as AiZOrderMethod) | Nothing | Arranges the art relative to other art in the group or layer. 根据指定的顺序命令调整艺术对象在组或图层中相对于其他艺术对象的前后顺序。 |
page 130
PageItems
A collection of PageItem objects. Provides complete access to all the art items in an Illustrator document in the following classes:
CompoundPathItem
GraphItem
GroupItem
MeshItem
NonNativeItem
PathItem
PlacedItem
RasterItem
SymbolItem
TextFrame
You can reference page items through the PageItems property in a Document, Layer, or Group. When you access an individual item in one of these collections, the reference a page item of one of a particular type.
For example, if you use PageItems to reference a graphitem, the typename value of that object is GraphItem.
PageItems properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。表示当前对象所属的Adobe Illustrator应用程序对象,可以访问和控制整个Illustrator应用的功能。 |
Count | Long | Read-only. Number of elements in the collection. 只读。集合中元素的数量,即该容器内包含的对象个数。 |
Parent | Object | Read-only. The object’s container. 只读。当前对象的容器,即包含此对象的上级对象,可能是另一个对象、图层、文档等。 |
PageItems methods
Method | Returns | What it does |
---|---|---|
Index(itemPtr as PageItem) | Long | Returns the index position of the object within the collection. 传入一个PageItem对象引用作为参数,返回该对象在集合中的索引位置。 |
Item(itemKey) | Object | Returns an object reference to the object identified by itemKey (name or index). 根据给定的itemKey(名称或索引)返回该集合中对应的对象引用。 |
RemoveAll() | Nothing | Deletes all objects in this collection. 删除当前集合中的所有对象,清空整个集合内容。 |
Getting references to external files
Before running this script, open a document that contains one or more linked images.
'Gets the file references of all placed and raster items,
'then displays them in a new document
Set appRef = CreateObject("Illustrator.Application")
Dim fileReferences(9)
Set sourceDocument = appRef.ActiveDocument
index = 0
For Each artItem In sourceDocument.PageItems
Select Case TypeName(artItem)
Case "PlacedItem"
fileReferences(index) = artItem.File
index = index + 1
Case "RasterItem"
If (Not artItem.Embedded) Then
fileReferences(index) = artItem.File
index = index + 1
End If
End Select
If index = 10 Then
Exit For
End If
Next
'Write the file references to a new document
Set reportDocument = appRef.Documents.Add
Set fileNameText = reportDocument.TextFrames.Add
fileNameText.Position = Array(50, 520)
fileNameText.Contents = "File references in " &_
sourceDocument.Name & ":"
For counter = 0 To (index - 1)
Set fileNameText = reportDocument.TextFrames.Add
fileNameText.Position = Array(65, 500 - 20 * counter)
fileNameText.Contents = fileReferences(counter)
Next
Getting page items of particular types
'Sets all placed or raster page items to hidden
Set appRef = CreateObject("Illustrator.Application")
For Each artItem In appRef.ActiveDocument.PageItems
If (TypeName(artItem) = "PlacedItem" Or _
TypeName(artItem) = "RasterItem") Then
artItem.Hidden = True
End If
Next
CHAPTER 1: VBScript Object Reference
page 132
Paper
A container for information objects about the paper to be used for printing.
Paper properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。表示Illustrator应用程序自身的对象,可用于访问和操作整个Illustrator应用。 |
Name | String | The paper name. 纸张的名称,通常用于标识特定的预设纸张或用户自定义纸张名称。 |
PaperInfo | PaperInfo | The paper information. 包含关于纸张详细信息的对象,可能包括但不限于纸张尺寸(宽度、高度)、方向(纵向或横向)、边距等参数。 |
page 133
PaperInfo
Contains information about the dimensions and imageable area of the paper to be used for printing.
PaperInfo properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。表示Illustrator应用程序的对象,用于访问和操作整个Illustrator应用的功能。 |
CustomPaper | Boolean | If true, a custom paper is being used. 如果为true,则表示正在使用自定义纸张尺寸,而非预设纸张尺寸。 |
Height | Double | The paper’s height in points. 纸张的高度,单位为点(1点 = 1/72英寸)。 |
ImageableArea | Array of 4 Doubles | The imageable area. 可打印区域的坐标信息,通常包括左上角横坐标、左上角纵坐标、右下角横坐标以及右下角纵坐标,这四个值共同定义了在该纸张上可以进行图像打印或输出的范围。 |
Width | Double | The paper’s width in points. 纸张的宽度,单位为点(1点 = 1/72英寸)。 |
Using Paper and PaperInfo objects
#Creates a new document then displays the paper list of the first printer in a text
frame
Set appRef = CreateObject("Illustrator.Application")
#Add a new document with some simple artwork
#(Must be a printable artwork for use with Printer object.)
Set docRef = appRef.Documents.Add()
Set textRef = docRef.TextFrames.Add()
textRef.Top = 750
textRef.Left = 50
curPrinterList = appRef.PrinterList
If UBound(curPrinterList) < 1 Then
#exit
sText = "Empty PrinterList"
paragraphCount = 1
Else
#Get paper objects for first printer
Set printerRef = curPrinterList(1)
sText = printerRef.Name
sText = sText & " paper list:" & vbCrLf
#Display data about available paper types
paragraphCount = 2
paperSizeArray = printerRef.PrinterInfo.PaperSizes
If IsEmpty (paperSizeArray) Then
sText = sText & vbCrLf
paragraphCount = paragraphCount + 1
Else
For i = 0 To UBound(paperSizeArray) - 1
Set paperRef = paperSizeArray(i)
sText = sText & paperRef.Name & vbCrLf
sText = sText & vbTab & paperRef.PaperInfo.Width
sText = sText & " x " & paperRef.PaperInfo.Height & vbCrLf
paragraphCount = paragraphCount + 2
Next
End If
End If
textRef.Contents = sText
appRef.Redraw
page 135
ParagraphAttributes
Specifies the properties and attributes of a paragraph contained in a text frame.
NOTE: Paragraph attributes do not have default values, and are undefined until explicitly set.
ParagraphAttributes properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。表示Illustrator应用程序的对象,提供了对整个Illustrator应用的操作访问权限。 |
AutoLeadingAmount | Double | Auto leading amount (as a percentage). 自动行距量(以百分比形式表示)。 |
BunriKinshi | Boolean | If true, BunriKinshi is enabled. 如果为true,则启用了“禁断”功能(日语文本排版中的一项设置,通常用于控制某些字符组合之间的禁排规则)。 |
BurasagariType | AiBurasagariTypeEnum | The Burasagari type, which specifies whether punctuation is allowed to fall outside of the paragraph bounding box (not available when Kinsoku Shori is set to None). 表示标点符号是否允许超出段落边框的“下延”类型(当禁排规则设置为无时不可用)。 |
DesiredGlyphScaling | Double | The desired glyph scaling, expressed as a percentage of the default character width. Range: 50.0 to 200.0; at 100.0,the width of characters is not changed. 期望的字形缩放比例,以默认字符宽度的百分比表示。范围:50.0至200.0;在100.0时,字符宽度不会改变。 |
DesiredLetterSpacing | Double | Desired letter, spacing expressed as a percentage of the default kerning or tracking Range: -100.0 to 500.0; at 0, no space is added between letters; at 100.0, an entire space width is added between letters. 期望的字母间距,以默认字间距或跟踪的百分比表示。范围:-100.0至500.0;在0时,字母之间不添加额外空间;在100.0时,在字母之间添加一个全空格宽度的距离。 |
DesiredWordSpacing | Double | Desired word spacing, expressed as a percentage of the default space for the font. Range: 0.0 to 1000.0; at 100.00, no space is added between words. 期望的单词间距,以默认字体空格大小的百分比表示。范围:0.0至1000.0;在100.0时,单词之间不添加额外空间。 |
EveryLineComposer | Boolean | If true, the Every-line Composer is enabled. If false, the Single-line Composer is enabled. 如果为true,则启用“每行排列器”。如果为false,则启用“单行排列器”。 |
FirstLineIndent | Double | First line left indent (in points). 首行左缩进距离(单位为点)。 |
HyphenateCapitalizedWords | Boolean | If true, hyphenation is enabled for capitalized words. 如果为true,则启用了大写单词的连字符功能,即允许在大写单词中进行断字处理。 |
Hyphenation | Boolean | If true, hyphenation is enabled for the paragraph. 如果为true,则启用段落的断字功能。 |
HyphenationPreference | Double | Hyphenation preference scale for better spacing (0) or fewer hyphens (1).Range: 0.0 to 1.0 用于改善间距(0)或减少连字符数量(1)的断字偏好程度。范围:0.0至1.0 |
HyphenationZone | Double | The distance (in points) from the right edge of the paragraph that marks the part of the line where hyphenation is not allowed. Note: 0 allows all hyphenation. Valid only when EveryLineComposer is false. 从段落右侧边缘开始,表示不允许发生断字区域的距离(单位为点)。注意:设置为0允许所有断字。仅在EveryLineComposer为false时有效。 |
Justification | AiJustification | Paragraph justification. 段落对齐方式(如左对齐、居中、右对齐、两端对齐等)。 |
Kinsoku | String | The name of a Kinsoku Shori set (a set of characters which cannot be used to begin or end a line of Japanese text). 日语文本禁排规则集的名称(包含不能作为行首或行尾的字符集合)。 |
KinsokuOrder | AiKinsokuOrderEnum | The preferred Kinsoku order. 首选的禁排顺序。 |
KurikaeshiMojiShori | Boolean | If true, KurikaeshiMojiShori is enabled (controls how repeated characters are handled in Japanese text). 如果为true,则启用“重复文字处理”功能(控制日语文本中重复字符的处理方式)。 |
LeadingType | AiAutoLeadingType | The type of auto leading. 自动行距的类型。 |
LeftIndent | Double | The left indent (in points). 左缩进距离(单位为点)。 |
MaximumConsecutiveHyphens | Long | Maximum number of consecutive hyphenated lines. 连续断字的最大行数限制。 |
MaximumGlyphScaling | Double | Maximum glyph scaling, expressed as a percentage of the default character width. Range: 50.0 to 200.0; at 100.0, the width of characters is not changed.Note: Valid only for justified paragraphs. 最大字形缩放比例,以默认字符宽度的百分比表示。范围:50.0至200.0;在100.0时,字符宽度不变。注意:仅在两端对齐段落中有效。 |
MaximumLetterSpacing | Double | Maximum letter spacing, expressed as a percentage of the default kerning or tracking Range: -100.0 to 500.0; at 0, no space is added between letters; at 100.0, an entire space width is added between letters. Note: Valid only for justified paragraphs. 最大字母间距,以默认字间距或跟踪的百分比表示。范围:-100.0至500.0;在0时,字母之间不添加额外空间;在100.0时,在字母之间添加一个全空格宽度的距离。注意:仅在两端对齐段落中有效。 |
MaximumWordSpacing | Double | Maximum word spacing, expressed as a percentage of the default space for the font. Range: 0.0 to 1000.0; at 100.00, no space is added between words.Note: Valid only for justified paragraphs. 最大单词间距,以默认字体空格大小的百分比表示。范围:0.0至1000.0;在100.0时,单词之间不添加额外空间。注意:仅在两端对齐段落中有效。 |
MinimumAfterHyphen | Long | Minimum number of characters after a hyphen. 断字后至少需要的字符数。 |
MinimumBeforeHyphen | Long | Minimum number of characters before a hyphen. 断字前至少需要的字符数。 |
MinimumGlyphScaling | Double | Minimum glyph scaling, expressed as a percentage of the default character width. Range: 50.0 to 200.0; at 100.0,the width of characters is not changed.Note: Valid only for justified paragraphs. 最小字形缩放比例,以默认字符宽度的百分比表示。范围:50.0至200.0;在100.0时,字符宽度不变。注意:仅在两端对齐段落中有效。 |
MinimumHyphenatedWordSize | Long | Minimum number of characters for a word to be hyphenated. 允许断字的单词的最小字符数。 |
MinimumLetterSpacing | Double | Minimum letter spacing, expressed as a percentage of the default kerning or tracking Range: -100.0 to 500.0; at 0, no space is added between letters; at 100.0, an entire space width is added between letters. Note: Valid only for justified paragraphs. 最小字母间距,以默认字间距或跟踪的百分比表示。范围:-100.0至500.0;在0时,字母之间不添加额外空间;在100.0时,在字母之间添加一个全空格宽度的距离。注意:仅在两端对齐段落中有效。 |
MinimumWordSpacing | Double | Minimum word spacing, expressed as a percentage of the default space for the font. Range: 0.0 to 1000.0; at 100.00, no space is added between words.Note:Valid only for justified paragraphs. 最小单词间距,以默认字体空格大小的百分比表示。范围:0.0至1000.0;在100.0时,单词之间不添加额外空间。注意:仅在两端对齐段落中有效。 |
Mojikumi | String | The name of a predefined Mojikumi set for Japanese text composition. 预定义的日语文本排版设定集名称。 |
Parent | Object | Read-only. The object’s container. 只读。该对象所在的容器对象。 |
RightIndent | Double | Right indent of margin expressed in points. 右边距,以点为单位表示。 |
RomanHanging | Boolean | If true, Roman hanging punctuation is enabled. 如果为true,则启用罗马体悬挂标点符号功能。 |
SingleWordJustification | AiJustification | Single word justification. 单个单词的对齐方式。 |
SpaceAfter | Double | Spacing after paragraph (in points). 段落后间距(单位为点)。 |
SpaceBefore | Double | Spacing before paragraph (in points). 段落前间距(单位为点)。 |
TabStops | Array of SymmetryRepeatConfig | Tab stop settings, as TabStopInfo objects. 制表符停止位置设置,以TabStopInfo对象的形式存储。 |
Modifying paragraph attributes
#Creates a new document with an area text item
#containing 3 paragraphs then uses paragraph attributes
#to apply a different justification to each paragraph
Set appRef = CreateObject("Illustrator.Application")
#Create 3 new pararagraphs
Set docRef = appRef.Documents.Add()
Set pathRef = docRef.PathItems.Rectangle(600, 200, 200, 400)
Set textRef = docRef.TextFrames.AreaText(pathRef)
textRef.Paragraphs.Add ("Left justified paragraph.")
textRef.Paragraphs.Add ("Center justified paragraph.")
textRef.Paragraphs.Add ("Right justified paragraph.")
textRef.TextRange.CharacterAttributes.Size = 28
#Change the justification of each paragraph
#using the paragraph attributes object
textRef.Paragraphs(1).ParagraphAttributes.Justification = 1 #aiRight
textRef.Paragraphs(2).ParagraphAttributes.Justification = 2 #aiCenter
textRef.Paragraphs(3).ParagraphAttributes.Justification = 0 #aiLeft
page 139
Paragraphs
A collection of Paragraph objects.
Paragraphs properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. |
Count | Long | Read-only. Number of elements in the collection. |
Parent | Object | Read-only. The object’s container. |
Paragraphs methods
Method | Returns | What it does |
---|---|---|
Add(contents as String[, relativeObject as TextFrame][, insertionLocation as AiElementPlacement]) | TextRange | Adds a new paragraph with specified contents at the specified location in the document. If location is not specified, adds the paragraph to the containing text frame after the current text selection or insertion point. 在文档指定位置添加一个包含特定内容的新段落。如果不指定位置,则在当前文本选择或插入点之后的文本框中添加该段落。 |
AddBefore(contents as String) | TextRange | Adds a new paragraph with specified contents before the current selection or insertion point. 在当前选区或插入点之前添加一个包含特定内容的新段落。 |
Index(itemPtr as PageItem) | Long | Returns the index position of the object within the collection. 返回此集合内指定PageItem对象(页面项目)的索引位置。 |
Item(itemKey) | Object | Returns a reference to the object identified by itemKey (name or index). 通过itemKey(名称或索引)返回对集合内特定对象的引用。 |
RemoveAll() | Nothing | Deletes all objects in this collection. 删除此集合内的所有对象。 |
Counting paragraphs in a document
#Counts the number of paragraphs in the document and
#stores in numParagraphs
Set appRef = CreateObject("Illustrator.Application")
If appRef.Documents.Count > 0 Then
numParagraphs = 0
For Each curTextArt In appRef.ActiveDocument.TextFrames
Set curTextRange = curTextArt.TextRange
numParagraphs = numParagraphs + curTextRange.Paragraphs.Count
Next
End If
page 141
ParagraphStyle
Associates character and paragraph attributes with a style. The style object can be used to apply those attributes to the text in a TextFrame object.
ParagraphStyle properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。表示Illustrator应用程序的对象,用于访问和操作整个Illustrator应用的功能。 |
CharacterAttributes | CharacterAttributes | Read-only. The character properties for the text range. 只读。文本范围的字符属性,包含字体、大小、颜色、字距调整等与单个字符相关的所有设置信息。 |
Name | String | The ParagraphStyle’s name. 段落样式的名称,用于标识和引用特定的段落样式。 |
ParagraphAttributes | ParagraphAttributes | Read-only. The paragraph properties for the text range. 只读。文本范围的段落属性,包括对齐方式、缩进、行距、断字、禁排规则等与整个段落布局相关的所有设置信息。 |
Parent | Object | Read-only. The object’s container. 只读。该对象所在的容器对象,通常是包含此文本范围或段落样式的更高层级对象(如文档、页面或文本框架)。 |
ParagraphStyle methods
Method | Returns | What it does |
---|---|---|
ApplyTo(textFrame as TextFrame[, clearingOverrides as Boolean]) | Nothing | Applies the paragraph style to the text object. 将此段落样式应用到指定的文本框架对象。如果提供了clearingOverrides参数且其值为true,则在应用样式之前会清除文本框架内已存在的局部样式覆盖设置。 |
Delete() | Nothing | Deletes the object. 删除当前段落样式对象。一旦删除,该样式将不再可用,并从文档中移除所有以此样式设置的文本范围。 |
Creating and applying a paragraph style
#Creates 3 paragraphs with different attributes, creates
#a paragraph style and applies it to each paragraph
Set appRef = CreateObject("Illustrator.Application")
#Create 3 new pararagraphs
Set docRef = appRef.Documents.Add()
Set pathRef = docRef.PathItems.Rectangle(600, 200, 200, 400)
Set textRef = docRef.TextFrames.AreaText(pathRef)
textRef.Paragraphs.Add ("Left justified paragraph.")
textRef.Paragraphs.Add ("Center justified paragraph.")
textRef.Paragraphs.Add ("Right justified paragraph.")
textRef.TextRange.CharacterAttributes.Size = 28
#Change the justification of each paragraph
#using the paragraph attributes object
textRef.Paragraphs(1).ParagraphAttributes.Justification = 1 #aiRight
textRef.Paragraphs(2).ParagraphAttributes.Justification = 2 #aiCenter
textRef.Paragraphs(3).ParagraphAttributes.Justification = 0 #aiLeft
#Create a new paragraph style
Set paraStyle = docRef.ParagraphStyles.Add("LeftIndent")
#Add some paragraph attributes
paraStyle.ParagraphAttributes.Justification = 0 #aiLeft
paraStyle.ParagraphAttributes.FirstLineIndent = 10
For Each pg In textRef.Paragraphs
paraStyle.ApplyTo pg, True
Next
appRef.Redraw
page 143
ParagraphStyles
A collection of ParagraphStyle objects. See ParagraphStyle for an example.
ParagraphStyles properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. |
Count | Long | Read-only. Number of elements in the collection. |
Parent | Object | Read-only. The object’s container. |
ParagraphStyles methods
Method | Returns | What it does |
---|---|---|
Add(name as String) | ParagraphStyle | Creates a new ParagraphStyle object. |
Index(itemPtr as ParagraphStyle) | Long | Returns the index position of the object within the collection. |
Item(itemKey) | ParagraphStyle | Returns an object reference to the object identified by itemKey (name or index). |
RemoveAll() | Nothing | Deletes all objects in this collection. |
CHAPTER 1: VBScript Object Reference PathItem 144
page 144
PathItem
Art items such as those created using the Line, Rectangle, or Pen Tools. A path consists of path points that define its geometry. Path points are defined either as a PathPoint object or as an x-y page coordinate pair. The PathItem class gives you complete access to paths in Illustrator.
PathItem properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。Illustrator应用程序对象本身。 |
Area | Double | Read-only. The area of this path in square points. If the area is negative, the pathis wound counterclockwise. Self-intersecting paths can contain sub-areas that cancel each other out, which makes this value zero even though the path has apparent area. 只读。此路径的面积(以平方点为单位)。如果面积为负,则表示路径是逆时针方向闭合。自相交路径可能存在相互抵消的子区域,导致该值为零,即使路径在视觉上似乎有面积。 |
ArtworkKnockout | AiKnockoutState | Is this object used to create a knockout, and if so, what kind. 指示该对象是否用于创建剪切效果以及具体是何种类型的剪切效果。 |
BlendingMode | AiBlendModes | The mode used when compositing an object. 组合对象时使用的混合模式。 |
Clipping | Boolean | If true, this pathis to be used as a clipping path 如果为真,则表明这个路径将被用作剪切路径。 |
Closed | Boolean | If true, this pathis closed 如果为真,则表示路径是闭合的。 |
ControlBounds | Variant Array of 4 Doubles | Read-only. The bounds of the object including stroke width and controls. 只读。包括描边宽度和控制点在内的对象边界范围。 |
Editable | Boolean | Read-only. If true, this path item is editable. 只读。如果为真,则表示这个路径项是可以编辑的。 |
Evenodd | Boolean | If true, the even-odd rule is used to determine insideness. 如果为真,则使用“偶-奇”规则来确定路径内部区域。 |
FillColor | Color info | The fill color of the path. 路径的填充颜色。 |
Filled | Boolean | If true, the pathis filled. 如果为真,则表示路径已经被填充了颜色。 |
FillOverprint | Boolean | If true, the art beneath a filled object are overprinted. 如果为真,则表示在填充对象下的艺术品会被覆盖印刷。 |
GeometricBounds | Variant Array of 4 Doubles | Read-only. The bounds of the object excluding stroke width. 只读。不包括描边宽度的对象边界范围。 |
Guides | Boolean | If true, this pathis a guide object. 如果为真,则表示这是一个参考线对象。 |
Height | Double | The height of the path item, based on the GeometricBounds. 基于GeometricBounds计算出的路径项高度。 |
Hidden | Boolean | If true, this path item is hidden. 如果为真,则表示这个路径项目是隐藏的。 |
IsIsolated | Boolean | If true, this object is isolated. 如果为真,则表示该对象已被孤立。 |
Layer | Layer | Read-only. The Layer to which this path item belongs. 只读。此路径项所属的图层。 |
Left | Double | The position of the left side of the item (in points, measured from the left side of the page). 项目左侧位置(以点为单位,从页面左侧测量)。 |
Length | Double | Read-only. The length of this path (in points). 只读。此路径的长度(以点为单位)。 |
Locked | Boolean | If true, this path item is locked. 如果为真,则表示此路径项目已被锁定。 |
Name | String | The name of this path item. 此路径项的名称。 |
Note | String | The note text assigned to the path 分配给路径的注释文本 |
Opacity | Double | The opacity of the object. Range 0.0 to 100.0 对象的不透明度。范围为0.0到100.0(表示从完全透明到完全不透明) |
Parent | object | Read-only. The object that contains this path item. 只读。包含此路径项的对象。 |
PathPoints | PathPoints | Read-only. The path points contained in this path item. 只读。此路径项中包含的所有路径点。 |
Polarity | AiPolarityValues | The polarity of the path. 路径的极性。 |
Position | Variant Array of 2 Doubles | The position (in points) of the top left corner of the item in the format [x, y]. Does not include stroke weight. 项目左上角位置(以点为单位,格式为[x, y])。不包括描边宽度。 |
Resolution | Double | The resolution of the path in dots per inch. 路径的分辨率(每英寸点数)。 |
Selected | Boolean | If true, this path item is selected. 如果为真,则表示此路径项已被选中。 |
SelectedPathPoints | PathPoints | Read-only. All of the selected path points in the path. 只读。路径中所有被选中的路径点。 |
Sliced | Boolean | If true, this path item is sliced. 如果为真,则表示此路径项已切片。 |
StrokeCap | AiStrokeCap | The type of line capping. 线端类型的设置。 |
StrokeColor | Color info | The stroke color for the path. 路径的描边颜色。 |
Stroked | Boolean | If true, the pathis stroked. 如果为真,则表示该路径有描边效果。 |
StrokeDashes | Variant Array of Doubles | The lengths for dashes and gaps in dashed lines, starting with the first dash length, followed by the first gap length, and so on. Set to an empty list, [], for a solid line. 虚线段和间隙的长度列表,起始于第一条虚线段长度,接着是第一个间隙长度,以此类推。设置为空列表[]时为实线。 |
StrokeDashOffset | Double | The default distance into the dash pattern at which the pattern is started. 虚线模式开始的位置偏移量,默认距离进入虚线模式的起点。 |
StrokeJoin | AiStrokeJoin | Type of joints for the path. 路径连接点类型的设置。 |
StrokeMiterLimit | Double | When a default stroke join is set to mitered, this property specifies when the join will be converted to beveled (squared-off) by default. The default miter limit of 4 means that when the length ofþthe point reaches four times the stroke weight, the join switches from a miter join to a bevel join. A value of 1 specifies a bevel join. Range: 1 to 500 Default: 4 当默认的描边连接方式设为斜接时,此属性指定何时将连接方式转换为默认倒角(方角)。默认的斜接限制值4表示当尖角长度达到描边宽度的四倍时,连接方式会从斜接变为倒角。取值范围:1至500,默认值:4 |
StrokeOverprint | Boolean | If true, the art beneath a stroked object is overprinted. 如果为真,则表示在描边对象下的艺术品会被覆盖印刷。 |
StrokeWidth | Double | The width of the stroke (in points). 描边的宽度(以点为单位)。 |
Tags | Tags | Read-only. The tags contained in this path item. 只读。此路径项中包含的所有标签。 |
Top | Double | The position of the top of the item (in points, measured from the bottom of the page). 项目的顶部位置(以点为单位,自页面底部测量)。 |
URL | String | The value of the Adobe URL tag assigned to this path item. 分配给此路径项的Adobe URL标签的值。 |
VisibilityVariable | Variant | The Variable bound to this path item. 与该路径项关联的变量。 |
VisibleBounds | Variant Array of 4 Doubles | Read-only. The visible bounds of the path item including stroke width. 只读。包括描边宽度在内的路径项可见边界范围。 |
Width | Double | The width of the path item, based on the GeometricBounds. 基于GeometricBounds计算出的路径项宽度。 |
WrapInside | Boolean | If true, the text frame object is wrapped inside this object. 如果为真,则表示文本框对象被包裹在这个对象内部。 |
WrapOffset | Double | The offset to use when wrapping text around this object. 绕此对象排列文本时使用的偏移量。 |
Wrapped | Boolean | If true, wrap text frame objects around this object (text frame must be above the object). 如果为真,则表示将文本框对象环绕此对象排列(文本框必须位于该对象上方)。 |
ZOrderPosition | Long | Read-only. The position of this art item within the stacking order of the group or layer (Parent) that contains the art item. 只读。在包含此艺术项的组或图层(父级)堆叠顺序中,该艺术项的位置。 |
PathItem methods
Method | Returns | What it does |
---|---|---|
Copy() | Nothing | Copies the path item to the clipboard; the associated document must be the frontmost document. 将路径项复制到剪贴板;关联文档必须是前台最顶层文档。 |
Cut() | Nothing | Cuts the path item to the clipboard; the associated document must be the frontmost document. 将路径项剪切到剪贴板;关联文档必须是前台最顶层文档。 |
Delete() | Nothing | Deletes the object. 删除对象。 |
Duplicate([relativeObject as Object],[insertionLocation as AiElementPlacement]) | Object | Duplicates the art item, optionally with the location and position for the copy. 复制艺术项目,可选地指定副本的位置和位置。 |
Move(relativeObject as Object,insertionLocation as AiElementPlacement) | Nothing | Moves the art item to a new location and position. 将艺术项目移动到新位置和位置。 |
Resize(scaleX as Double,scaleY as Double,[, changePositions as Boolean][, changeFillPatterns as Boolean][, changeFillGradients as Boolean] [, changeStrokePattern as Boolean] [, changeLineWidths as Double][, scaleAbout as AiTransformation]) | Nothing | Scales the art item where scaleX is the horizontal scaling factor and scaleY is the vertical scaling factor; 100.0 = 100% 按比例缩放艺术项目,其中scaleX为水平缩放因子,scaleY为垂直缩放因子;100.0表示100%。可以同时选择是否改变位置、填充图案、填充渐变、描边图案以及线条宽度,并可自定义缩放基准点。 |
Rotate(angle as Double,[, changePositions as Boolean][, changeFillPatterns as Boolean][, changeFillGradients as Boolean][, changeStrokePattern as Boolean][, rotateAbout as AiTransformation]) | Nothing | Rotates the art item relative to the current rotation. The object is rotated counter-clockwise if the Angle value is positive, clockwise if the value is negative. 相对于当前旋转角度旋转艺术项目。如果Angle值为正,则逆时针旋转对象,若值为负,则顺时针旋转。可以选择是否改变位置、填充图案、填充渐变、描边图案,并可自定义旋转基准点。 |
SetEntirePath(pathSpecification as Array of [x, y] coordinate pairs) | Nothing | Sets the path using the specified array of (x,y) coordinate pairs for path points. 使用指定的(x,y)坐标对数组设置路径。 |
Transform(transformationMatrix as Matrix,[, changePositions as Boolean][, changeFillPatterns as Boolean][, changeFillGradients as Boolean][, changeStrokePattern as Boolean][, changeLineWidths as Double][, transformAbout as AiTransformation]) | Nothing | Transforms the art item by applying a transformation matrix. 通过应用指定的转换矩阵来变换艺术项目。可以选择是否同时改变对象的位置、填充图案、填充渐变、描边图案和线条宽度,还可以设置一个自定义的转换基准点。 |
Translate([deltaX as Double][, deltaY as Double][, transformObjects as Boolean][, transformFillPatterns as Boolean][, transformFillGradients as Boolean][, transformStrokePatterns as Boolean]) | Nothing | Repositions the art item relative to the current position, where deltaX is the horizontal offset and deltaY is the vertical offset. 根据当前位置重新定位艺术项目,其中deltaX表示水平偏移量,deltaY表示垂直偏移量。可以设定是否同时移动关联的对象、填充图案、填充渐变以及描边图案。 |
ZOrder(zOrderCmd as AiZOrderMethod) | Nothing | Arranges the art item’s position in the stacking order of the group or layer (Parent) of this object. 在当前艺术项目所属的组或图层(Parent)中调整其堆叠顺序,即在视觉上前后层次的位置。可以通过指定不同的AiZOrderMethod来实现前移、后移、置顶或置底等操作。 |
Setting attributes of a path
'Sets the fill color and stroke width of the first path item
Set appRef = CreateObject("Illustrator.Application")
Set frontDocument = appRef.ActiveDocument
Set firstPath = frontDocument.PathItems(1)
firstPath.Filled = True
firstPath.fillColor = frontDocument.Swatches(10).Color
firstPath.Stroked = True
firstPath.StrokeWidth = 5
Setting a path consisting of straight lines
The SetEntirePath method provides an extremely efficient way to create paths that consist of straight lines. This script illustrates the use of the method.
'Creates 10 lines in the document then adds them as a single path item.
Set appRef = CreateObject("Illustrator.Application")
Dim lineList(10)
For index = 0 To 10
lineList(index) = Array(index * 10 + 50, (index - 5) ^ 2 * 5 + 50)
Next
Set frontDocument = appRef.ActiveDocument
Set newPath = frontDocument.PathItems.Add
newPath.SetEntirePath(lineList)
page 149
PathItems
A collection of PathItem objects. The methods Ellipse, Polygon, Rectangle, RoundedRectangle, and Star allow you to create complex PathItems using straightforward parameters. Note that Rectangle,RoundedRectangle, and Ellipse take theY axis first (Top), then the X axis (Left). If you do not provide any parameters when calling these methods, default values are used.
PathItems properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. |
Count | Long | Read-only. Number of elements in the collection. |
Parent | Object | Read-only. The object’s container. |
PathItems methods
Method | Returns | What it does |
---|---|---|
Add() | PathItem | Creates a new PathItem object. 创建一个新的PathItem对象(路径项),通常为空的路径,需要进一步添加点或形状来定义具体路径。 |
Ellipse([top as Double][, left as Double][, width as Double][, height as Double][, reversed as Boolean][, inscribed as Boolean]) | PathItem | Creates a new PathItem in the shape of an ellipse using the supplied parameters. Defaults: Top: 100 pt.; Left: 100 pt.; Width: 50 pt.;Height: 100 pt.; Reversed: False 使用提供的参数创建一个椭圆形的新PathItem对象。默认参数:顶部位置(Top): 100 pt;左侧位置(Left): 100 pt;宽度(Width): 50 pt;高度(Height): 100 pt;是否逆时针绘制(Reversed): False。 |
Index(item as PathItem) | Long | Returns the index position of the object within the collection. 返回给定PathItem对象在集合中的索引位置。 |
Item(itemKey) | PathItem | Returns an object reference to the object identified by itemKey (name or index). 根据itemKey(可以是名称或索引)返回集合中对应的PathItem对象引用。 |
Polygon([centerX as Double][, centerY as Double][, radius as Double][, sides as Long][, reversed as Boolean]) | PathItem | Creates a new PathItem in the shape of a polygon using the supplied parameters.Defaults: CenterX: 200 pt.; CenterY: 300 pt.; Radius: 50 pt.; Sides: 8; Reversed: false 使用提供的参数创建一个多边形形状的新PathItem对象。默认参数:中心X坐标(CenterX): 200 pt;中心Y坐标(CenterY): 300 pt;半径(Radius): 50 pt;边数(Sides): 8;是否逆时针绘制(Reversed): false。 |
Rectangle([top as Double][, left as Double][, width as Double][, height as Double][, reversed as Boolean]) | PathItem | Creates a new PathItem in the shape of a rectangle using the supplied parameters. 使用提供的参数创建一个矩形形状的新PathItem对象。 |
RemoveAll() | Nothing | Deletes all objects in this collection. 删除当前集合中的所有PathItem对象,清空整个集合。 |
RoundedRectangle([top as Double][, left as Double][, width as Double][, height as Double][, horizontalRadius as Double][, verticalRadius as Double][, reversed as Boolean]) | PathItem | Creates a new PathItem in the shape of a rectangle with rounded corners using the supplied parameters. Defaults:HorizontalRadius: 15 pt.; VerticalRadius: 20 pt.; Reversed: False 根据提供的参数创建一个带有圆角的新矩形PathItem对象。默认参数:水平半径(HorizontalRadius): 15 pt;垂直半径(VerticalRadius): 20 pt;是否逆时针绘制(Reversed): False。 |
Star([centerX as Double][, centerY as Double][, radius as Double][, innerRadius as Double][, points as Long][, reversed as Boolean] ) | PathItem | Creates a new PathItem in the shape of a star using the supplied parameters. Defaults:CenterX: 200 pt.; CenterY: 300 pt.; Radius: 50 pt.; InnerRadius: 20 pt.; Points: 5; Reversed: False 使用提供的参数创建一个星形的新PathItem对象。默认参数:中心X坐标(CenterX): 200 pt;中心Y坐标(CenterY): 300 pt;外接圆半径(Radius): 50 pt;内接圆半径(InnerRadius): 20 pt;星形点数(Points): 5;是否逆时针绘制(Reversed): False。 |
Creating shapes
#Creates 5 new path items in the current document and
#applies a random graphic style to each item
Set appRef = CreateObject("Illustrator.Application")
Set frontDocument = appRef.Documents.Add()
#Create a new rectangle with
#top = 762.5, left side = 87.5, witdth = 425 and height = 75
Set newRectangle = frontDocument.PathItems.Rectangle(762.5,87.5,425.0,75.0)
#create new rounded rectangle
Set newRndRectangle =
frontDocument.PathItems.RoundedRectangle(637.5,87.5,425.0,75.0,20.0,10.0)
#create ellipse, 'reversed' is false, 'inscribed' is true
Set newEllipse = frontDocument.PathItems.Ellipse(512.5,87.5,425.0,75.0,false,true)
#create an 8 sided polygon
Set newOctagon = frontDocument.PathItems.Polygon(300.0,325.0,75.0,8)
#create a 4 pointed star
Set newStar = frontDocument.PathItems.Star(300.0,125.0,100.0,20.0,4)
For Each newItem in frontDocument.PathItems
Randomize
styleIndex = Int((frontDocument.GraphicStyles.Count) * Rnd + 1)
frontDocument.GraphicStyles(styleIndex).ApplyTo(newItem)
Next
page 151
PathPoint
A point on a specific path. Each path point is made up of an anchor point and a pair of handles, or control points.
PathPoint properties
Property | Value type | What it is |
---|---|---|
Anchor | Variant Array of 2 Doubles | The position of the anchor point. 锚点的位置坐标,即路径点在画布上的具体位置。 |
Application | Application | Read-only. The Illustrator Application object. 只读。指向整个Adobe Illustrator应用程序的对象,允许访问和控制Illustrator的所有全局功能。 |
LeftDirection | Variant Array of 2 Doubles | The position of this path point’s inward control point. 此路径点的内向控制点(贝塞尔曲线中的左控制点)的位置坐标。控制点用于定义路径曲线的弯曲程度。 |
Parent | Object | Read-only. The object that contains this PathPoint object. 只读。包含此PathPoint对象的父级容器对象,通常是指向包含该路径点的路径或图形对象。 |
PointType | AiPointType | The type of path point, either a curve or a corner. Any point can considered a corner point. Setting the type to a corner forces the left and right direction points to be on a straight line when the user attempts to modify them in the user interface. 路径点的类型,可以是曲线点或角点。设置为角点时,在用户界面中尝试修改它们时,会强制左右方向点位于同一直线上,从而创建直线段。 |
RightDirection | Variant Array of 2 Doubles | The position of this path point’s outward control point. 此路径点的外向控制点(贝塞尔曲线中的右控制点)的位置坐标。控制点同样用于定义路径曲线的形状。 |
Selected | AiPathPointSelection | Are points of this path point selected, and if so, which ones. 指示路径点是否被选中以及哪些部分被选中(如起点、终点或控制点)。 |
PathPoint methods
Method | Returns | What it does |
---|---|---|
Delete() | Nothing | Deletes the object. |
Shaping a path item by modifying a path point
#Changes the left and right path point directions of
#all but the last path point of frontmost path item
Set appRef = CreateObject("Illustrator.Application")
Set firstPath = appRef.ActiveDocument.PathItems(1)
countOfPoints = firstPath.PathPoints.Count
#Go through all PathPoints except the last one and set the
#left/right direction according to where the next point is
For index = 1 To (countOfPoints - 1)
Set currentPoint = firstPath.PathPoints(index)
Set nextPoint = firstPath.PathPoints(index + 1)
currentAnchorList = currentPoint.Anchor
nextAnchorList = nextPoint.Anchor
deltax = nextAnchorList(0) - currentAnchorList(0)
deltay = currentAnchorList(1) - nextAnchorList(1)
length = Sqr(deltax ^ 2 + deltay ^ 2)
currentPoint.LeftDirection = Array(currentAnchorList(0) - (50 * deltax / length),
currentAnchorList(1) - (50 * deltay / length))
currentPoint.RightDirection = Array(currentAnchorList(0) + (50 * deltax / length),
currentAnchorList(1) + (50 * deltay / length))
Next
page 153
PathPoints
A collection of PathPoint objects in a path.
PathPoints properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. |
Count | Long | Read-only. Number of elements in the collection. |
Parent | Object | Read-only. The object’s container. |
PathPoints methods
Method | Returns | What it does |
---|---|---|
Add() | PathPoint | Creates a new PathPoint object. |
Index(item as PathPoint) | Long | Returns the index position of the object within the collection. |
Item(itemKey) | PathPoint | Returns an object reference to the object identified by itemKey (name or index). |
RemoveAll() | Nothing | Deletes all objects in this collection. |
Adding a new path point
#Creates a new path point in the first path item
Set appRef = CreateObject("Illustrator.Application")
Set firstPath = appRef.ActiveDocument.PathItems(1)
Set newPoint = firstPath.PathPoints.Add
newPoint.Anchor = Array(75, 300)
newPoint.LeftDirection = Array(10, 280)
newPoint.RightDirection = Array(165, 330)
newPoint.PointType = 2
page 154
Pattern
An Illustrator pattern definition contained in a document. Patterns are shown in the Swatches palette. Each pattern is referenced by a PatternColor object, which defines the pattern’s appearance.
Pattern properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. |
Name | String | The pattern name. |
Parent | Document | Read-only. The document that contains this pattern. |
Pattern methods
Method | Returns | What it does |
---|---|---|
Delete() | Nothing | Deletes the object. |
Setting a fill color to a pattern
#Sets the default fill to pattern 1
Set appRef = CreateObject("Illustrator.Application")
Set frontDocument = appRef.Documents(1)
Set patternColor = CreateObject("Illustrator.PatternColor")
For Each swatchRef In appRef.ActiveDocument.Swatches
# Get the color object of the swatch
Set swatchColor = swatchRef.Color
# Only operate on patterns
If (swatchColor.TypeName = "PatternColor") Then
frontDocument.DefaultFilled = true
frontDocument.DefaultFillColor = swatchColor
End If
Next
page 155
PatternColor
A pattern color specification, used in conjunction with the Pattern property of the Color specification. Pattern colors are created using a reference to an existing pattern in the document. A matrix may be specified to further transform the pattern color.
PatternColor objects can be used in any property that takes a color info object, such as fillColor or strokeColor.
PatternColor properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。指向Adobe Illustrator应用程序对象,该对象提供了对整个Illustrator程序的全局访问和控制能力。 |
Matrix | Matrix | An additional transformation matrix to manipulate the prototype pattern. 附加变换矩阵 |
Pattern | Pattern | A reference to the pattern object to use in this color definition. 引用在此颜色定义中使用的图案对象,决定了填充图形时所使用的图案样式。 |
Reflect | Boolean | If true, the prototype is reflected before filling. 如果为真,则在填充前会先将原型图案进行镜像反射操作。 |
ReflectAngle | Double | The axis in degrees around which to reflect. 以度为单位指定用于反射的轴线角度,围绕此轴线进行反射。 |
Rotation | Double | The angle in degrees to rotate the prototype pattern before filling. 以度为单位指定在填充前需要旋转原型图案的角度。 |
ScaleFactor | Variant Array of 2 Doubles | The fraction to which to scale the prototype pattern before filling, represented as a point containing horizontal and vertical scaling percentages 表示水平和垂直缩放比例的点,用于在填充前按一定百分比缩放原型图案。 |
ShearAngle | Double | The angle in degrees by which to slant the shear. 以度为单位指定斜切的角度,即沿某方向对图案进行倾斜变形的程度。 |
ShearAxis | Double | The axis in degrees to shear relative to. 以度为单位指定相对其进行斜切的轴线角度,图案将沿着这个角度方向进行斜切变形。 |
ShiftAngle | Double | The angle in degrees to translate the unscaled prototype pattern before filling. 以度为单位指定在填充前未缩放的原型图案沿某一角度方向进行平移旋转的角度。 |
ShiftDistance | Double | The distance in points to which to translate the unscaled prototype pattern before filling. 以点为单位指定在填充前未缩放的原型图案沿某一特定方向平移的距离。 |
####Modifying a pattern
#Rotates each pattern in the swatch list 10 degrees
#then applies it to the first path item.
Set appRef = CreateObject("Illustrator.Application")
Set colorOfPattern = CreateObject("Illustrator.PatternColor")
Set frontPath = appRef.ActiveDocument.PathItems(1)
For Each swatchRef In appRef.ActiveDocument.Swatches
#Get the color object of the swatch
Set swatchColor = swatchRef.Color
#Only operate on patterns
If (swatchColor.TypeName = "PatternColor") Then
swatchColor.Rotation = 10
frontPath.filled = true
frontPath.fillColor = swatchColor
End If
Next
CHAPTER 1: VBScript Object Reference
page 157
Patterns
A collection of Pattern objects in a document.
Patterns properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. |
Count | Long | Read-only. Number of elements in the collection. |
Parent | Object | Read-only. The object’s container. |
Patterns methods
Method | Returns | What it does |
---|---|---|
Add() | Pattern | Creates a new Pattern object. |
Index(item as Pattern) | Long | Returns the index position of the object within the collection. |
Item(itemKey) | Pattern | Returns an object reference to the object identified by itemKey (name or index). |
RemoveAll() | Nothing | Deletes all objects in this collection. |
Removing a pattern
#Deletes a pattern from the document
Set appRef = CreateObject("Illustrator.Application")
#Delete the pattern, then set the patternToRemove reference to
#nothing because it no longer references an existing Illustrator pattern
Set frontDocument = appRef.Documents(1)
Set patternToRemove = frontDocument.Patterns(1)
frontDocument.Patterns.Remove patternToRemove
page 158
PDFFileOptions
Options for opening Adobe PDF documents. This object is found in the PDFFileOptions property of the Preferences class.
PDFFileOptions properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。指向整个Adobe Illustrator应用程序的对象,允许开发者访问和控制Illustrator的所有全局功能。 |
PageToOpen | Long | Specifies which page are used when opening a multipage document. Default: 1 指定打开多页文档时使用哪一页。默认值:1,表示打开文档的第一页。 |
Parent | Object | Read-only. The object’s container. 只读。表示当前对象所在的容器,即这个对象所属的父级实体。例如,在Illustrator中可能是一个特定的文档或页面等。 |
PDFCropToBox | AiPDFBoxType | Specifies which box are used when placing a multipage document. Default: 4 AiPDFMediaBox 在放置一个多页PDF文档时,指定使用的裁剪框类型。默认值:4 AiPDFMediaBox,表示使用PDF文件的媒体边界作为裁剪区域。该枚举可以有多个选项,如裁剪至裁剪框、出血框或其他类型的边框等。 |
Opening a PDF file
#Opens a multi-page PDF file to a specific
#page using the PDFFileOptions object
#filePath contains the full name and file path of the file to open
Sub pdfFileOptions(filePath)
Set appRef = CreateObject("Illustrator.Application")
With appRef.Preferences.PDFFileOptions
.PageToOpen = 2
.PDFCropToBox = 5 'aiPDFBoundingBox
End With
Set docRef = appRef.Open(filePath, 1)
End Sub
page 159
PDFSaveOptions
Options that can be supplied when saving a document as an Adobe PDF file with the document SaveAs method.
PDFSaveOptions properties
Property | Value type | What it is |
---|---|---|
AcrobatLayers | Boolean | Optional. If true, create PDF layers from top-level layers (Acrobat 6 only option). Default: false 可选。如果设置为true,则根据顶层图层创建PDF图层(仅限 Acrobat 6 版本)。默认值:false,不创建PDF图层。 |
Application | Application | Optional. Read-only. The Illustrator Application object. 可选。只读。指向Adobe Illustrator应用程序的对象,允许访问和控制Illustrator的核心功能。 |
ArtboardRange | string | Optional. This is considered for multi-asset extraction, which specifies the artboard range. An empty string extracts all the artboards. Default: empty string 可选。在多资产提取时使用,用于指定要提取的艺术板范围。空字符串表示提取所有艺术板。默认值:空字符串 |
BleedLink | Boolean | Optional. Link 4 bleed values.Default: true 可选。链接四边出血值。默认值:true,表示四个出血值关联并同步更新。 |
BleedOffsetRect | Variant Array of 4 Doubles | The bleed offset rectangle. 出血偏移矩形,定义文档四周的出血区域边界。 |
ColorBars | Boolean | Optional. Draw color bars.Default: false 可选。是否绘制颜色条以供校对。默认值:false,不绘制颜色条。 |
ColorCompression | AiCompressionQuality | Optional. Compression method for color bitmap images.Default: 1 aiNoCompression 可选。彩色位图图像的压缩方法。默认值:1 aiNoCompression,表示不进行颜色图像压缩。 |
ColorConversionID | AiColorConversion | Optional. The PDF color conversion policy. Default:0 aiColorConversionNone 可选。PDF的颜色转换策略。默认值:0 aiColorConversionNone,表示不执行颜色转换。 |
ColorDestinationID | AiColorDestination | Optional. The conversion target for color conversion. Default:0 aiColorDestinationNone 可选。颜色转换的目标配置。默认值:0 aiColorDestinationNone,表示没有特定的目标色彩空间转换。 |
ColorDownsampling | Double | Optional. if zero, no downsampling, otherwise, the resolution to downsample color bitmap images to. Default: 150.0 可选。如果为零,则不进行降采样,否则将彩色位图图像降采样至指定分辨率。默认值:150.0,表示将图像降采样到150dpi。 |
ColorDownsamplingImage-Threshold | Double | Optional. Downsample if the image’s resolution is above this value. Default: 225.0 可选。当图像分辨率高于此值时才进行降采样处理。默认值:225.0,即只有图像分辨率超过225dpi时才执行降采样。 |
ColorDownsamplingMethod | AiDownsampleMethod | Optional. Specifies how color bitmap images are resampled.Default: 0 aiNoDownsample 可选。指定如何对彩色位图图像进行重新采样。默认值:0 aiNoDownsample,表示不进行颜色图像的重新采样。 |
ColorProfileID | AiColorProfile | Optional. The color profile to include.Default: 0 aiColorProfileNone 可选。指定要包含的颜色配置文件。默认值:0 aiColorProfileNone,表示不包含任何特定颜色配置文件。 |
ColorTileSize | Long | Optional. Tile size when compressing with JPEG2000.Default: 256 可选。当使用JPEG2000压缩时的图像拼贴大小。默认值:256,表示每块图像大小为256像素。 |
Compatibility | AiPDFCompatibility | Optional. The version of the Acrobat® file format to create.Default: 5 Acrobat5 可选。创建的Acrobat®文件格式版本。默认值:5 Acrobat5,表示兼容Adobe Acrobat 5.0。 |
CompressArt | Boolean | Optional. If true, line art and text are compressed. Default: true 可选。如果设置为true,则对线条艺术和文本进行压缩。默认值:true,表示启用线稿和文字的压缩。 |
DocumentPassword | String | Optional. A password string to open the document. Default: no string 可选。用于打开文档的密码字符串。默认值:无密码(空字符串)。 |
EnableAccess | Boolean | Optional. If true, enable accessing 128-bit. Default: true 可选。如果设置为true,则启用128位访问权限。默认值:true,表示允许128位加密的访问权限。 |
EnableCopy | Boolean | Optional. If true, enable copying of text 128-bit. Default: true 可选。如果设置为true,则启用128位加密下的复制文本功能。默认值:true,表示允许在128位加密下复制文本。 |
EnableCopyAccess | Boolean | Optional. If true, enable copying and accessing 40-bit. Default: true 可选。如果设置为true,则启用40位加密下的复制和访问权限。默认值:true,表示在40位加密下同时开启复制和访问权限。 |
EnablePlainText | Boolean | Optional. Enable plaintext metadata 128-bit; available only for Acrobat 6. Default: false 可选。启用128位加密下的纯文本元数据;仅适用于Acrobat 6。默认值:false,表示不启用此功能。 |
FlattenerOptions | PrintFlattenerOptions | Optional. The printing flattener options 可选。打印平滑器选项,定义如何处理透明度效果以适应输出设备。 |
FlattenerPreset | String | Optional. Transparency flattener style name. Default: Custom 可选。透明度平滑预设风格名称。默认值:“Custom”,表示自定义透明度平滑设置。 |
FontSubsetThreshold | Double | Optional. Include a subset of fonts when less than this percentage of characters are used. Range: 0.0 to 100.0. Default: 100.0 可选。当使用的字符百分比低于此阈值时,只包含字体子集。范围:0.0到100.0。默认值:100.0,表示始终包含整个字体。 |
GenerateThumbnails | Boolean | Optional. If true, generate thumbnails for the saved document. Default: true 可选。如果设置为true,则为保存的文档生成缩略图。默认值:true,表示生成缩略图。 |
GrayscaleCompression | AiCompressionQuality | Optional. Specifies how grayscale bitmap images are compressed.Default: 1 aiNoCompression 可选。指定灰度位图图像的压缩方式。默认值:1 aiNoCompression,表示不压缩灰度图像。 |
GrayscaleDownsampling | Double | Optional. If zero, no downsampling, otherwise, the resolution to downsample grayscale images to. Default: 150.0 可选。如果为零则不进行降采样,否则将灰度图像降采样至指定分辨率。默认值:150.0,表示将灰度图像降采样到150dpi。 |
GrayscaleDownsampling-ImageThreshold | Double | Optional. Downsample if the image’s resolution is above this value. Default: 225.0 可选。当图像分辨率高于此值时才进行灰度图像降采样处理。默认值:225.0,即只有图像分辨率超过225dpi时才执行降采样。 |
GrayscaleDownsampling-Method | AiDownsampleMethod | Optional. How should grayscale bitmap images be resampled. Default: 0 aiNoDownsample 可选。指定灰度位图图像应如何被重新采样。默认值:0 aiNoDownsample,表示不进行灰度图像的重新采样。 |
GrayscaleTileSize | Long | Optional. Tile size when compressing with JPEG2000.Default: 256 可选。使用JPEG2000压缩时的灰度图像拼贴大小。默认值:256,表示每个灰度图像拼贴块大小为256像素。 |
MonochromeCompression | AiMonochromeCompression | Optional. How should monochrome bitmap images be compressed.Default:0 aiNoMonoCompression 可选。单色位图图像的压缩方法。默认值:0 aiNoMonoCompression,表示不压缩单色图像。 |
MonochromeDownsampling | Double | Optional. The resolution to downsample images to. If 0, no downsampling. Default: 300.0 可选。单色图像的降采样分辨率。如果为0,则不进行降采样。默认值:300.0,表示将单色图像降采样至300dpi。 |
MonochromeDownsampling-ImageThreshold | Double | Optional. Downsample if the image’s resolution is above this value. Default: 450 可选。如果图像分辨率高于此值,则进行单色图像的降采样处理。默认值:450.0,表示当图像分辨率超过450dpi时执行降采样。 |
MonochromeDownsampling-Method | AiDownsampleMethod | Optional. How monochrome bitmap images are resampled.Default: aiNoDownsample 可选。指定单色位图图像应如何被重新采样。默认值:aiNoDownsample,表示不对单色图像进行重新采样。 |
Offset | Double | Optional. Offset from artwork to draw printer marks. Default: 0 可选。用于绘制打印机标记相对于艺术品的偏移量。默认值:0,表示无偏移。 |
Optimization | Boolean | Optional. If true, saved PDF are optimized for fast web viewing. Default: false 可选。如果设置为true,则保存的PDF文件将针对快速网页查看进行优化。默认值:false,表示不进行优化以适应网页查看。 |
OutputCondition | String | Optional. An optional comment to add to the PDF file, describing the intended printing condition.Default: not included 可选。添加到PDF文件中的一条可选注释,描述预期的打印条件。默认值:不包含任何注释信息。 |
OutputConditionID | String | Optional. The name of a registered printing condition. Default: not included 可选。已注册打印条件的名称。默认值:不包含任何打印条件名称。 |
PageInformation | Boolean | Optional. If true, draw page information. Default: false 可选。如果设置为true,则在页面上绘制页面信息(如页码等)。默认值:false,表示不绘制页面信息。 |
PageMarksType | AiPageMarksStyle | Optional. The page marks style. Default: aiPageMarksStandard 可选。页面标记样式。默认值:aiPageMarksStandard,表示使用标准页面标记样式(例如裁切、出血和中心线等)。 |
PDFAllowPrinting | AiPDFPrintAllowedEnum | Optional. PDF security printing permission. Default:3 aiPrint128HighResolution 可选。PDF安全设置中的打印权限级别。默认值:3 aiPrint128HighResolution,表示允许128位加密下的高分辨率打印。 |
PDFChangesAllowed | AiPDFChangesAllowedEnum | Optional. PDF security changes allowed. Default: 5 Change128AnyChanges 可选。指定PDF文件的安全设置中允许的更改权限级别。默认值:5 Change128AnyChanges,表示使用128位加密且允许进行任何类型的更改。 |
PDFPreset | String | Optional. PDF preset name 可选。用于导出PDF的预设名称,通常对应于预定义的一组PDF导出设置集合。 |
PDFXStandard | AiPDFXStandard | Optional. The PDF standard with which this document complies. Default: 1 aiPDFXNone 可选。指示此文档遵循的PDF标准。默认值:1 aiPDFXNone,表示不遵循特定的PDF/X标准。 |
PDFXStandardDescription | string | Optional. A description of the PDF standard from the selected preset. 可选。所选PDF预设中包含的PDF标准相关描述信息。 |
PermissionPassword | String | Optional. A password string to restrict editing security settings. Default: no string 可选。设置一个密码以限制编辑安全设置的修改。默认值:无密码(空字符串),即不对编辑安全设置进行密码保护。 |
PreserveEditability | Boolean | Optional. If true, preserve Illustrator editing capabilities when saving the document. Default: true 可选。如果设置为true,则在保存文档时保留Illustrator的编辑功能。默认值:true,表示保存后仍可编辑。 |
PrinterResolution | Double | Optional. Flattening printer resolution. Default: 800.0 可选。指定图形合并(Flattening)过程中的打印机分辨率。默认值:800.0 dpi。 |
RegistrationMarks | Boolean | Optional. Draw registration marks. Default: false 可选。是否绘制印刷注册标记。默认值:false,表示不绘制注册标记。 |
RequireDocumentPassword | Boolean | Optional. If true, a password are required to open the document. Default: false 可选。如果设置为true,则打开文档时需要输入密码。默认值:false,表示无需密码即可打开。 |
RequirePermissionPassword | Boolean | Optional. If true, a password are used to restrict editing security settings. Default: false 可选。如果设置为true,则修改文档安全设置时需提供密码。默认值:false,表示不需要密码来修改安全设置。 |
Trapped | Boolean | Optional. If true, manual trapping has been prepared for the document.Default: false 可选。如果设置为true,则表明该文档已经手动准备了陷印处理。默认值:false,表示文档未经陷印处理。 |
TrimMarks | Boolean | Optional. If true, draw trim marks. Default: false 可选。如果设置为true,则绘制裁切标记。默认值:false,表示不绘制裁切标记。 |
TrimMarkWeight | AiPDFTrimMarkWeight | Optional. Trim mark weight. Default: 1 aiTrimMarkWeight0125 可选。设置裁切标记线的粗细。默认值:1 aiTrimMarkWeight0125,表示裁切标记线宽为0.125点。 |
ViewAfterSaving | Boolean | Optional. If true, view PDF after saving. Default: false 可选。如果设置为true,则保存PDF后自动打开查看。默认值:false,表示保存时不自动打开查看。 |
Saving to PDF
This script illustrates how to save the frontmost document as PDF.
#Saves current document as PDF to dest
#dest contains the full path and file name to save to
Sub exportFileAsPDF (dest)
Set appRef = CreateObject("Illustrator.Application")
Set saveOptions = CreateObject("Illustrator.PDFSaveOptions")
saveOptions.ColorCompression = 6 #aiJPEGHigh
saveOptions.Compatibility = 5 #aiAcrobat5
Set frontDocument = appRef.ActiveDocument
Call frontDocument.SaveAs (dest, saveOptions)
End Sub
page 164
PhotoshopFileOptions
Options applied when opening or placing an Adobe Photoshop file.
PhotoshopFileOptions properties
Property | Value type | What it is |
---|---|---|
Application | Application | Read-only. The Illustrator Application object. 只读。Illustrator 应用程序对象。 |
LayerComp | String | The name of the layer composition to use when the document is converted. 在转换文档时要使用的图层组合的名称。 |
Parent | Object | Read only. This object’s parent object. 只读。此对象的父对象。 |
PreserveHiddenLayers | Boolean | If true, preserve hidden layers when the document is converted. Default: false 如果设置为true,则在转换文档时保留隐藏的图层。默认值为false。 |
PreserveImageMaps | Boolean | If true, the image maps are preserved when the document is converted. Default: true 如果设置为true,则在转换文档时保留图像映射。默认值为true。 |
PreserveLayers | Boolean | If true, layers are preserved when the document is converted. Default: true 如果设置为true,则在转换文档时保留图层。默认值为true。 |
PreserveSlices | Boolean | If true, slices are preserved when the document is converted. Default: true 如果设置为true,则在转换文档时保留切片。默认值为true。 |
Opening a Photoshop document
#Opens a PSD file and retains its layers
#using the PhotoshopFileOptions object
#dest contains the full path and file name of the file to open
Sub photoShopFileOptions(dest)
Set appRef = CreateObject("Illustrator.Application")
With appRef.Preferences.PhotoshopFileOptions
PreserveLayers = True
PixelAspectRatioCorrection = False
End With
Set docRef = appRef.Open(dest, 1)
End Sub
page 165
PlacedItem
An artwork item placed in a document as a linked file. For example, an artwork item