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

[JS] Selection All object

Enthusiast ,
May 18, 2017 May 18, 2017

Copy link to clipboard

Copied

Bonjour,

Je script habituellement pour indesign. mais là, j' ai un script à faire pour Ill CC2017.

Je dois traité  des fichiers, 

je ne parviens pas à faire un tableau de tous les objet du document.

je parviens à sélectionné le groupe.

Est-il possible d'avoir un début de piste pour traité chaque élément du document.

Bien à vous

Philippe

TOPICS
Scripting

Views

926

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

Community Expert , May 23, 2017 May 23, 2017

Hi Liphou​,

a little bit more precise could be:

// TextFrameKerningTo400.jsx

// regards pixxxelschubser

var aDoc = app.activeDocument;

var aTF = aDoc.textFrames[0];

var x = aTF.textRange.kerningMethod;

alert("Kerning was: "+x);

if (x != AutoKernType.NOAUTOKERN) {

    x = AutoKernType.NOAUTOKERN;

    }

aTF.textRange.kerning = 400;

alert("Kerning is now: 400");

Have fun

Votes

Translate

Translate
Adobe
People's Champ ,
May 22, 2017 May 22, 2017

Copy link to clipboard

Copied

Bonjour,

la propriété allPageItems du document renvoie l'intégralité des objets indépendamment de leur relations aux autres objets. Dans le cas d'un groupe, tu récupéreras donc l'objet groupe ainsi que tous les objets appartenant à ce groupe. A l'inverse les collections sont relatives au parent. doc.pageItems ne renvoie alors que les objets qui lui dépendent directement.

Un groupe au premier niveau sera dans la collection du document mais pas mes éléments du groupe qui eux appartiennent à la collection pageItems du groupe et ainsi de suite.

Donc ta question est de savoir ou peuvent se trouver ces groupes. S'ils peuvent être n'importe ou, il est préférable de boucler dans allPageItems et d'isoler les objets groupe pour les traiter dans un deuxième temps.

Attention toutefois aux effets de bords. Si tu essayes de dégrouper un groupe par exemple, tu peux avoir une erreur si le groupe est lui même enfant d'un groupe.

Loic

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
Enthusiast ,
May 22, 2017 May 22, 2017

Copy link to clipboard

Copied

Bonjour et merci Loïc,

Je travail sur des documents simple  provenant de la même source "MathType", (c'est mon première script pour Illustrator) la doc en FR n'est pas lord .

Passé le document en CMYK (DocumentColorSpace.CMYK), à déjà un grand pas ! Mais il me reste à passer sur chaques objets pour les traités,  faut-il le dégroupé obligatoirement ? j'ai un seul groupe, c'est déjà ça.

La suite est de tester la cour du contour, du fond, de faire la distinction entre graphique et texte.

je place se que j'ai regroupe pour faire mon script: (il n'est pas propre, il dois être nettoyer pas la suite)

#target illustrator

var  sourceDir,

        destDir,

        files,

         nameFiles

        sourceDoc,

         destinationDoc;

sourceDir = Folder.selectDialog( 'Selection votre dossier source.', '~' );

//destDir = Folder.selectDialog( 'Select the export directory.', sourceDir.sourceDir );

        files = sourceDir.getFiles("*.EPS");

            if(files.length == 0){

                alert("No files to import");

            }else{

                for(i=0; i < files.length; i++){

                    sourceDoc = app.open(files);

                    nameFiles = sourceDoc.name;

                    $.writeln(nameFiles)

// backup                                       sourceDoc.groupItems[0].selected = true;

                   

                   // selection de tous les éllementr sur chaques calques

                     for (y=0; y < sourceDoc.layers.length; y++){

                            sourceDoc.layers.hasSelectedArtwork = true;

                    } // select all 

  

                               copy();// 

                               // creation du nouveau document

                               destinationDoc = documents.add(DocumentColorSpace.CMYK); // new doc CMYK 

                               // colle les object (groups)

                               paste(); //

                           // fermenture du document

                           sourceDoc.close(SaveOptions.DONOTSAVECHANGES);

                           sourceDoc = null;

                  

                 

                   

                    // Resize artboard

                  destinationDoc.artboards[0].artboardRect = app.activeDocument.visibleBounds;

                  redraw();

                  if (exportFileAsEPS (sourceDir, nameFiles, destinationDoc)) {

                      destinationDoc.close(SaveOptions.DONOTSAVECHANGES);

                      sourceDoc = null;

                   }

                   

                

                    //app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

                    //sourceDoc = null;

                }

            }

