Created
October 20, 2014 23:40
-
-
Save apetrone/26f5a767e82c2c92b9fd to your computer and use it in GitHub Desktop.
Split Active Layer Text String
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
// Adam Petrone | |
// Creation date: ~2011? | |
// Select a text layer in Photoshop/Illustrator and it will distribute | |
// each letter to its own layer. | |
try | |
{ | |
// get the active document | |
var doc = app.activeDocument; | |
} | |
catch( e ) | |
{ | |
doc = null; | |
} | |
if ( doc != null ) | |
{ | |
// get the active layer | |
var target = doc.activeLayer; | |
if ( target.kind != LayerKind.TEXT || !target.textItem ) | |
{ | |
alert( "To begin, select a Text Layer with the specified Font, Size, and Word you want distributed to layers." ); | |
} | |
else | |
{ | |
//if ( confirm( "Your original layer will be removed, ok?" ) ) | |
{ | |
var str = target.textItem.contents; | |
var set = doc.layerSets.add(); | |
set.name = str + "_layers"; | |
for( var i = 0; i < str.length; ++i ) | |
{ | |
var layer = set.artLayers.add(); | |
layer.name = str[i]; | |
layer.kind = LayerKind.TEXT; | |
layer.textItem.font = target.textItem.font; | |
layer.textItem.size = target.textItem.size; | |
layer.textItem.color = target.textItem.color; | |
layer.textItem.contents = str[i]; | |
} | |
// remove original layer | |
//target.remove(); | |
} | |
} | |
} // doc | |
else | |
{ | |
alert( "You must have an active document." ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment