Highlighted

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

Explorer ,
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.

Adobe Community Professional
Correct answer by CarlosCanto | Adobe Community Professional

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();

TOPICS
Scripting

Views

21.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

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

Explorer ,
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.

Adobe Community Professional
Correct answer by CarlosCanto | Adobe Community Professional

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();

TOPICS
Scripting

Views

21.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
Jan 24, 2011 0
Adobe Community Professional ,
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
Reply
Loading...
Jan 30, 2011 0
Explorer ,
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
Reply
Loading...
Jan 30, 2011 0
Adobe Community Professional ,
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
Reply
Loading...
Jan 30, 2011 0
Adobe Community Professional ,
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
Reply
Loading...
Mar 05, 2011 4
Explorer ,
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
Reply
Loading...
Mar 06, 2011 0
Adobe Community Professional ,
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
Reply
Loading...
Apr 13, 2011 1
Explorer ,
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
Reply
Loading...
Apr 13, 2011 0
Adobe Community Professional ,
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
Reply
Loading...
Jul 11, 2011 0
Adobe Community Professional ,
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
Reply
Loading...
Jul 11, 2011 0
New Here ,
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
Reply
Loading...
Sep 28, 2011 0
Adobe Community Professional ,
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
Reply
Loading...
Sep 28, 2011 1
New Here ,
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
Reply
Loading...
Sep 29, 2011 0
New Here ,
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
Reply
Loading...
Oct 13, 2011 0
Adobe Community Professional ,
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
Reply
Loading...
Oct 14, 2011 3
New Here ,
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
Reply
Loading...
Nov 01, 2011 0
New Here ,
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
Reply
Loading...
Jun 17, 2013 0
Adobe Community Professional ,
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
Reply
Loading...
Jun 17, 2013 0
New Here ,
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
Reply
Loading...
Jun 18, 2013 0
New Here ,
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
Reply
Loading...
Jun 18, 2013 0
New Here ,
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
Reply
Loading...
Jul 23, 2013 0
Adobe Community Professional ,
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
Reply
Loading...
Jul 23, 2013 0
New Here ,
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
Reply
Loading...
Jul 23, 2013 0
New Here ,
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
Reply
Loading...
Jul 23, 2013 0
Adobe Community Professional ,
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
Reply
Loading...
Jul 23, 2013 0
New Here ,
Oct 23, 2013

Copy link to clipboard

Copied

Hi Carlos, I've been reading a lot of your responses across several related topics and I think you may be able to help me.

I edit a lot of pdfs from CAD programs and Excel files in Illustrator CS6. Often the pdfs text imports each letter as an individual frame. I found a script called "JoinTextFrames" which allows me to relink the individual letters together when the are selected mannualy as a word or number value.

The script works alright but especially in the excel files it gets tedious to select each group of numbers or string of letters. Also, its not consistant with puctuation like commas, periods or other glyphs.

Would you know a better way script Illustrator to search say at an artboard level; and go across a document identifying each word/number group, based on the coordinates that are touching, to make whole words and numbers?

Long time Adobe user but noob at scripting, Sorry for the long reply. 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
Reply
Loading...
Oct 23, 2013 0
Adobe Community Professional ,
Oct 24, 2013

Copy link to clipboard

Copied

interesting, not sure if it can be easily accomplished...can you share a file?

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
Reply
Loading...
Oct 24, 2013 0
New Here ,
Oct 25, 2013

Copy link to clipboard

Copied

Carlos, I've sent you a private message with links to sample files. Thanks for offering to take a look!

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
Reply
Loading...
Oct 25, 2013 0
New Here ,
Jul 16, 2015

Copy link to clipboard

Copied

Hola. Trato de hacer una macro Excel que hace el contrario de oneCharacterPerTFrame(). Quiero fusionar unos textFrames en solo uno. Me puede ayudar por favor? Gracias por su respuesta.

Hello. I'm trying to make an Excel macro that does the opposite . I mean I want to merge textFrames into only one.

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
Reply
Loading...
Jul 16, 2015 0
Adobe Community Professional ,
Jul 16, 2015

Copy link to clipboard

Copied

Hola guyp

- loop through your text frames,

- get their contents,

- concatenate them into one string

- add a new frame

- write the concatenated string

- remove individual frames (optional)

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
Reply
Loading...
Jul 16, 2015 0
New Here ,
Jul 16, 2015

Copy link to clipboard

Copied

Thanks for your fast answer.

I’m not accustomed at all to work with Illustrator. I do it for a friend of mine who is a graphic designer. She has to paste pie charts from Excel to Illustrator.

