Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Script for creating guides in After Effects
var canvas = app.project.activeItem;
var height = canvas.height;
var width = canvas.width;
var canvasSize = [height, width];
// Guide positions (in pixels)
var bleed = 20; // Off canvas
var margin = 40; // Inside margin
function makeGuides() {
// For each axis (horizontal then vertical)
for (var axis = 0; axis < canvasSize.length; axis++) {
// Guides from top to bottom then left to right
var guides = [
-bleed, // top or left off canvas bleed
margin, // top or right margin
canvasSize[axis] / 2, // horizontal or vertical center
canvasSize[axis] + bleed, // bottom or right margin
canvasSize[axis] - margin // bottom or right off canvas bleed
// Make a guide for each position in the list
for (var guide = 0; guide < guides.length; guide++) {
canvas.addGuide(axis, guides[guide]);
// Wrap in an Undo Group to allow undoing and redoing of guides
app.beginUndoGroup('Canvas Guides'); // Message to show for Undo and Redo
makeGuides(); // Make the guides
write('Enjoy your guides!'); // Confirmation message to show in Info Window
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.