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

[JS] Topics Crée sur 3 Niveaux

Enthusiast ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

Bonjour,

Je suis parvenu à crée une entré dans un index

     var doc = app.documents[0];

     var new_topic = doc.indexes[0].topics.add (app.selection[0].contents);

     new_topic.pageReferences.add (app.selection[0], PageReferenceType.currentPage);

}

Mais cherche un exemple pour descendre jusque 3 niveaux

Niv1

|-> Niv2

          |-> Niv3

Bien à vous

Philippe

TOPICS
Scripting

Views

511

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 , Nov 22, 2016 Nov 22, 2016

var Niv2 = new_topic.topics.add (. . .);

var Niv3 = Niv2.topics.add (. . .);

P.

Votes

Translate

Translate
Community Expert ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

var Niv2 = new_topic.topics.add (. . .);

var Niv3 = Niv2.topics.add (. . .);

P.

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 ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

Merci Peter, bonne réponse, vla voici en fonction:

function InsetionPeter() {

        var doc = app.documents[0];

        var new_topic = doc.indexes[0].topics.add( 'Philou25');

        var Niv2 = new_topic.topics.add ('Philou99');

        var Niv3 = Niv2.topics.add (app.selection[0].contents);

        Niv3.pageReferences.add (app.selection[0], PageReferenceType.currentPage);

   

    }

Hier soir très tard j'avais fais ceci :

function InsetionPhilippe() {

            var doc = app.documents[0];

            doc.indexes[0].topics.add( 'Philou28');

            doc.indexes[0].topics.item( 'Philou28' ).topics.add( 'Philou100');

            var new_topic = doc.indexes[0].topics.item( 'Philou28' ).topics.item( 'Philou100' ).topics.add (app.selection[0].contents);

           new_topic.pageReferences.add (app.selection[0], PageReferenceType.currentPage);

    }

Je voudrais aussi mettre un text (ex: voir Réference suivent) à la place de la pagination, c'est possible mais avec quel commende?

Encore Merci Peter

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 ,
Nov 23, 2016 Nov 23, 2016

Copy link to clipboard

Copied

Philippe,

You can do that in two ways. Either in one step:

var new_topic = doc.indexes[0].topics.item( 'Philou28' ).topics.item( 'Philou100' ).topics.add (app.selection[0].contents + ' (voir Réference suivent)');  

or you can change a topic's name later:

var new_topic = doc.indexes[0].topics.item( 'Philou28' ).topics.item( 'Philou100' ).topics.add (app.selection[0].contents);

new_topic.name += ' (voir Réference suivent)';

Peter

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 ,
Nov 23, 2016 Nov 23, 2016

Copy link to clipboard

Copied

Merci Peter,

Je pourrai avance dans la mise en place de mon Script. Je vais aussi regarde pour y mettre des référence croisé.

Bien à vous

Philippe

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 ,
Nov 25, 2016 Nov 25, 2016

Copy link to clipboard

Copied

Bonjour,

Un autre demande, je voudrais trouve les commande ou exemple pour rélisse les manipulation suivant (voir image) :

Capture d’écran 2016-11-25 à 10.40.47.png

Merci d’avance pour votre aide.

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 ,
Nov 25, 2016 Nov 25, 2016

Copy link to clipboard

Copied

Philippe -- You can find that in the object model. But here's the code anyway:

myTopic = app.documents[0].indexes[0].topics.item('Test25').topics.item('Test26');

refTopic = app.documents[0].indexes[0].topics.add ('Test33');

myTopic.crossReferences.add (refTopic, CrossReferenceType.SEE_ALSO);

Peter

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 ,
Nov 25, 2016 Nov 25, 2016

Copy link to clipboard

Copied

Merci Peter.

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 ,
Nov 25, 2016 Nov 25, 2016

Copy link to clipboard

Copied

Je ne parviens pas à tester si une entre de niveau 1 existe  déjà (!!) j'ai un erreur

if (doc.indexes[0].topics.itemByName(leNivParent1).isValid) {

                   

                    var new_topic = doc.indexes[0].topics.item(leNivParent1);

                } else {

                    var new_topic = doc.indexes[0].topics.add(String(leNivParent1));

}

J'ai voulus  utilisé la commande try {} catch () {}, je ne maitrise pas assz cette manière de faire.

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 ,
Nov 25, 2016 Nov 25, 2016

Copy link to clipboard

Copied

Philippe -- You can add a new topic without checking whether it exists, Indesign checks it for you: If you try to add a topic that already exists, Indesign does nothing. So there's no point using a try/catch construction.

Please start new discussions for new problems.

P.

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 ,
Nov 25, 2016 Nov 25, 2016

Copy link to clipboard

Copied

LATEST

Merci, je fais ça.

Bonne soirée à 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