Skip to content

Instantly share code, notes, and snippets.

@jadnco
Last active August 29, 2015 14:21
Show Gist options
  • Save jadnco/d8c06a8248c32738c490 to your computer and use it in GitHub Desktop.
Save jadnco/d8c06a8248c32738c490 to your computer and use it in GitHub Desktop.
A Sketch plugin that lets you create and specify how many duplicates of a layer you want.
var input = [doc askForUserInput:"Total copies:" initialValue:'']);
var count = parseInt(input);
var quit = input == null;
while (count != count) {
if (quit) break;
input = [doc askForUserInput:"Please enter an actual number for copies:" initialValue:''];
quit = input == null;
count = parseInt(input);
}
if (!quit) {
for (var i=0; i<selection.count(); i++) {
var layer = selection[i];
for (var j=0; j<count-1; j++) {
layer.duplicate()
}
print(layer);
}
}
@jadnco
Copy link
Author

jadnco commented May 24, 2015

How to install

  1. Click the Download Gist button to the right.
  2. Unzip the .tar file it downloaded.
  3. Move sketch-duplicate.sketchplugin to ~/Library/Application Support/com.bohemiancoding.sketch3/Plugins

Using the plugin

  1. Select the layer you want to duplicate.
  2. Click on Plugins > sketch-duplicate and specify the total layer count you want.
  3. Profit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment