Skip to content

Instantly share code, notes, and snippets.

@apetrone
Created October 20, 2014 23:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apetrone/26f5a767e82c2c92b9fd to your computer and use it in GitHub Desktop.
Save apetrone/26f5a767e82c2c92b9fd to your computer and use it in GitHub Desktop.
Split Active Layer Text String
// 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