Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


How to divide all textFrames in one-character-per-textFrame?

Explorer ,
Jan 24, 2011 Jan 24, 2011

Copy link to clipboard

Copied

Hello:

How to divide all textFrames in one-character-per-textFrame?

Example: the textFrame "Letters" will be divided in 7 textFrames: "L", "e", "t", "t", "e", "r", "s".

Help, please.

TOPICS
Scripting

Views

23.6K

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Mar 05, 2011 Mar 05, 2011
Hi Victor, here's the JS version, sorry for the delay#target Illustrator//  script.description = splits selected texFrame into separate characters;//  script.required = select a point text textFrame before running;//  script.parent = CarlosCanto;  // 3/5/11//  script.elegant = false;var idoc = app.activeDocument;var tWord = idoc.selection[0];var xpos = tWord.position[0];var ypos = tWord.position[1];var charCount = tWord.characters.length;for (i=charCount-1 ; i>=0 ; i--)     {          var ichar ...

Likes

Translate

Translate
Adobe Community Professional ,
Jan 30, 2011 Jan 30, 2011

Copy link to clipboard

Copied

here's how to do it with VBA, a copy in blue shown underneath.

oneCharPerFrame.PNG

Sub oneCharacterPerTFrame()

    Dim Iapp As New Illustrator.Application

    Dim Idoc As Illustrator.Document

    Dim tWord As Illustrator.TextFrame

    Dim tCharacter As Illustrator.TextFrame

    Dim a As Integer

    Dim b As Integer

    Set Idoc = Iapp.ActiveDocument

    Set tWord = Idoc.TextFrames(1)

    x = tWord.Position(0)

    y = tWord.Position(1)

    a = tWord.Characters.Count

    For b = a To 1 Step -1

        Set tCharacter = Idoc.TextFrames.Add

        tCharacter.Contents = tWord.Characters(b).Contents

        tWord.Characters(b).Delete

        w = tWord.Width

        tCharacter.Position = Array(x + w, y)

    Next

    tWord.Delete

    Set tCharacter = Nothing

    Set tWord = Nothing

    Set Idoc = Nothing

    Set Iapp = Nothing

End Sub

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 30, 2011 Jan 30, 2011

Copy link to clipboard

Copied

Thanks, Carlos, for your solution, but I have a Mac and Microsoft Visual Basic for Applications does not run on Mac.

Please, do you can translate your code to JavaScript (or AppleScript)?

Best regards.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jan 30, 2011 Jan 30, 2011

Copy link to clipboard

Copied

you're welcome, I have a hard time doing JS, it doesn't seem to stick to my brain....but I'll try.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 05, 2011 Mar 05, 2011

Copy link to clipboard

Copied

Hi Victor, here's the JS version, sorry for the delay

#target Illustrator

//  script.description = splits selected texFrame into separate characters;

//  script.required = select a point text textFrame before running;

//  script.parent = CarlosCanto;  // 3/5/11

//  script.elegant = false;

var idoc = app.activeDocument;

var tWord = idoc.selection[0];

var xpos = tWord.position[0];

var ypos = tWord.position[1];

var charCount = tWord.characters.length;

for (i=charCount-1 ; i>=0 ; i--)

     {

          var ichar = tWord.duplicate();

          ichar.contents = tWord.characters.contents;

          tWord.characters.remove();

          var width = tWord.width;

          ichar.position = [xpos+width,ypos];

     }

tWord.remove();

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 06, 2011 Mar 06, 2011

Copy link to clipboard

Copied

Thanks, Carlos. Your script works perfectly! I am very happy.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 13, 2011 Apr 13, 2011

Copy link to clipboard

Copied

Hi Victor, here's your request, it works on multiple text Frames

#target Illustrator

//  script.name = splitSelectedWordsIntoCharacters.jsx;

//  script.description = splits selected texFrames into separate characters;

//  script.required = select point text textFrames before running;

//  script.parent = CarlosCanto;  // 4/13/11

//  script.elegant = false;

var idoc = app.activeDocument;

var sel = idoc.selection; // get selection

var selCount = sel.length; // count items

var tWord = []; // to hold the textFrames

for (j=selCount ; j>0 ; j--) // loop thru selection & get textFrames backwards

     {

          tWord[j-1] = sel[j-1];

     }

for (k = 0 ; k<tWord.length ; k++) // loop thru textFrames

     {

          var xpos = tWord.position[0]; // get x

          var ypos = tWord.position[1]; // get y

          var charCount = tWord.characters.length; // count characters

          for (i=charCount-1 ; i>=0 ; i--) // loop thru characters backwards

               {

                    var ichar = tWord.duplicate(); // duplicate textFrame

                    ichar.contents = tWord.characters.contents; // get last character

                    tWord.characters.remove(); // remove last character from original word

                    var width = tWord.width; // get the new width (without the last character)

                    ichar.position = [xpos+width,ypos]; // position the character = original position + new width

               }

          

          tWord.remove(); // remove textFrame (it is empty by now)

     }

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 13, 2011 Apr 13, 2011

Copy link to clipboard

Copied

Superb, Carlos! Thanks again.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 11, 2011 Jul 11, 2011

Copy link to clipboard

Copied

Nice, Carlos. Thanks.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 11, 2011 Jul 11, 2011

Copy link to clipboard

Copied

Hi Peter, you're welcome

thanks

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 28, 2011 Sep 28, 2011

Copy link to clipboard

Copied

What an amazing script! Carlos, would you be able to modify this so that instead of breaking apart all characters, it breaks apart all words at any spaces, like "\s"?

Your script is so close to what I need! Apparently it was called the break apart feature in Corel Draw, if I have read about it correctly.

