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

Hello, everyone. I often use to replace names and numbers. Is there any script like this in Illustra

Participant ,
Feb 26, 2021 Feb 26, 2021

Copy link to clipboard

Copied

Alt text script122.gif

TOPICS
Feature request , Print and publish , Scripting , Third party plugins

Views

1.6K

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

Advocate , Mar 10, 2021 Mar 10, 2021

Salut Lengxiaomo!

Comme promis, j'ai simplifié au maximum.

Il suffit de sélectionner une de tes listes et de renseigner le texte à remplacer.

Dans mon test, j'ai utilisé 88 et AA.

Sans titre - 1.png

Bonne réception

René

 

// JavaScript Document for Illustrator
// text-in-cercle-reduit_liste.jsx
// Author Landry René
// Tue, 9 March 2021 18:04:45 GMT
#target Illustrator
// INIT ------------
var debut = 0;     // Start num
var textRep = "88"; // contenu du texte à rechercher
var ecart = 4; // écart en pt toléré dans une li
...

Votes

Translate

Translate
Adobe
Engaged ,
Feb 28, 2021 Feb 28, 2021

Copy link to clipboard

Copied

You don’t say where your source text is coming from, but assuming a text file (e.g. Excel-exported CSV) this is the sort of work for which you’d typically use AI’s built-in Variable Data features. Here are some (free/paid) tutorials:

 

https://www.youtube.com/watch?v=mpwXj2E7YNA

 

https://www.lynda.com/Illustrator-tutorials/Welcome/450909/489328-4.html

 

https://helpx.adobe.com/illustrator/using/data-driven-graphics-templates-variables.html

 

https://www.christianda.com/blog-variable-data.html

 

Votes

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
Participant ,
Feb 28, 2021 Feb 28, 2021

Copy link to clipboard

Copied

The source text is manually copied to AI. I want to replace the name and number like gif picture presentation. thank you

Votes

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
Engaged ,
Feb 28, 2021 Feb 28, 2021

Copy link to clipboard

Copied

For that you’ll need a script. Something like:

 

(function() {

function copyLinesToFrames(frameName) {
	var textFrames = app.activeDocument.textFrames
	var values = textFrames.getByName(frameName).contents.replace(/^\s+|\s$/g, "").split(/[\r\n]/)
	for (var i = 0; i < values.length; i++) {
			textFrames.getByName(frameName+"_"+(i+1)).contents = values[i]
	}
}

copyLinesToFrames("names")
copyLinesToFrames("ages")

})()

 

This assumes two existing text frames, named “names” and “ages”, into which you’ll paste the source text.

 

The corresponding frames on the artworks must be named “names_1”, “names_2”, …, “names_7”, and “ages_1”, “ages_2”, …, “ages_7”.

 

Use the Layers palette to name your text frames. (If the Layers palette currently displays only layer names, click the menu at its top-right and change the Panel Options preferences to show all objects.)

 

The script assumes the number of lines of text wll always match the number of text frames on the artworks. I’ve not bothered with error checking; you can add that yourself if you need it.

Votes

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
Engaged ,
Feb 28, 2021 Feb 28, 2021

Copy link to clipboard

Copied

Amusingly, I just thought of a much simpler solution: just link your artworks’ text frames so that you paste the text directly into the first frame and it flows automatically from one to the next. As long as each text frame is the height of a single line of text and none of the lines overflow, you’re sorted.

 

(One advantage of a scripted approach is it can check for overflowing lines and adjust automatically, e.g. by tightening tracking and/or reducing horizontal scaling until each line fits the available width. That would require additional code to detect overflows and adjust character attributes according to your design guidelines, of course.)

Votes

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
Participant ,
Mar 01, 2021 Mar 01, 2021

Copy link to clipboard

Copied

Thank you for your help. The last question is how to implement the script. I hope you can help me again. Thank you very much

12C4F519-43BD-4019-90DE-33FE9891612B.gif

Votes

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
Engaged ,
Mar 01, 2021 Mar 01, 2021

Copy link to clipboard

Copied

