Quantcast
Channel: Adobe Community: Message List - InDesign Scripting
Viewing all articles
Browse latest Browse all 37788

Create charater based on a txt file

$
0
0

Y have a text file separeted by tabs with the definitions of the charater style that y want to create, but in some font name it gets error (example Lucida Math Std and Frutiger LT Std.

The file was exported by the same way, so y don't undestand why. can someone help me pleeeeeaaaase!!!

 

Here's the file:

 

NomeFonte
Horizontal ScaleVertical ScaleCor% de CorBaseline ShiftLinguagemBasedo em
vverbete.lexeger.exeger.tbregHelvetica LT StdLight Condensed100100C=0 M=70 Y=0 K=01000Portuguese: Orthographic Agreement[None]
efaux3Helvetica LT StdRoman100100C=100 M=0 Y=0 K=601000Portuguese: Orthographic Agreement[None]
efaux4Lucida Math StdSymbol100100C=20 M=100 Y=50 K=01000Portuguese: Orthographic Agreement[None]
vverbete.divisao.catgram.aceps.numITC Novarese StdBold100100C=0 M=100 Y=100 K=01000Portuguese: Orthographic Agreement[None]
vverbete.divisao.catgram.aceps.subacep.traduz.trad_iFrutiger LT Std46 Light Italic100100C=100 M=0 Y=0 K=201000Portuguese: Orthographic Agreement[None]
vverbete.divisao.catgram.aceps.subacep.traduz.trad_ibFrutiger LT Std66 Bold Italic100100C=100 M=0 Y=0 K=501000Portuguese: Orthographic Agreement[None]

 

 

Here's the script:

 

main();

 

function main(){

          var myObject;

          //Make certain that user interaction (display of dialogs, etc.) is turned on.

          app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

          if(app.documents.length > 0){

                    myCreateStyles(app.documents.item(0));

          }

          else{

                    alert("Não existem documentos abertos. Abra o documento pretendido e corra o script de novo.");

          }

}

 

function myCreateStyles(myObject){

          var myScriptFileName, myCharFile, myFindChangeFileName, myScriptFile, myResult;

          var myFindChangeArray, myFindPreferences, myChangePreferences, myFindLimit, myStory;

          var myStartCharacter, myEndCharacter;

          var myCharFile = myFindFile("/FindChangeSupport/FindChangeList.txt")

    var i = 0;

 

 

          if(myCharFile != null){

        myCharFile = File(myCharFile);

        var myDoc = app.documents[0];

        var myResult = myCharFile.open("r", undefined, undefined);

 

 

    if(myResult == true){

           //determina o número de  estilos a criar a alterar

           var myCharStyles = new Array();

                              do{

                myFindArray = myCharFile.readln();

                myCharStyles.push(myFindArray);

                }

            while(myCharFile.eof == false);

            var charStylesLenght = myCharStyles.length;

 

  // cria estilo a lingua dos estilos de carater

          for (oneStyle=1;oneStyle<charStylesLenght;oneStyle++){

        var myCharacterStyle = new Array();

        myCharStyleProp = myCharStyles[oneStyle].split("\t");

       

        var myCharStyleName = myCharStyleProp[0];

        var myCharStyleFont = myCharStyleProp[1];

        var myCharStyleFontStyle = myCharStyleProp[2];

        myCharacterStyle = myDoc.characterStyles.add();

        myCharacterStyle.name = myCharStyleName;

        myCharacterStyle.fontStyle = myCharStyleFontStyle;

        myCharacterStyle.appliedFont = myCharStyleFont;

       }

                              alert ("Foram criados os estilos de carater.");

                    }

          }

}

function myFindFile(myFilePath){

          var myScriptFile = myGetScriptPath();

          var myScriptFile = File(myScriptFile);

          var myScriptFolder = myScriptFile.path;

          myFilePath = myScriptFolder + myFilePath;

          if(File(myFilePath).exists == false){

                    myFilePath = File.openDialog("Selecione o documento .txt com as palavras a alterar.");

          }

          return myFilePath;

}

function myGetScriptPath(){

          try{

                    myFile = app.activeScript;

          }

          catch(myError){

                    myFile = myError.fileName;

          }

          return myFile;

}


Viewing all articles
Browse latest Browse all 37788

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>