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

Element labels in scripting

Community Beginner ,
Oct 18, 2023 Oct 18, 2023

I'm afraid my question will betray my ignorance, but can anyone help me use these 'element labels' (I think that's what they're called) in a script?

Scherm­afbeelding 2023-10-18 om 17.10.06.pngScherm­afbeelding 2023-10-18 om 17.45.03.png

There are a number of text frames (or stories?) in the document, each with one of various labels. I want to collect elements with the same label and use their contents in a script. Unfortunately, I can't find a way to access those labels. I've tried collecting all textFrames, stories, pageItems... and then using ".label", but I don't get the expected results.

Can anyone help?

TOPICS
Scripting
829
Translate
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 2 Correct answers

Community Beginner , Oct 18, 2023 Oct 18, 2023

Thanks everyone for pointing me in the right direction so quickly. You're right, element labels are added by Woodwing and are mentioned in their dedicated scripting guide!

Translate
Community Beginner , Oct 25, 2023 Oct 25, 2023

Here is a sample how to handle pageItems with an elementLabel in WoodWing

for (var p=0; p<curPageItems.length; p++) {
var curPageItem = curPageItems[p];
if ( curPageItem.hasOwnProperty(„elementLabel“) ) {
$.writeln(„PageItem: „ + curPageItem.constructor.name + „ | ElementLabel: „ + curPageItem.elementLabel);
}
}
Translate
People's Champ ,
Oct 18, 2023 Oct 18, 2023

It looks like you're using the Woodwing Studio plugin?

Translate
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
LEGEND ,
Oct 18, 2023 Oct 18, 2023
quote

It looks like you're using the Woodwing Studio plugin?


By @Tá´€W

 

You are right - 2nd screenshot:

 

https://helpcenter.woodwing.com/hc/en-us/articles/360041448831-Components-that-are-added-to-InDesign... 

 

Translate
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 Beginner ,
Oct 18, 2023 Oct 18, 2023

Yes, those labels are related to Woodwing Studio. Is that why I can't access them through scripting?

Translate
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
LEGEND ,
Oct 18, 2023 Oct 18, 2023
Translate
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 Beginner ,
Oct 18, 2023 Oct 18, 2023

I assumed those labels were a standard InDesign feature leveraged by Woodwing, but if they don't look familiar to anyone here, that's what I'll do. Thanks!

Translate
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
LEGEND ,
Oct 18, 2023 Oct 18, 2023

Sometimes REAL plugins can add extra functionality - and also offer extra scripting options.

 

Translate
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
People's Champ ,
Oct 18, 2023 Oct 18, 2023

In my limited experience of this plugin, Woodwing studio gets deep into InDesign's standard scripting DOM. It actually removes some properties (for instance, stories no longer have a "locked" property, and they cannot be exported to .icml), and adds a whole bunch of others.

So you would need to look at WW's scripting documentation (or use the DOM browser that comes with ESTK, because that reflects the changes that happen to the DOM when WW Studio is installed) to see what properties and methods you have available.

Translate
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 Beginner ,
Oct 18, 2023 Oct 18, 2023

Thanks everyone for pointing me in the right direction so quickly. You're right, element labels are added by Woodwing and are mentioned in their dedicated scripting guide!

Translate
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 ,
Oct 18, 2023 Oct 18, 2023

Hi @Robrecht5C72 , Is the Woodwing plugin setting the document’s XML structure—View>Show Structure? If it is you could access the XML elements via JS.

Translate
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 Beginner ,
Oct 18, 2023 Oct 18, 2023

That could be an interesting approach! I'll check.

Translate
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 Beginner ,
Oct 25, 2023 Oct 25, 2023
LATEST

Here is a sample how to handle pageItems with an elementLabel in WoodWing

for (var p=0; p<curPageItems.length; p++) {
var curPageItem = curPageItems[p];
if ( curPageItem.hasOwnProperty(„elementLabel“) ) {
$.writeln(„PageItem: „ + curPageItem.constructor.name + „ | ElementLabel: „ + curPageItem.elementLabel);
}
}
Translate
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