When in Excel, the data label associated with a piece of the chart, for example, “Québec – 1 235 – 12%” ,  is one string but when pasted into Illustrator, it becomes 4 textframes: Quebec, 1, 235 and 12%.

I’ll do some research over Internet to learn more about the VBA object model and try to get something out of it.

Gracias otra vez por haber contestado tan rapido a mi pregunta.

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
Reply
Loading...
Jul 16, 2015 0
Adobe Community Professional ,
Jul 16, 2015

Copy link to clipboard

Copied

You're welcome, most of what you need is done in my first post in this thread.

Look at this post, it covers the basics

https://forums.adobe.com/message/7652442#7652442

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
Reply
Loading...
Jul 16, 2015 0
New Here ,
Jul 22, 2015

Copy link to clipboard

Copied

Good morning Sir,

The code I did to merge individual textFrames into one works fine when the textFrames are located on the same line. I mean with a separator being a point, a comma, a semicolon or a space.

Ex: Quebec; 3064; 25%

But when the separator is a new line, VBA raises a "Mismatch type" error because it doesn't see each line as a textFrame anymore but as a groupItem containing textFrames, each line being Item1 of the textFrames collection from wich I can see the contents.

Ex: Québec

      3064

      25%

This part of the code works fine.

However, the error is raised at this part highlighted in blue.

I hope you can give me a hint in order to fix it.

Thanks.

Here is the complete code I used

' ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Sub MergeTextFramesTest()
    Dim IApp As New Illustrator.Application
    Dim IDoc As Illustrator.Document
    Dim IFrame As Illustrator.TextFrame
    Dim IFrameNew As Illustrator.TextFrame

    Dim i As Integer

    Dim dblLeft As Double
    Dim dblTop As Double

    Dim StartIndex As Long
    Dim EndIndex As Long

    Dim strTextFrame As String

    Dim selectedObjects  'Array

    Set IDoc = IApp.ActiveDocument

    strTextFrame = ""

    For Each IFrame In IDoc.TextFrames
      Debug.Print IFrame.Contents
    Next

    If Not IsEmpty(IDoc.selection) Then

        selectedObjects = IDoc.selection
        StartIndex = UBound(selectedObjects)
        EndIndex = LBound(selectedObjects)
        Set IFrame = selectedObjects(StartIndex)

    ' Get the location of the first textFrame
    ' Later the new textFrame will be located at this position
        dblLeft = IFrame.Left
        dblTop = IFrame.Top

        For i = StartIndex To EndIndex Step -1  ' Step - 1 pour que la lecture se fasse de droite à gauche sinon c'est l'inverse

            strTextFrame = strTextFrame & selectedObjects(i).Contents
            'selectedObjects(i).Delete           
        Next

        ' Add a new textFrame with the string concaneted
        Set IFrameNew = IDoc.TextFrames.Add
        IFrameNew.Contents = strTextFrame
        ' Place the textframe at the position of the first individual textFrame
        IFrameNew.Top = dblTop
        IFrameNew.Left = dblLeft
        ' Assign original police and size
        IFrameNew.TextRange.CharacterAttributes.TextFont = IApp.TextFonts.Item(IFrame.TextRange.CharacterAttributes.TextFont.Name)
        IFrameNew.TextRange.CharacterAttributes.Size = IFrame.TextRange.CharacterAttributes.Size

        ' Delete individual textFrames
        For i = StartIndex To EndIndex Step -1

            selectedObjects(i).Delete

        Next

    Else

        MsgBox "You must select textFrames you want to merge"

    End If

    Set IFrame = Nothing
    Set IFrameNew = 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
Reply
Loading...
Jul 22, 2015 0
New Here ,
Jul 23, 2015

Copy link to clipboard

Copied

Everything is Ok. I loop through the items selected, these objects were previously stored in an array, then I check the TypeName property.

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
Reply
Loading...
Jul 23, 2015 0
Adobe Community Professional ,
Jul 23, 2015

Copy link to clipboard

Copied

Good to hear

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
Reply
Loading...
Jul 23, 2015 0
New Here ,
Apr 25, 2016

Copy link to clipboard

Copied

Hello CarlosCanto

If I make change in this line

     var words = tFrames.contents.split(/\r/g)

the script that splits selected texFrames into separate words works, but arranges split paragraphs horizontally.

Can you please modify the script to split correctly a block of selected text to paragraphs?

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
Reply
Loading...
Apr 25, 2016 0
New Here ,
Mar 26, 2018

Copy link to clipboard

Copied

