
CHAPTER 4: Scripting with AppleScript Working with the perspective grid 42
For a one-point perspective grid, only the left and floor plane are valid.
This script sets the active perspective plane to the left plane:
tell application "Adobe Illustrator"
--Create a new document
set docRef to make new document
tell docRef
--Set the active plane to the left plane
set perspective active plane perspective grid plane leftplane
end tell
end tell
Draw on a perspective grid
When the Perspective Grid is on, drawing methods allow you to draw or operate on objects in perspective.
This script creates a new document, shows a two-point perspective grid, and draws art objects on the left
plane:
tell application "Adobe Illustrator"
--Create a new document
set docRef to make new document
tell docRef
--Select the default two-point perspective preset
select perspective preset perspective preset "[2P-Normal View]"
--Display the perspective grid defined in the document
show perspective grid
--Check if active plane is set to left, otherwise set it to left
if (get perspective active plane) is not leftplane then
set perspective active plane perspective grid plane leftplane
end if
--Draw rectangle in perspective, then resize to 200% and move
set rectRef to make new rectangle with properties {bounds:{0, 0, 30, 30},
reversed:false}
scale rectRef horizontal scale 200 vertical scale 200 about top left with
transforming objects
translate rectRef delta x -420 delta y 480
--Draw ellipse in perspective
set ellipseRef to make new ellipse with properties {bounds:{60, -60, 90, -30},
reversed:false, inscribed:true}
--Draw rounded rectangle in perspective
set rrectRef to make new rounded rectangle with properties {bounds:{90, -90, 30,
30}, horizontal radius:10, vertical radius:10, reversed:false}
--Draw polygon in perspective
set polyRef to make new polygon with properties {center point:{105, 105},
radius:15, sides:7, reversed:false}
--Draw star in perspective
Floor plane
perspective grid plane floorplane
Invalid plane
perspective grid plane noplane
Kommentare zu diesen Handbüchern