Seperating text onto seperate layers

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

saltedm8

Seperating text onto seperate layers

Post by saltedm8 »

I am thinking of doing some kinetic typography pieces in after effects but I have come across a pretty basic issue that would need a script to separate the text and then import them into after effects

I went hunting for one and found this http://www.agasyanc.ru/text-splitter looks like it does exactly what I wanted so I installed it and tried to use it but I was hit by this error
Error 8500: The requested property does not exist.

Line: 9
-> if (layer.textItem.useAutoLeading){
I am presuming because I have CS6, the person that made it had an older version, but I have hunted high and low for another but cannot find one, I have even looked for illustrator and although in illustrator there is a way to do it (lost the video now) it still takes time to do

Would anyone be able to fix that script, write another one or even point one out to me.

Thank you

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Mike Hale

Seperating text onto seperate layers

Post by Mike Hale »

I think there must be something else that is causing that error for you. That property does exists in Photoshop CS6 and that script works for me in CS6 and Photoshop CC
saltedm8

Seperating text onto seperate layers

Post by saltedm8 »

can I ask exactly how you are doing the text.. maybe I am doing something wrong.
saltedm8

Seperating text onto seperate layers

Post by saltedm8 »

sorry, just to add to that, I forgot to mention I am on a mac, dont know if that makes any difference
Mike Hale

Seperating text onto seperate layers

Post by Mike Hale »

I am using Windows but I don't think that would cause the property error.

I just created a new text layer and added a enter/return after I typed each word. I typed 3 or 4 words. All the char and paragraph settings were the defaults. Myriad Pro Regular 36pt. Don't think it would cause that error but the ruler was set to pixels. I would think if the ruler settings mattered the script would still run without errors just the results would not be as expected.
xbytor

Seperating text onto seperate layers

Post by xbytor »

For some reason, useAutoLeading is not getting set correctly when the text layer is loaded or created in CS6.
You need to make this change in order for it to work.
Code: Select all    try { layer.textItem.leading; } catch (e) { layer.textItem.useAutoLeading = true; }

    if (layer.textItem.useAutoLeading){



Edit: I saw this behaviour on a Mac. I simply created a new doc with a text layer with a few words in it. Ruler and Type units were set to pixels.
saltedm8

Seperating text onto seperate layers

Post by saltedm8 »

Sorry xbytor, I know literally nothing about scripts (although it looks like a very interesting area and I might look into it a little later), where in the script would I change or add that code?

thanks

p.s and thanks Mike, I will give those settings a go just in case
saltedm8

Seperating text onto seperate layers

Post by saltedm8 »

Oh.. so sweet

I cannot be bothered to test it at the moment but there might be an issue with that script using all caps, I was also trying to type in a line without using <enter> so it was not working

with a lot of messing about I discovered where that script you supplied was suppose to go, thank you very much I really appreciate it.

Code: Select alldoc = app.activeDocument;
layer = doc.activeLayer;

var text = layer.textItem.contents;
var textArray = text.split("\r");

var pos = layer.textItem.position;
var leading = 0;try { layer.textItem.leading; } catch (e) { layer.textItem.useAutoLeading = true; }
if (layer.textItem.useAutoLeading){
        leading = layer.textItem.size/100*Math.round(layer.textItem.autoLeadingAmount)
     
}
else{
    leading = Number(layer.textItem.leading)
}

layer.textItem.contents=textArray[0]
layer.name = textArray[0]
for (var k=1; k<textArray.length;k++){
    tmp = layer.duplicate();
    tmp.textItem.position = [pos[0], pos[1]+(Number(leading)*k)]
    tmp.textItem.contents = textArray[k];
}