Hi,

This is nice code but here are some problems you should modify it. This code is not able to break the Multi text line it is working only single line text. but if it apply on multi line text (means on paragraph) then the second line text break but make a cluster in the end of first line. because here the position of y should be change for multi line could you please modify it...

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
Reply
Loading...
Mar 26, 2018 0
Adobe Community Professional ,
Mar 26, 2018

Copy link to clipboard

Copied

use the Wundes script linked in post # 51 to break paragraphs into lines then use my script to break each line into 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
Reply
Loading...
Mar 26, 2018 0
New Here ,
Apr 02, 2018

Copy link to clipboard

Copied

I use that script but that is working like this (2nd, 3rd, 4th..... nth line break in words and add in first line continuously) but the requirement is break words should be in that position in which the paragraph were before breaking the text. If is it possible then help me please.. Thanks a lot.......

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
Reply
Loading...
Apr 02, 2018 0
Adobe Community Professional ,
Oct 29, 2019

Copy link to clipboard

Copied

Hi neilb69570407 and ahablett, something happened to the script when it was migrated to the new platform. 

 

try this version

 

#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[k].position[0]; // get x
		var ypos = tFrames[k].position[1]; // get y
		var words = tFrames[k].contents.split(/\s/g); // get all words into an array
		//$.writeln(words);
		var space = tFrames[k].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[i]; // 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[k].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
Reply
Loading...
Oct 29, 2019 0
Explorer ,
Nov 06, 2019

Copy link to clipboard

Copied

Thanks Carlos!

Could you amend the 'split by characters' script as well?  It gives the same error.

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
Reply
Loading...
Nov 06, 2019 0
New Here ,
Nov 06, 2019

Copy link to clipboard

Copied

Carlos, I tried the updated script, and got the error below. Thank you for the time you're putting into this, I can't believe you've been answering this question for eight years. That's some serious patience and tenacity.

Screen Shot 2019-11-06 at 12.08.52 PM.png
@neilb69570407, Were you able to get the script to run successfully? 

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
Reply
Loading...
Nov 06, 2019 0
Adobe Community Professional ,
Nov 08, 2019

Copy link to clipboard

Copied

Hi ahablett, 8 years and counting 🙂

the new forum migration really messed up with the arrays. I'll re-post the original script in a separate response so it doesn't get buried in this thread.

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
Reply
Loading...
Nov 08, 2019 0
Adobe Community Professional ,
Nov 08, 2019

Copy link to clipboard

Copied

here's the re-post of the Split Words into Characters script

 

#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[k].position[0]; // get x
		var ypos = tWord[k].position[1]; // get y
		var charCount = tWord[k].characters.length; // count characters
 
		for (i=charCount-1 ; i>=0 ; i--) // loop thru characters backwards
			{
				var ichar = tWord[k].duplicate(); // duplicate textFrame
				ichar.contents = tWord[k].characters[i].contents; // get last character
				tWord[k].characters[i].remove(); // remove last character from original word
				var width = tWord[k].width; // get the new width (without the last character)
				ichar.position = [xpos+width,ypos]; // position the character = original position + new width
			}
		
		tWord[k].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
Reply
Loading...
Nov 08, 2019 0
New Here ,
Nov 10, 2019

Copy link to clipboard

Copied

Hey Carlos, 

This is the message I get with this script running Adobe CC (2019) on a mac. Let me know if there's any other info you need or resources I can research to figure out how to get the scripts to work—the word separation one specifically would save days of work. I'm grateful for this thread to show it's even a possibility. 🙂 

 

Screen Shot 2019-11-10 at 4.11.33 PM.png

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
Reply
Loading...
Nov 10, 2019 0
Adobe Community Professional ,
Nov 10, 2019

Copy link to clipboard

Copied

Hi ahablett, did you use the latest script I posted yesterday? can you show a screen shot of you selected text including your layers expanded?

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
Reply
Loading...
Nov 10, 2019 0
New Here ,
Nov 10, 2019

Copy link to clipboard

Copied

I would have sworn on a bible that I did, but going back and redoing the process to take screenshots for you, I must have followed directions right this time, and splitSelectedFramesIntoWords2.0.jsx works like a charm. Thank you for your script and patience, I am so stoked to use this tool!

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
Reply
Loading...
Nov 10, 2019 0
Adobe Community Professional ,
Nov 10, 2019

Copy link to clipboard

Copied

you're welcome, I'm happy to hear that...you know, almost 9 years later, this script is still rocking.

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
Reply
Loading...
Nov 10, 2019 0
Resources