Motion Path Points Revisited

In our last script, we introduced the concept of using a script to automate animations for fixed layout ePub publications. To get the motion path points for the animation we used the entire path property for path one of a selected page item. The entire path property appears to return the control points for a path point in the order of left direction controller, anchor point, and right direction controller. The motion point path property for animation settings expects the three values to be returned in the order of anchor point, left direction controller, then right direction controller. For this purpose, the following script should be used to determine your motion path points.

tell application "Adobe InDesign CC 2014"
   set selRef to item 1 of selection
   set testPath to path 1 of selRef
   set pointList to path points of testPath
   set myPathPoints to {}
   repeat with i from 1 to length of pointList
      set thisPoint to item i of pointList
      if point type of thisPoint is smooth then
         set aList to anchor of thisPoint
         set eList to left direction of thisPoint
         set rList to right direction of thisPoint
      else
         set aList to anchor of thisPoint
         set eList to anchor of thisPoint
         set rList to anchor of thisPoint
      end if
      set end of myPathPoints to {aList, eList, rList} 
   end repeat
   set myPathPoints to {myPathPoints} & {true}
end tell
myPathPoints

Another benefit of using this script is that the the result eliminates the need to add curly braces and the word true to the end of the list. Just assign the result to the mPathPoints variable for the TestAnimation script.

Relative Paths

Motion path points for presets such as move rightmove leftfly in from top, and fly in from left are relative paths.

The first value for the motion path points list for these presets will be {{0.0,0.0}, {0.0,0.0}, {0.00.0}}

The second value will be three lists indicating the amount of move in both the x and y direction. For example to move right 300 points the second value for the motion path points list will be {{300, 0},{300, 0},{300,0}}

If moving left, the values will be negative.

This makes it convenient for moving a number of objects on the page, especially if they are all moving the same distance.

Timing Delays

Once you get your basic animation working, you may want to add some timing delays. Adding a delay of one second to an animation that starts when its page is opened gives the reader a chance to settle into the page before the animation begins. Alternatively, you may want the user to click on the page to start the animation. If you have more than one animation on the page, you may want to add delays so the animations don’t follow immediately one after another.

Timing Settings

Before we get into writing a script that uses timing settings, there are a few things you need to know:

  • Timing settings are a property of a spread, not a page.
  • By default, timing settings has a single timing list set to trigger On Page Load.
  • To create your own timing setting, you need to delete the default timing list
  • A timing list is a list of animations (referred to as timing groups) in the order they will run.

Animated Text

One common use for using timing delays is for displaying bulleted text sequentially. The following script sets up a page where the bulleted text animates in line by line with a two second delay. The animation will not start until the user clicks on the page. The script assumes the document is set up for iPad horizontal orientation and has a paragraph style named “Bullets.”. The result is the beginning of a page that could be used as part of a visual presentation.

global parastyleRef
set bulletList to {"Establish a clear goal for your presentation", ¬
"Prepare early, prepare often", "Find stories to illustrate concepts",¬
"Involve your audience", "Respect the time limit", ¬
"Show up early", "Practice, practice, practice"}

Animated Text

tell application "Adobe InDesign CC 2014"
   set docRef to document 1
   tell docRef
      --document setup
      set parastyleRef to paragraph style "Bullets"
      set pageRef to page 1
      set horizontal measurement units of view preferences to mySet
      set vertical measurement units of view preferences to mySet
      set ruler origin of view preferences to page origin
      set y0 to 200
      --add elements to be animated to page
      tell pageRef
         repeat with i from 1 to length of bulletList
            set myText to item i of bulletList
            my makeTextFrame(pageRef, {y0, 100, y0 + 50, 800}, ¬
("Frame" & i), myText, "Minion Pro", 14, left align, true) set y0 to y0 + 50 end repeat end tell --page -establish timing list for timing settings set spreadRef to parent of pageRef set timingSettings to timing settings of spreadRef tell timingSettings delete timing list 1 set myTimingList to make timing list with properties ¬
{trigger event:on page click} tell myTimingList repeat with i from 1 to length of bulletList set thisFrame to text frame ("Frame" & i) of docRef make timing group with properties ¬
{dynamic target:thisFrame, delay seconds:2} end repeat end tell --timing list end tell --timing settings end tell --document end tell --application (*Routine that makes text frames and establishes animation*) on makeTextFrame(pageRef, gBounds, objName, myText, fontName, pointSize, textJust, fitOption) tell application "Adobe InDesign CC 2014" set fontRef to font fontName set myPreset to Motion Preset "Fade In" tell pageRef set frameRef to make text frame with properties¬
{geometric bounds:gBounds, name:objName} tell animation settings of frameRef set duration to 1.5 --set design option to to current appearance set preset to myPreset set ease type to no ease set hidden after to false set plays loop to false set plays to 1 set initially hidden to true end tell set contents of insertion point 1 of frameRef to myText tell text 1 of parent story of frameRef set applied paragraph style to parastyleRef end tell if fitOption is true then tell frameRef to fit given frame to content end if return frameRef end tell end tell end makeTextFrame

Of course you will want to add more to the page to make it visually appealing. The nice thing about creating a presentation using InDesign is that you have total control over the design of the page.

Onward and Upward

There is so much you can do now with fixed format layouts in InDesign, we feel like we have just scratched the surface. Our next blog will work with multi state objects.