I am not sure what you’re asking. Are you talking about moving the numbers slightly left or right to visually equalize the negative space on each side?

 

I don’t think there’s anything in AI that would do that for you automatically (e.g. optical kerning only works inbetween characters; overhanging punctuation only works for punctuation). Aesthetic choices generally require human decisions. Once you’ve decided (e.g.) “1” needs to move 0.3pt right and “6” needs to move -0.2pt, you could encode those choices so the next time the same numbers come up the script moves them automatically. That’d be worth doing if the same numbers appear frequently. Although that is more than a two-minute job, if you’re looking for someone to develop it for you.

Votes

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
Community Expert ,
Mar 08, 2021 Mar 08, 2021

Copy link to clipboard

Copied

Hi,

Could you please attach you sample ai file?

 

Best regards

Votes

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
Participant ,
Mar 08, 2021 Mar 08, 2021

Copy link to clipboard

Copied

Votes

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
Advocate ,
Mar 09, 2021 Mar 09, 2021

Copy link to clipboard

Copied

Salut!

Pour l'alignement, sélectionner plusieurs objets plus ALT-clic sur le vètement.

tutu.png

Je peux faire votre script, me contacter par mail.

René

Votes

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
Advocate ,
Mar 09, 2021 Mar 09, 2021

Copy link to clipboard

Copied

J'ai édité un sript similaire:

Remplace tous les textes "88" par le contenu d'une liste.

Sans titre - 4.png

de elleere (LR)

 

 

Votes

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
Participant ,
Mar 09, 2021 Mar 09, 2021

Copy link to clipboard

Copied

Hi renél80416020, thanks for your advice ,and it give me a way to solve it. and it will improve the speed, and we can finsh the job without overtime.

and i just graduate form the high school, so i have not too much money now, and i need this job for my home
can you make it for me for free, and i will be very appreciate it

Votes

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
Advocate ,
Mar 09, 2021 Mar 09, 2021

Copy link to clipboard

Copied

Salut Lengxiaomo!

En fait mon script a été fait pour un client dans un besoin très spécifique, je dois donc utiliser la partie utile pour toi.
Afin de faire un nouveau script qui correspond exactement à tes besoins.

Pour l'instant, j'ai simplement fait un test sur le script existant.

Promis, je regarde ce soir...

Ce que devait faire le script:
Remplacer les étiquettes (88) qui renvoient à un glossaire, ligne par ligne par des nombres croissants à partir d'une valeur de départ afin de traiter plusieurs documents à la suite...

(Documents pouvant contenir plusieurs pages)
De la gauche vers la droite comme sur cet extrait ou de la droite vers la gauche pour un texte en langue arabe.

renél80416020_0-1615313606596.png

elleere

Votes

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
Participant ,
Mar 09, 2021 Mar 09, 2021

Copy link to clipboard

Copied

Thank you for your help. Manual operation is too time-consuming. I hope you can help me solve this problem. Thank you

Votes

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
Advocate ,
Mar 10, 2021 Mar 10, 2021

Copy link to clipboard

Copied

Salut Lengxiaomo!

Comme promis, j'ai simplifié au maximum.

Il suffit de sélectionner une de tes listes et de renseigner le texte à remplacer.

Dans mon test, j'ai utilisé 88 et AA.

Sans titre - 1.png

Bonne réception

René

 

// JavaScript Document for Illustrator
// text-in-cercle-reduit_liste.jsx
// Author Landry René
// Tue, 9 March 2021 18:04:45 GMT
#target Illustrator
// INIT ------------
var debut = 0;     // Start num
var textRep = "88"; // contenu du texte à rechercher
var ecart = 4; // écart en pt toléré dans une ligne en dessous de la valeur Maxi
//---------------------------
if ( app.documents.length > 0 ) {
  var result, textRef;
      result = false;
    if (selection.length != 0){
      textRef = selection[0];
        if (textRef.typename == "TextFrame") {
          var kk = textRef.contents.split(/[\r\n]/);
          if (kk.length) dlg();
        }
    }
  if (result) main();
}
//-------------------------------
function dlg() {
    var res = "dialog { \ properties:{ closeButton: false \
          } \
        msgPnl: Panel { orientation: 'column' , \
          margins: [0,20,10,10] , \
          text: 'Text to be replaced :', \
          paramGrp: Group { orientation: 'row', \
            s: StaticText { text:' ' }, \
            e: EditText { text: nom, characters: 20 } \
            } \
        } \
        buttons: Group { orientation: 'row', alignment: ['center', 'top'] , \
          okBtn: Button { text:'OK', properties:{name:'ok'} }, \
          cancelBtn: Button { text:'Cancel', properties:{name:'cancel'} } \
        } \
      }"; // end res

    win = new Window (res);
    win.text = 'Script de elleere';
    win.spacing = 8;
    win.frameLocation = [200,200];
      //------------------
      win.buttons.okBtn.onClick = function() {
          textRep = win.msgPnl.paramGrp.e.text;
          result = true; win.close();
      }
      //------------------
      win.buttons.cancelBtn.onClick = function() {
        result = false; win.close();
      }
      // Init value dialog
      win.msgPnl.paramGrp.e.text = textRep;
      win.msgPnl.paramGrp.e.active = true;
    win.show();
}
//--------------------
function main() {
  var nb, maxiV, k, texts, i, n, tp;
  var t88 = [];
      maxiV = -Infinity;
      k = debut;
      texts = app.activeDocument.textFrames;
      nb = texts.length;

      for (i = 0; i < nb; i++) {
        if (texts[i].contents == textRep) {
          t88.push(texts[i]);
        }
      }

    while(t88.length > 0) {
      // recherche top maxV
      for (i = 0; i < t88.length; i++) {
        tp = t88[i].top;
        maxiV = Math.max(maxiV,tp);
      }
      // liste ligne la plus haute tV
      var tV = [];
          nb = t88.length;
      for (i = nb-1; i >= 0; i--) {
        if(t88[i].top >= maxiV-ecart && t88[i].top <= maxiV) {
          tV.push(t88[i]);
          t88.splice(i,1);
        }
      }
      // position left dans tV
      var tlf = [];
      for (n = 0; n < tV.length; n++) {
        tlf.push(tV[n].left);
      }
      tlf.sort
      // traite ligne tV
        while (tV.length > 0 && k < kk.length) {
          for (n = 0; n < tV.length; n++) {
              if (tV[n].left == tlf[0]) {
                tV[n].contents = kk[k];  k++;
                tV.splice(n,1);
                tlf.splice(0,1);
              }
              else continue;
          }
        }
      maxiV = -Infinity; // ligne suivante
   }
}
//--------------------

 

Votes

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
Participant ,
Mar 10, 2021 Mar 10, 2021

Copy link to clipboard

Copied

sorry, i just try to do it as you said, But i do not know how to use it.
can you show it to me by video ?

Votes

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
Advocate ,
Mar 10, 2021 Mar 10, 2021

Copy link to clipboard

Copied

C'est poutant simple ?

toto03.PNG

Ok pour effectuer l'action

Remarque: ne pas utiliser de sauts de ligne forcés dans la liste

car \n peut ne pas être pris en compte suivant la version de AI

Sinon changer la ligne 17 par

var kk = textRef.contents.split(RegExp("[\r"+String.fromCharCode(3)+"]"));

Cordialement René

 

 

Votes

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
Participant ,
Mar 10, 2021 Mar 10, 2021

Copy link to clipboard

Copied

Hello renél80416020   After change the text in the script, can you make it in the centr123.gifal

Votes

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
Advocate ,
Mar 11, 2021 Mar 11, 2021

Copy link to clipboard

Copied

Salut Lengxiaomo!

Je pense avoir résolu ton problème, à toi de gérer le reste...
Il suffit que les éléments de chaque groupes soient centrés verticalement avant l'exécution du script.

A partir d'un groupe centré, par déplacement (translation et copie) cela se fait en moins de 20 secondes.

René

 

 

Votes

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
Participant ,
Mar 11, 2021 Mar 11, 2021

Copy link to clipboard

Copied

LATEST

Ok thanks for your help

Votes

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