Skip to content

Instantly share code, notes, and snippets.

@srwild
Created February 23, 2020 15:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save srwild/d6b0da258454411856867327d404ac4d to your computer and use it in GitHub Desktop.
Save srwild/d6b0da258454411856867327d404ac4d to your computer and use it in GitHub Desktop.
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
clearOutput();
makeGuides(); // Make the guides
write('Enjoy your guides!'); // Confirmation message to show in Info Window
app.endUndoGroup();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment