Adobe 65048332 Scripting Guide - Page 11
Photoshop Object Model, Containment hierarchy
View all Adobe 65048332 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 11 highlights
CHAPTER 2: Photoshop Scripting Basics Photoshop Object Model 11 Photoshop Object Model A document object model (DOM) is an application programming interface (API), which allows you to programmatically access various components of a document (as defined for that application) through a scripting language. For additional information about Adobe object models and the scripting languages that support them, see Introduction to Scripting. The Photoshop DOM consists of a hierarchical representation of the Photoshop application, the documents used in it, and the components of the documents. The DOM allows you to programmatically access and manipulate the document and its components. For example, through the DOM, you can create a new document, add a layer to an existing document, or change the background color of a layer. Most of the functionality available through the Photoshop user interface is available through the DOM. A good understanding of the Photoshop DOM, and how each aspect of the DOM relates to the Photoshop application and its documents will make script writing easier. Containment hierarchy The Photoshop object model is a containment hierarchy, which means that objects in the model are identified partially by the objects that contain them. In Photoshop, the Application object sits at the top of the hierarchy. Applications contain a Documents collection. The Documents collection contains Document objects. A Document object contains an ArtLayers collection, a HistoryStates collection, a Layers collection, a Layersets collection, and a Channels collection. Through using commands or methods in the DOM, you can tell Photoshop documents to add and remove objects, or set or change individual object properties like color, size and shape. In the diagram below, each node in the hierarchy represents a class in the Photoshop DOM. The Photoshop object model uses elements (AppleScript) or collections (VBScript, JavaScript) as a convenient way to group classes. We have not shown object elements or collections in the object model diagram below. Not all classes are associated with a collection. However, some key classes are grouped by elements or collection. The following elements/collections exist in Photoshop: Art Layers, Channels, Color Samplers, Count Items, Documents, Layers, Layer Comps, Layer Sets, History States, Notifiers, Path Items, Path Points Sub Path Items, and Text Fonts. See Introduction to Scripting for more information on elements and collections. NOTE: In Photoshop, VBScript collections index from 1 rather than 0. This stands in contrast to other VBScript arrays, which index from 0.