// option sauvegarde

// Sauvegrade du fichier 

function exportFileAsEPS (destFile, leName, saveDoc) {

        var newFile = new File(destFile + "/"+ leName);

        var saveOpts = new EPSSaveOptions();

                saveOpts.cmykPostScript = true;

                saveOpts.embedAllFonts = true; // font incoporet

                saveOpts.includeDocumentThumbnails = true; // image minature (prewieu ?)

                // saveOpts.embedLinkedFiles = false; // incoporation des omage Lié

        try {

                saveDoc.saveAs( newFile, saveOpts, true );

                return true;

                }

       catch(e) {

          

            $.wrireln ("erreur de sauvegarde : " + e);

          

           }

       

}

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 ,
May 22, 2017 May 22, 2017

Copy link to clipboard

Copied

Liphou​,

Sorry, I do not speak french. And the auto-translation isn't really helpful.

But 2 notes:

- Do not use paste(). Better use paste in place.

  app.executeMenuCommand("pasteInPlace"); // is available since CS6

- And perhaps you also do not need copy and paste. Perhaps the following is helpful for you:

  app.executeMenuCommand("doc-color-cmyk");// is available since CS6

  • open one document
  • use app.executeMenuCommand("doc-color-cmyk");
  • and save as whatever you want

Have fun

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
Enthusiast ,
May 22, 2017 May 22, 2017

Copy link to clipboard

Copied

pixxxel schubser​,

Hi,

No problem I use Google translation, thanks

Thank you for your advice,


I re-run the test with the command "app.executeMenuCommand (" pasteInPlace ");" And now this function (super) and so no longer need the paste () command!


I currently block on kerning:

Capture d’écran 2017-05-23 à 07.54.02.jpg


I tested the following command in different ways but I can not change the thing:


  LeDoc.selection  .textRange.characterAttributes.kerningMethod = AutoKernType.AUTO;




I'd like to place it on Zero.

//--------------------------------------------------------------------------------------

Pas de problème j'utilise la traduction de Google, Merci

Merci pour vos conseil,

j'ai refait le test avec la commande "app.executeMenuCommand("pasteInPlace");" et maintenant cela fonction (super) et donc plus besoin de la commande paste() !

Je bloc actuellement sur le crénage :

(voir image)

j'ai testé le commande suivante de différente manière mais je ne parviens pas a faire changer la chose :

  leDoc.selection.textRange.characterAttributes.kerningMethod = AutoKernType.AUTO;

Je voudrais le placer sur Zéro.

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
Enthusiast ,
May 22, 2017 May 22, 2017

Copy link to clipboard

Copied

Ok, for kerning: / Ok, pour le crénage :

leDoc.selection.textRange.characterAttributes.kerningMethod = AutoKernType.METRICSROMANONLY;

leDoc.selection.textRange.kerning = 0;

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 ,
May 23, 2017 May 23, 2017

Copy link to clipboard

Copied

Hi Liphou​,

a little bit more precise could be:

// TextFrameKerningTo400.jsx

// regards pixxxelschubser

var aDoc = app.activeDocument;

var aTF = aDoc.textFrames[0];

var x = aTF.textRange.kerningMethod;

alert("Kerning was: "+x);

if (x != AutoKernType.NOAUTOKERN) {

    x = AutoKernType.NOAUTOKERN;

    }

aTF.textRange.kerning = 400;

alert("Kerning is now: 400");

Have fun

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
Enthusiast ,
May 24, 2017 May 24, 2017

Copy link to clipboard

Copied

LATEST

hi pixxxel schubser​,

Thank you so much for your valuable help.
Welcome

Merci beaucoup pour votre aide si précieuse.

Bien à vous

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