• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
1

ScriptPreferences Version

Participant ,
Aug 07, 2017 Aug 07, 2017

Copy link to clipboard

Copied

Hey all

I dont have a problem I need solving for once, just a question for those in the know.

In order to get hold of a page item by Label name, I have  a small function which downgrades me to version 6,

collection.item(label).getElements()

then putting my version back to the original state.

This works fine, but has always bothered me using this technique. Will I always be able to rely on switching versions mid-script?

Are there any other ways that Adobe have introduced that have slipped me by?

Not a biggie, I was just getting curious, and need to know if I can relax!

Cheers

Royston

TOPICS
Scripting

Views

875

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 , Aug 08, 2017 Aug 08, 2017

Roy -- Change script labels to names. Then you can say things like

myPage.textFrames.item('box')

myDoc.rectangles.item('circle')

It's easy to change labels to names: loop through all page items and

x = app.documents[0].allPageItems;

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

  x.name = x.label;

}

You can see names of page items in the Layers panel.

P.

Votes

Translate

Translate
Community Expert ,
Aug 08, 2017 Aug 08, 2017

Copy link to clipboard

Copied

Hi Royston,
you did not mention it, but I'd be surprised if your trick is still working with the latest version of InDesign.
Cannot contribute much on this, but I would never rely on an older ScriptPreferences Version for a particular feature.

Regards,
Uwe

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
Participant ,
Aug 08, 2017 Aug 08, 2017

Copy link to clipboard

Copied

Hey Uwe

Yep, that old trick (That I think Dave Saunders demonstrated) is still working for me in my case.

so maybe Id better start using more 'proper native' way from now. Such a shame I cannot directly call an item by script label just in case.

Oh well, onwards and upwards.

Royston

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 ,
Aug 08, 2017 Aug 08, 2017

Copy link to clipboard

Copied

Roy -- Change script labels to names. Then you can say things like

myPage.textFrames.item('box')

myDoc.rectangles.item('circle')

It's easy to change labels to names: loop through all page items and

x = app.documents[0].allPageItems;

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

  x.name = x.label;

}

You can see names of page items in the Layers panel.

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
Participant ,
Aug 08, 2017 Aug 08, 2017

Copy link to clipboard

Copied

Hey Peter.

That sounds like a fundamental practice I should have been using all along! I did not know that the Name property was available in this way. Seems obvious now though. The Layers panel showing this is pretty useful too.

Thanks again

Roy

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 ,
Aug 09, 2017 Aug 09, 2017

Copy link to clipboard

Copied

Hm,

since item("name") or itemByName("name") will only get the first instance of a named item I see no real advantage in using names instead of labels. But that's for the scripting side of things to collect items with the same label or name value.

It's quite different in the UI where the user controls labeling or naming items.

Names are more obvious in the Layer Panel than using the Script Label Panel where you have to select item for item to see into the value of the label.

Regards,
Uwe

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
Participant ,
Aug 09, 2017 Aug 09, 2017

Copy link to clipboard

Copied

There are definitely pros and cons either way. For me, needing this for the sort of work I am doing, I control the name/label allocating, and ensure they are unique, so only selecting the first item works well for me. It appears that the user isn't able to re-name the item in the UI which is another plus point for me.

There have been times when I want to collect all items with the same label so I'll be using labels for that purpose.

It's good for me to learn different ways, I feel I am not wasting my time so much when I learn a new (to me anyway) technique.

Thanks again

Roy

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 ,
Aug 09, 2017 Aug 09, 2017

Copy link to clipboard

Copied

https://forums.adobe.com/people/Roy+Marshall  wrote

ā€¦ It appears that the user isn't able to re-name the item in the UI which is another plus point for me.ā€¦

Roy

Hi Roy,

but a user would be able to rename a named item in the Layer Panel.


And a user would also be able to change the contents of a label in the UI by using the Script Label Panel.
Unless you are using insertLabel() / extractLabel() and not using "Label" as key.

Regards,
Uwe

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
Participant ,
Aug 09, 2017 Aug 09, 2017

Copy link to clipboard

Copied

LATEST

Hey Uwe.

I was just going to say "Where is the edit option" for the Layer item name, when I discovered it. Click, and hover for a second and it becomes editable! Strange there is no menu for this.

And I was not aware of the second way to add a label. I use the insertLabel and extractLabel option all the time with pages, and the app itself, but didnt know page items also have this additional layer of labels.

I never get bored learning new things!

Cheers

Roy

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