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

Path from the Book-Object to a paragraph-styled content

Engaged ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

Hi everybody.

By now I understand, that it is not possible to come to a result with (commonplace-)logical conclusions.

This time I´d like to get all the contents out of a book which are formatted with a certain paragraph-style. I started with this:

app.activeBook.bookContents.everyItem().name

So I got the names of the documents the book contains. According to my logic, this is approximately equal: .document.name. Isn´t it?

The next logical step (for me) would be:

app.activeBook.bookContents.everyItem().pages.everyItem().name

But, of course, it´s the wrong way... Althought:

app.activeDocumentpages.everyItem().name

works!

Background of my intension is the creation of a nested loop in which I can collect different contents from different levels (eg. page numbers, documen-/chapter-numbers, etc.). Doesn´t exist a path as I wrote in the head of this thread?

TOPICS
Scripting

Views

414

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

Copy link to clipboard

Copied

Hi,

bookContent and document are two different object with different properties.

Main (logical?) reason is that a doc is a file opened by app but a bookContent can be 'missed', 'closed', 'out of date' and... so on. It is a 'draw' where doc is inserted.

You can refer to a doc - as a part of book - and you can use a bookContent.name - but

1. check if is opened

2. call it like app.documents.itemByName(bookContent.name)

Jarek

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

Copy link to clipboard

Copied

Hmmm ... of course they are.

But I thought one can "walk" along a path "downstairs" to the children of the objects by "collecting" whatever one need. I know, it is a very non-expert-like expression, but it makes it more clear how I think about. Maybe that has to change, my way of thinking.

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

Copy link to clipboard

Copied

I think that good idea is to start here

ID CS5 Object Model

or another ID version.

Any path possible to walk - you can find there.

Jarek

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

Copy link to clipboard

Copied

Yes, that would be the best. But it would take to much time I do not have now. First I want to solve some problems by "trial & error & asking for help & try again".

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

Copy link to clipboard

Copied

I'm sorry but I have to disagree with that.

I deliberately designed my Object Model viewer to make the relationship between different objects much clearer, and in a visually more understandable way, than the Help built-in in the toolkit editor. That should take a large part of the 'trial & error' out of your own attempts. (But don't get me wrong, there is nothing wrong with the second part, "asking for help & try again"!)

For your case, you should take a look at the Hierarchy sections in my Help.

Let's take a look at your bookContents and see where it leads us to: Adobe InDesign CS5 (7.0) Object Model JS: BookContent

book1.PNG

We can go up and up and up in the hierarchy .. but not that far! BookContent is a part of a Book, which is a 'part' of the Application itself.

book2.PNG

The Application is kind of End of the Line, as far as InDesign is concerned; after all, it's InDesign itself, and it cannot access objects "above" itself. So, let's see where your second attempt, pages, leads us to: Adobe InDesign CS5 (7.0) Object Model JS: Page

page1.PNG

(Cheat: I pick Spread here, not MasterSpread, because I already know in what direction I want to guide you.)

page2.PNG

book3.PNG

and we end up at Application again. See? "BookContents" does not point to a document, and pages do not point to a book anywhere.

This mimicks (*) what you see in InDesign itself: you can edit documents and you can edit Book files, and you can do so independent of each other. You don't need a document "active" to change a book's order, and also not the other way around. The link between the two is ... apathetic. Neither one really cares about what happens to the other; and (as I found out the hard way just today, with a 15 document/350 page book) all responsibility to maintain correct pagination falls upon you, the user...

(*) Not accidentally or on purpose. It literally uses the exact same object model that InDesign itself uses, because, well, it has to because it is InDesign itself. Or something like that.

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

Copy link to clipboard

Copied

LATEST

I see. Thank you for that good (and individual) explanation.

Believe me, I´ve been a few times on that site. For me it was a mysterium: couldn´d see the connections between the objects, classes, methods, etc. Could not understand in what case one does use brackets (eg. .everyItem() ), and if one use them, which one ( (), { } or [ ] ); whether this brackets do contain parameters.

I know, I need a wider theoretical basis. The big job I´m working on now and wherefor I need some scripts came pretty sudden. I did not hae the time for reading books and study (very good) sites. But I will, one time...

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