Thank you for the wonderful feature above and anything you can do for me.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Sep 28, 2011 Sep 28, 2011

Copy link to clipboard

Copied

Hi Paul, no problem

#target Illustrator

//  script.name = splitSelectedFramesIntoWords.jsx;

//  script.description = splits selected texFrames into separate words;

//  script.required = select point text textFrames before running;

//  script.parent = CarlosCanto;  // 9/28/11

//  script.elegant = false;

var idoc = app.activeDocument;

var sel = idoc.selection; // get selection

var selCount = sel.length; // count items

var tWord = []; // to hold the textFrames

for (j=selCount ; j>0 ; j--) // loop thru selection & get textFrames backwards

          {

                    tWord[j-1] = sel[j-1];

          }

for (k = 0 ; k<tWord.length ; k++) // loop thru textFrames

          {

                    var xpos = tWord.position[0]; // get x

                    var ypos = tWord.position[1]; // get y

                    var wordCount = tWord.words.length; // count words

                    for (i=wordCount-1 ; i>=0 ; i--) // loop thru words backwards

                              {

                                        var iword = tWord.duplicate(); // duplicate textFrame

                                        iword.contents = tWord.words.contents; // get last word

                                        tWord.words.remove(); // remove last character from original word

                                        var width = tWord.width; // get the new width (without the last character)

                                        iword.position = [xpos+width,ypos]; // position the character = original position + new width

                              }

                    tWord.remove(); // remove textFrame (it is empty by now)

          }

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 29, 2011 Sep 29, 2011

Copy link to clipboard

Copied

Carlos, it is so close! My first attempt resulted with this problem, where spacing is lost between some objects and in one case a word lost both a period and a letter, the string "page. They" became "pag They"

Thank you so much! You are so fast, dude! See the archive linked below.

https://files.me.com/oneillhome/36dtn8

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2011 Oct 13, 2011

Copy link to clipboard

Copied

Carlos, is there any update to fix the problem I saw in the first word, in the punctuation and in the characters/spaces at the end of lines?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Oct 14, 2011 Oct 14, 2011

Copy link to clipboard

Copied

Hi Paul, try this one

#target Illustrator

//  script.name = splitSelectedFramesIntoWords2.0.jsx;

//  script.description = splits selected texFrames into separate words;

//  script.required = select point text textFrames before running;

//  script.parent = CarlosCanto;  // 10/14/11

//  script.elegant = false;

var idoc = app.activeDocument;

var sel = idoc.selection; // get selection

var selCount = sel.length; // count items

var tFrames = []; // to hold the textFrames

for (j=selCount ; j>0 ; j--) // loop thru selection & get textFrames backwards

          {

                    tFrames[j-1] = sel[j-1];

          }

for (k = 0 ; k<tFrames.length ; k++) // loop thru textFrames

          {

                    var xpos = tFrames.position[0]; // get x

                    var ypos = tFrames.position[1]; // get y

                    var words = tFrames.contents.split(/\s/g); // get all words into an array

                    //$.writeln(words);

                    var space = tFrames.duplicate(); // dup to get width of a space

                    space.contents = " ";

                    var sw = space.width;

                    space.contents = words[0]; // replace space with first word

                    var w = space.width;

                    var wordCount = words.length; // count words

                    for (i=1; i<wordCount ; i++) // loop thru words

                              {

                                        xpos2 = xpos+w+sw; // next words position = previous word pos+width+space

                                        var iword = space.duplicate(); // duplicate previous word

                                        iword.contents = words; // add next word

                                        iword.position = [xpos2,ypos]; // position the character = original position + new width

                                        w = iword.width; // get words width

                                        xpos = iword.position[0]; // get words position

                              }

                    tFrames.remove(); // remove textFrame

          }

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 01, 2011 Nov 01, 2011

Copy link to clipboard

Copied

It really works fantastically, Carlos. Thank you so much for your attention on this very specific Illustrator inquiry!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 17, 2013 Jun 17, 2013

Copy link to clipboard

Copied

How do I install your code??

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jun 17, 2013 Jun 17, 2013

Copy link to clipboard

Copied

Copy the above. Open a text editor or the Adobe ESTK utility and paste. Save making sure that is in plain text. Run it in AI by File>Scripts>Other scripts and navigate to the saved script. You must have a file open in AI and some text selected.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 18, 2013 Jun 18, 2013

Copy link to clipboard

Copied

I tried that in a few different ways, but I keep getting this error when I run the script:

Screen shot 2013-06-18 at 12.55.02 PM.png

Any ideas how to fix that?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 18, 2013 Jun 18, 2013

Copy link to clipboard

Copied

Just kidding--I used DreamWeaver this time and found the error. It works!!!! I will be using this script almost every day! THANK YOUUUUU!!!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 23, 2013 Jul 23, 2013

Copy link to clipboard

Copied

Hi Carlos. I used your script and it worked. But, I don't want each individual letter broken apart. Is there a script to break apart a text string by whole words? Thanks

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 23, 2013 Jul 23, 2013

Copy link to clipboard

Copied

Hi, use the script in post # 14, that one works with whole words.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 23, 2013 Jul 23, 2013

Copy link to clipboard

Copied

Thank you so much Carlos. Awesome. Saving me tons of time.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 23, 2013 Jul 23, 2013

Copy link to clipboard

Copied

Carlos saves me on a project way back. He is the king of the forums IMHO.

Stereo thank you to Carlos Canto.

Sent from my iPhone

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 23, 2013 Jul 23, 2013

Copy link to clipboard

Copied

thanks Paul/kaswid I appreciate the feedback

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines