EDOBE XDOM TPC Informações Técnicas Página 57

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 68
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 56
CHAPTER 6: Scripting with VBScript Accessing and referencing objects 57
In the script below, the variable pageItemRef will not necessarily refer to the same object as the above
script, since this script includes a reference to a layer:
Set documentRef = appRef.ActiveDocument
Set pageItemRef = documentRef.Layers(1).PageItems(1)
VBScript indexes start at 1 for object collections; however, VBScript allows you to specify whether array
indexes start at 1 or 0. For information on specifying the index start number for arrays, see any VBScript
textbook or tutorial.
Creating new objects
You can use a script to create new objects. To create objects that are available from collection objects, use
the collection object’s
Add method:
Set myDoc = appRef.Documents.Add()
Set myLayer = myDoc.Layers.Add()
Some collection objects do not have an Add method. To create an object of this type, define a variable and
use the
CreateObject method. For example, the following code creates a new CMYKColor object using
the variable name
newColor:
Set newColor = CreateObject ("Illustrator.CMYKColor")
Working with selections
When the user makes a selection in a document, the selected objects are stored in the document’s
selection property. To access all selected objects in the active document:
Set appRef = CreateObject ("Illustrator.Application")
Set documentRef = appRef.ActiveDocument
selectedObjects = documentRef.Selection
Depending on what is selected, the selection property value can be an array of any type of art objects. To
get or manipulate the properties of the selected art items, you must retrieve the individual items in the
array. To find out an objects type, use the
typename property.
The following sample gets the first object in the array, then displays the objects type:
Set appRef = CreateObject ("Illustrator.Application")
Set documentRef = appRef.ActiveDocument
selectedObjects = documentRef.Selection
Set topObject = selectedObjects(0)
MsgBox(topObject.Typename)
The MsgBox method does not display a dialog when the script is run from the Illustrator Scripts menu
(File > Scripts).
The first object in a selection array is the selected object that was last added to the page, not the last object
selected.
Selecting artwork objects
To select an artwork object, use the objects Selected property.
Vista de página 56
1 2 ... 52 53 54 55 56 57 58 59 60 61 62 ... 67 68

Comentários a estes Manuais

Sem comentários