Skip to main content
Known Participant
February 5, 2023
Answered

Convert all text into point text script?

  • February 5, 2023
  • 2 replies
  • 2061 views

I want to convert all text layer into point text. I usually select all text layers, then run the "convert to point text" action. However, not all layers are the same, so paragraph text will convert to point text, and point text will turn to paragraph, they only switch back and forth, but cannot be converted to a unified type (point text).
My file contains a lot of text layers, and I can't check which is point text or paragraph. Because I tried with actions, so I think scripting will be more efficient.

Thank you everyone for help!

This topic has been closed for replies.
Correct answer r-bin

Try this (not a very fast script).

 

function a(layers, kind)
    {
    try {
        for (var i = 0; i < layers.length; i++)
            {
            if (layers[i].kind == LayerKind.TEXT) layers[i].textItem.kind = kind;

            if (layers[i].layers != undefined) a(layers[i].layers, kind);
            }
        }
    catch (e) { alert(e); }
    }

a(activeDocument.layers, TextType.POINTTEXT);

 

 

2 replies

r-binCorrect answer
Legend
February 6, 2023

Try this (not a very fast script).

 

function a(layers, kind)
    {
    try {
        for (var i = 0; i < layers.length; i++)
            {
            if (layers[i].kind == LayerKind.TEXT) layers[i].textItem.kind = kind;

            if (layers[i].layers != undefined) a(layers[i].layers, kind);
            }
        }
    catch (e) { alert(e); }
    }

a(activeDocument.layers, TextType.POINTTEXT);

 

 

Known Participant
February 6, 2023

Thank you very much, it worked great!

PECourtejoie
Community Expert
Community Expert
February 5, 2023
Known Participant
February 6, 2023

Thank you for your answer! I did, but I have no experient about scripting, so when I tried pixxxelschubser's suggesting, the result was the same as when I used action. By the way, r-bin has solved my problem, I'm satisfied now ^^

pixxxelschubser
Community Expert
Community Expert
February 6, 2023
quote

… so when I tried pixxxelschubser's suggesting, the result was the same as when I used action …


By @Le27921535n6i8

 

😉

Yes, that was also a different topic seven years ago. At that time, it was essentially about showing how to basically switch from paragraph text to point text and back again with a script.

 

It was more of a manual than a finished script:

quote

… convert paragraph text to point text (and also in the other direction) is a "destructiv" process …


By @pixxxelschubser

 

 

I'm glad your problem has been solved by @r-bin