Last active
August 30, 2017 14:13
-
-
Save designforhuman/77c908b7075402fe20ab215928f83981 to your computer and use it in GitHub Desktop.
NameTag Generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NameTag Generator (alpha version) | |
// Designed and Coded by David Lee @DesignSpectrum, @Daylight | |
// 23 July, 2017 | |
// array of participants' names | |
var participants = ["James", "Peter", "David"]; | |
// get sketch document and layers(incl. artboard) | |
var sketch = context.api(); | |
var document = sketch.selectedDocument; | |
var page = document.selectedPage; | |
var selectedLayers = document.selectedLayers; | |
var DISTANCE = 50; | |
// Give warning when artboard is not selected | |
if(selectedLayers.length == 0) { | |
log('Please select an artboard first.'); | |
} | |
// duplicate the selected artboard | |
for(i = 0; i < participants.length; i++) { | |
selectedLayers.iterate(function(artboard) { | |
if(artboard.isArtboard) { | |
var newArtboard = artboard.duplicate(); | |
var rect = newArtboard.frame; | |
rect.x += (i + 1) * (rect.width + DISTANCE); | |
newArtboard.frame = rect; | |
newArtboard.iterate(function(group) { | |
if(group.name == 'name') { | |
group.iterate(function(layer) { | |
if(layer.name == 'name') { | |
layer.text = participants[i]; | |
} | |
}); | |
} | |
}); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment