Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Script error

Engaged ,
Feb 05, 2022 Feb 05, 2022

Hi community.

 

I tried to run a script which breaks up text to become individual object, but still live text, and I get this following error

 

StefanCargoski_0-1644053949725.png

 

Original post can be viewed here:

https://community.adobe.com/t5/illustrator-discussions/how-to-break-apart-in-illustrator/m-p/1272914...

 

 

 

TOPICS
Scripting
924
Translate
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 2 Correct answers

Community Expert , Feb 05, 2022 Feb 05, 2022

I have an older version and as pixxelschubser remarked the [i] is missing. Here is the old version:

#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 = tW
...
Translate
Community Expert , Feb 05, 2022 Feb 05, 2022

@Stefan Cargoski 

As I said before: the migration of the forum has destroyed many good old scripts.

 

Replace:

 

ichar.contents = tWord.characters.contents;
tWord.characters.remove();

 

with:

 

ichar.contents = tWord.characters[i].contents;
tWord.characters[i].remove();

 

 

Translate
Adobe
Community Expert ,
Feb 05, 2022 Feb 05, 2022

There are several script versions in the linked thread. Please link to the specific script or post the code. The (new) forum migration to Khoros really messed up with the arrays. Mostly a counter like [i] is missing.

Translate
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
Engaged ,
Feb 05, 2022 Feb 05, 2022

This is the script which is shown as correct:

 

 

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

Translate
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
Community Expert ,
Feb 05, 2022 Feb 05, 2022

I have an older version and as pixxelschubser remarked the [i] is missing. Here is the old version:

#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[i].contents;  
          tWord.characters[i].remove();  
          var width = tWord.width;  
          ichar.position = [xpos+width,ypos];  
     }  
tWord.remove();  

 

Translate
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
Engaged ,
Feb 05, 2022 Feb 05, 2022

Finally it worked.

 

Kind regards.

Translate
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
Community Expert ,
Feb 05, 2022 Feb 05, 2022

@Stefan Cargoski 

As I said before: the migration of the forum has destroyed many good old scripts.

 

Replace:

 

ichar.contents = tWord.characters.contents;
tWord.characters.remove();

 

with:

 

ichar.contents = tWord.characters[i].contents;
tWord.characters[i].remove();

 

 

Translate
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
Engaged ,
Feb 05, 2022 Feb 05, 2022

Thank you!

Translate
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
Community Expert ,
Feb 05, 2022 Feb 05, 2022

Hi @Ton Frederiks 

You were two minutes faster.

😉

Translate
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
Community Expert ,
Feb 05, 2022 Feb 05, 2022

Happens to me all the time 🙂

Translate
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
Community Expert ,
Feb 05, 2022 Feb 05, 2022
LATEST

This question is well and truly answered, but for those who are interested, I posted a further version of the splitting script under the original post. It has a few advantages I think.

- Mark

Translate
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