Lottie Tools for Affinity

dailyRushes Scripts for Affinity

dR Animate animates your artwork inside Affinity: record the changes you make on the canvas as clips, adjust and play them, then save a Lottie animation.

dR Animate has its own page

Everything about recording, clips, path clips, playing and making Lottie files is on dR Animate for Affinity.

The other tabs here cover Import and export with dR Lottie, Batch Export with dR Batch Lottie, and Saving Files for all three.

dR Lottie brings Lottie files into Affinity as editable shapes, and turns your artwork into still Lottie files. It has two tabs at the top: Import and Export.

Before you start

  1. Add dR Lottie to your Script Library, then click it to run it. See Installing Scripts for Affinity.
  2. Choose Edit > Settings > Scripting, turn on Access the file system, then under File system access click Add and choose the folder with your Lottie files, such as your Desktop. See Saving Files.

Import: Lottie file

File

Every .json file in your allowed folders, labelled with its folder. Choose one and it is read straight away. The list starts on the file you imported last.

Choose file...

Opens File Explorer to pick a .json file, for example one in a folder inside an allowed folder, or one saved after the window opened.

File details

The line under the buttons shows the chosen file’s size, frame rate, length and number of layers.

Import: Or paste a Lottie

Paste the text of a Lottie file into the box. While there is text in the box, it is used instead of the file. Choosing a file clears the box.

Import: Import

Frame

The moment of the animation to bring in. 0 is the start.

Position

Where the artwork goes:

  • Top-left of the page: the artwork’s own top-left corner goes to the page’s top-left corner.
  • Centre of the page: the artwork is centred on the page.
  • Same place as in the file: keeps the spot it had in the Lottie.

Select one artboard before running dR Lottie to place the artwork on that artboard instead. The artwork always comes in at the file’s own size.

Import: What will come in

Lists the shapes, groups and layers that will be created, and anything that will be left out or changed. It updates whenever you change a setting.

  1. Check the list.
  2. Click OK to import, or Cancel to stop without importing.

Everything comes in as one group, named after the Lottie, and is selected afterwards. To remove it in one go, use Edit > History and click the step before the import.

Comes in Left out
Shape layers, groups and their names, paths, rectangles, ellipses, stars and polygons Text layers, images
Solid and gradient fills, strokes, dashes Masks and track mattes
Position, rotation, scale, opacity, parenting, precomps Effects, trim paths, repeaters, expressions

Export

Turns your artwork into a still Lottie file. To export animation, use dR Animate.

Export

  • Selection (or artboard): the selected objects, or one selected artboard. The Lottie is cropped to fit them.
  • Whole page: everything on the page.

Scale %

Makes the Lottie bigger or smaller than the artwork.

Make Lottie

Builds the Lottie and shows it below.

Lottie JSON

The Lottie file as text. Click in the box, press Ctrl+A then Ctrl+C to copy it. The box below lists what was exported and anything that could not be converted.

File name

The name for the saved file. It is filled in for you after Make Lottie.

Folder

Where to save: your allowed folders.

Save to folder

Makes the Lottie again and saves it as a .json file.

On the Export tab, OK and Cancel just close the window. Nothing is imported.

dR Batch Lottie saves each object as its own still Lottie file, named after its layer, in one go.

Before you start

  1. Add dR Batch Lottie to your Script Library. See Installing Scripts for Affinity.
  2. Choose Edit > Settings > Scripting, turn on Access the file system, then under File system access click Add and choose a folder, such as your Desktop. Folders inside it can be used too. See Saving Files.
  3. Select the objects to export, or one group, then click dR Batch Lottie to run it.

What to export

Export

  • Each selected object: one file for each object you selected.
  • Each object inside the selected group: select one group, and each object inside it becomes a file.

Hidden objects are always left out. A background shape inside the group is exported too, so select just the objects you want if you don’t want it.

Name prefix

Optional: added to the start of every file name. For example, lower- gives lower-01.json.

Size

  • Cropped to each object: each file is just the object.
  • Full page (keeps its place): every file is page-sized, with the object where it is on the page.

Scale %

Makes every file bigger or smaller than the artwork.

Where

Folder

Your allowed folders and the folders inside them.

Choose a file in the folder...

For a folder further in: pick any file in it, and the Lottie files are saved next to it.

Saving to

Shows the folder the files will be saved in.

If a file exists

  • Replace it: the old file is overwritten.
  • Skip it: the old file is kept and that object is not saved.
  • Keep both (add a number): the new file gets a number, such as 01 2.json.

Files

File list

Every file that will be written, shown before anything is saved, for example 01 → 01.json. Files that will replace or skip an existing file are marked.

File names come from the layer names. Accented letters and characters Windows doesn’t allow are changed, and two objects with the same name get a number.

Export

Writes all the files in the list.

Report

Each file saved, with its size, and anything that could not be converted, such as text or pictures.

OK and Cancel just close the window. Files are only saved when you click Export.

Affinity only lets scripts open and save files in folders you have allowed. Without this, dR Animate, dR Lottie and dR Batch Lottie can’t save Lottie files, and dR Lottie can’t find Lottie files to import.

Allow scripts to use a folder

  1. In Affinity, choose Edit > Settings. On a Mac, choose Affinity > Settings.
  2. Click Scripting.
  3. Turn on Access the file system.
  4. Under File system access, click Add.
  5. Choose the folder for your Lottie files, then confirm.

The folder appears in the File system access list. The scripts can now use it straight away, and they list it in their Folder and File dropdowns the next time you open them.

Folders inside an allowed folder

Allowing a folder also allows every folder inside it. For example, if your Desktop is allowed, Desktop\lotties can be used too, without adding it separately.

Stop scripts using a folder

  1. Choose Edit > Settings > Scripting.
  2. Under File system access, click the folder in the list.
  3. Click Remove.

The folder and its files are not changed or deleted. Scripts just can’t open or save there any more.

To stop scripts using any folders at all, turn off Access the file system.

Which folder to allow

  • Allow only what you need. A folder you keep for Lottie files, such as Desktop\lotties, is safer than a whole drive.
  • The Desktop is a handy choice. Any folder you make on it can be used straight away.
  • Several folders can be in the list. The scripts show all of them.

If saving doesn’t work

What you see Fix
“Affinity is not letting scripts save” or “read”, with PERMISSION_DENIED or NOT_ALLOWED Turn on Access the file system, and add the folder (or a folder it is inside) under File system access.
“No allowed folders”, or the Folder list is empty No folder has been added yet. Add one as shown above, then close and reopen the script.
A folder you just added isn’t in the list The lists are made when the script’s window opens. Close it and run the script again.
A new Lottie file isn’t in dR Lottie’s File list It was saved after the window opened, or it is in a folder inside an allowed folder. Use Choose file..., or reopen dR Lottie.