Application
The application object.
Documents
View
Editing Actions
Utilities
activeDocument
returns Document
Gets the currently active document.
Example: set the canvas size of the current document
var doc = [app activeDocument]
doc.canvasSize = CGSizeMake(800, 800)
addDocument
returns Document
Creates a new empty document and makes it the active document.
Example: create a new document with copies of the selected objects by cutting and pasting
[app copy]
[app addDocument]
[app pasteInPlace]
copy
Performs the 'Edit' menu's 'Copy' command, copying the selected objects to the clipboard.
cut
Performs the 'Edit' menu's 'Cut' command, copying the selected objects to the clipboard and then removing them.
Example: move the selected objects into a new layer by cutting and pasting
[app cut]
[[app activeDocument] addLayer]
[app pasteInPlace]
openDocument
returns Document
Displays the Open Panel and allows the user to select and open a document. If successful, the document is made active and returned. Otherwise the function return nil.
Example: open an existing document, export it as an SVG string, and copy the string to the clipboard
var doc = [app openDocument]
if(doc)
{
var svgStr = [doc exportSVG:nil]
var pboard = [NSPasteboard generalPasteboard]
[pboard clearContents]
[pboard writeObjects:[NSArray arrayWithObject:svgStr]]
}
paste
Performs the 'Edit' menu's 'Paste' command, pasting the contents of the clipboard to the canvas.
pasteInPlace
Performs the 'Edit' menu's 'Paste In Place' command, pasting the contents of the clipboard to the canvas. If the clipboard contains objects copied within Graphic, the objects are pasted in their original locations.
redo
Performs the 'Edit' menu's 'Redo' command, redoing the last undone action.
showAlert:
input: String
Displays an alert panel with the input string as the message.
Example: display an alert showing the active layer's name
var doc = [app activeDocument]
var layer = [doc activeLayer]
[app showAlert:[layer name]]
undo
Performs the 'Edit' menu's 'Undo' command, undoing the last action.
version
returns: String
Returns a string of the application's version number, such as "3.1".
Example: display an alert showing the application's version string
[app showAlert:[app version]]
view
returns View
Gets the application's View object.
Example: set the current zoom level to 200%
var view = [app view]
[view setZoom:200]
Next: Document
