Your prescription for increased productivity and profitability
In this blog post series we are creating animations for InDesign using scripts. If you followed our last post, you saw that there were a number of properties that needed to be set for an object ‘s animation settings to create its animation:
To illustrate how transform offsets works, we can think in terms of the transformation proxy (the diagram of nine circles that appears at the top left of the control panel when you create a page item in InDesign.
Transformation proxy
As you can see, each column can have a number from zero to one with point five (.5) being the center point. When setting the transform offsets for an object’s animation settings, the first item of the transform offsets list represents the column, while the second represents the row. The following scripts illustrate:
tell application "Adobe InDesign CC 2017" set measurement unit of script preferences to pixels set ruler origin of view preferences of document 1 to page origin set spreadRef to active spread of active window set objStyle to object style 1 of document 1 set gBounds to {100, 200, 150, 300} set rectRef to my makeDefaultRectangle(spreadRef, gBounds, objStyle) tell animation settings of rectRef set duration to 2 set transform offsets to {0,1} set rotation array to {{0, 0}, {23, 45}} end tell end tell on makeDefaultRectangle(spreadRef, gBounds, objStyle) tell application "Adobe InDesign CC 2017" tell spreadRef set myRectangle to make rectangle with properties {geometric bounds:gBounds, object style:objStyle} end tell end tell end makeDefaultRectangle
var myDocument = app.documents[0]; app.scriptPreferences.measurementUnit = MeasurementUnits.PIXELS; var spreadRef = myDocument.spreads[0]; var objStyle = myDocument.objectStyles[0]; var gBounds = [100, 200, 150, 300]; var rectRef = makeDefaultRectangle(spreadRef, gBounds, "Rect1", objStyle); rectRef.animationSettings.duration = 2; rectRef.animationSettings.transformOffsets=[0,1] rectRef.animationSettings.rotationArray = [[1,0], [23, 45]]; function makeDefaultRectangle(spreadRef, gBounds, myString, myStyle){ var myRectangle = spreadRef.rectangles.add({geometricBounds:gBounds, objectStyle:myStyle, name:myString}); return myRectangle; }
As you can see from the above, the transform offsets property can make a big difference when it comes to rotation.
Notice in the above the rotation array is a list (array) with each item being a list itself where its first item represents timeframe and the second, the degree of rotation.
AppleScript
set rotation array to {{0, 0}, {23, 45}}
JavaScript
rectRef.animationSettings.rotationArray = [[1,0], [23, 45]];
A fun idea is to use the transform offsets property to rotate a page item around another. How could this be done? You create the containing rectangle for the rotating object to enclose its target.
For demonstration, in the screen capture below, we have created the rectangle that contains the airplane to enclose that for the world. With the world in the center vertically and horizontally, we can set the transform offsets to {0.5, 0.5}. We have placed the airplane rectangle on a layer named “Plane”. With this} we can write the following script.
tell application "Adobe InDesign CC 2017" set ruler origin of view preferences of document 1 to page origin set spreadRef to active spread of active window set objRef to page item 1 of layer "Plane" of document 1 tell animation settings of objRef set duration to 3 set transform offsets to {0.5, 0.5} set rotation array to {{0, 0}, {71, 360}} end tell end tell
var myDocument = app.documents[0]; var spreadRef = myDocument.spreads[0]; var layerRef = myDocument.layers.itemByName("Plane"); var objRef = layerRef.pageItems[0]; objRef.animationSettings.duration = 3; objRef.animationSettings.transformOffsets=[0.5, 0.5]; objRef.animationSettings.rotationArray = [[0,0], [71, 360]];
Notice that the duration is set to 3 so the first element of the second rotation array is 71 representing the timeframe: (24 * 3) – 1. The second element is 360 representing the angle of rotation: 360 degrees.
Come up with some ideas for animating several objects using rotation. Refer back to the AnimationEncyclopedia script provided by Adobe in the Scripts Panel. Page 3 may give you some code to start with.