Skip to main content
moebius_tm
Known Participant
November 19, 2009
Answered

How to duplicate a text item and convert it to paths?

  • November 19, 2009
  • 2 replies
  • 1247 views

Hi,

I'm totally stuck. I can't seem to duplicate a selected TextFrame and make an outline of it. I tried "MyChoice.TextFrame.createOutline()" but it told me that "undefined is no object". What am i doing wrong?

Environment: Illustrator CS4, ExtendScriptToolkit, Javascript.

Help!

moebius

This topic has been closed for replies.
Correct answer sonicDream

var mySelection = app.activeDocument.selection;

for(j = mySelection.length - 1; j >=0; j--){

     //alert(mySelection.typename)

     if(mySelection.typename == "TextFrame") {

          mySelection.createOutline();

     }

}

there are a few things that you mixed up ... as i dun have time right now to explain, above is a working code(i think so ... ) ... i'll return later with an explanation

cheers;

2 replies

MarkWalsh
Inspiring
November 19, 2009

What does 'MyChoice' refer to? I would assume that it is undefined, or it does not contain a TextFrame object as one of it's member properties. You might need to dig deeper to get to the TextFrame if it has one.

moebius_tm
Known Participant
November 19, 2009

What does 'MyChoice' refer to? I would assume that it is undefined, or it does not contain a TextFrame object as one of it's member properties. You might need to dig deeper to get to the TextFrame if it has one.

Earlier in my script i set "var MyChoice = app.activeDocument.selection;" so it is not undefined. But it seems as if i messed some things up. Sonics code works an i learned that my selection (it IS a TextFrame) is not recognized as a TextFrame until i dig into the darn thing. Sorry, i'm a complete noob.

Moebius

Larry G. Schneider
Community Expert
Community Expert
November 19, 2009

Also notice that sonic is working backwards through the list so as not to disrupt the indexing of the selection.

sonicDreamCorrect answer
Participating Frequently
November 19, 2009

var mySelection = app.activeDocument.selection;

for(j = mySelection.length - 1; j >=0; j--){

     //alert(mySelection.typename)

     if(mySelection.typename == "TextFrame") {

          mySelection.createOutline();

     }

}

there are a few things that you mixed up ... as i dun have time right now to explain, above is a working code(i think so ... ) ... i'll return later with an explanation

cheers;

moebius_tm
Known Participant
November 20, 2009

What i have made of it is this:

var mySelection = app.activeDocument.selection;
var Anzahl = mySelection.length;

if (Anzahl ==1) {

for(j = mySelection.length - 1; j >=0; j--){
  if(mySelection.typename == "TextFrame") {
   var Links = mySelection.left;
   var Oben = mySelection.top;
   app.copy();
   app.paste();
   var Kopie = app.activeDocument.selection;
   Kopie.top = Oben;
   Kopie.left = Links;
   Kopie.createOutline();
  }
  else {
   alert("Auswahl ist kein Text!","Fehlermeldung:")
  }
}
}

else {
alert("Bitte nur genau einen Textrahmen auswählen!", "Fehlermeldung:")
}

It makes a nice duplicate of my selected TextFrame, places it at the same coordinates and converts it to outlines.

Thanks to the kind helping in this forum i learned a lot (again) by doing this.

What i plan to do further is to set my copy to left oriented and change its entire content to a single capital "M" so i can conveniently measure the versal-height of the used font.

Maybe i'll come back to this later.

For the time being, thanks a lot for the friendly advice i get here.

It's much appreciated.

moebius

P.s.: I just recognized, that the for-loop is no longer necessary as i make sure, that only one element is selected by the "if (Anzahl ==1)"- Statement.

P.p.s: Just tried the above. Found that this doesn't work. No idea why.

Nachricht geändert durch moebius_tm

Participating Frequently
November 20, 2009

var mySelection = app.activeDocument.selection;

if (mySelection.length == 1) {

if(mySelection[0].typename == "TextFrame") {
   var Links = mySelection[0].left;
   var Oben = mySelection[0].top;
   app.copy();
   app.paste();
   var Kopie = app.activeDocument.selection[0];
   Kopie.top = Oben;
   Kopie.left = Links;
   Kopie.createOutline();
  }
  else {
   alert("Auswahl ist kein Text!","Fehlermeldung:");
  }
}
}

else {
alert("Bitte nur genau einen Textrahmen auswählen!", "Fehlermeldung:");
}

do not forget that selection is ALWAYS an array whatever the length of the objects within is.

cheers;