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

With CS5, some things have changed

LEGEND ,
Apr 12, 2010 Apr 12, 2010

Copy link to clipboard

Copied

This discussion is for changes to the scripting DOM which can affect legacy scripts.

Please use this discussion for discussing new scripting features in CS5.

Please keep in mind that all changes are specific to version 7 DOM. InDesign supports versioning, so you should be able to use legacy scripts in CS5 without issues. Versioning can be done in two ways:

1) Place the script in a folder named: "Version 6.0 Scripts" (or 5.0, 4.0, 3.0). The folder must be named exactly as specified.

2) Set the script version preferences at the start of your script. (i.e. app.scriptPreferences.version = 6), but it's highly recommended to reset the scripting version at the end of the script, and even to enclose the script in a try/catch/finally block to ensure that the script preferences are reset correctly.

Here's quick links to issues brought up in this thread:

  1. PageItem.parent
  2. PageItem.itemByName()
  3. PageItem.cornerOption and PageItem.cornerRadius
  4. Text values returned as Strings instead of Numbers
  5. PointType.LINE_TYPE was changed to PointType.PLAIN
  6. PasteBoardPreference.minimumSpaceAboveAndBelow was removed.

Harbs

TOPICS
Scripting

Views

58.2K

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 ,
Sep 08, 2011 Sep 08, 2011

Copy link to clipboard

Copied

John Hawkinson wrote:

However, if one sets the version preferences:

app.scriptPreferences.version=6.0
Result: 6
app.activeDocument.textFrames.item("foo").contents
Result: Foobar

So that does seem to work.

Yes, It was mentioned before and it works perfectly fine

Or you can do more - set it at the beginning of the script So old scripts work without any changes at all

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
Explorer ,
Sep 08, 2011 Sep 08, 2011

Copy link to clipboard

Copied

Hi John,

kimtorch's wrote: "In CS3 we used to simply get the parent story properties from the  frame, place the new text and then reapply the properties to restore the  style." I just wanted to note that that was something that script versioning couldn't fix that particular problem. (No worries--your posts here are great!)

Regarding item(label) vs. itemByName(name)--in my opinion, the biggest problem here is that the behaviors differ. The former may have been a hack (a special case for label that only worked for page items), but it was great in that it would return all of the page items with a given label. The latter only returns a single item, even if multiple items have the same name. In cases where the name is not required to be unique (e.g., page items), itemByName should behave the way that item(label) did. So, yeah, I'm really glad script versioning solves the problem, but I wish they'd just fix itemByName.

Thanks,

Ole

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
LEGEND ,
Sep 08, 2011 Sep 08, 2011

Copy link to clipboard

Copied

Yes, it is a problem.

Having left the hive-mind, can you advise us: do you think the team

would be receptive to requests to change .item()'s behavior behavior

back to the pre-CS5 behavior of searching for a label (where applicable)?

It seems to me we need .itemByName() and .itemByLabel() and both should

handle multiple objects. I guess I can file a feature request for the

.itemByLabel(), but I'm not sure if it makes sense to ask for .item()

to revert to .itemByName().

What do you think and what do you think is feasible to get?

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
Explorer ,
Sep 08, 2011 Sep 08, 2011

Copy link to clipboard

Copied

Hi John,

I really have no idea. But here's what should be done:

* item(label) should be restored for page items, but deprecated. That is, it should work as it did before the change, but users should be encouraged to use itemByName(name)--see the next point.

* itemByName(name) should be modified to work the way that item(label) used to work for page items. That is, it should return an array of all page items in a container that have the specified name. For objects where unique names are required (paragraph styles in a paragraph style group, for example), itemByName should return a single item.

* A new feature should be added: itemByLabel(labelName, labelValue) should get all items with a custom label of "labelName" where the label has the value "labelValue". This way, scripters can mark items using insertLabel in a way that isn't visible (and editable) in the user interface, and get references to items of a given label with a given value. Again, this should return an array of all items in a container with the specified key/value pair. I've run into too many cases where workflow solutions get broken by users accidentally changing labels in the Script Label panel. If you needed to, you could use the default label property by using itemByLabel("label", labelValue).

I don't think that these would be difficult changes to make, but I doubt if anything will happen. I put more of my faith in our ability to create workarounds.

Thanks,

Ole

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 ,
Sep 09, 2011 Sep 09, 2011

Copy link to clipboard

Copied

hey ole,

i do see your point - especially for exprienced scripters.

but for beginners and learnes this would confuse even more: the label property would not correspond to the itemByLabel() function (same problem as  insertLabel() and extractLabel() but far less used).

the mess started with insertLabel() and now there is no easy way out.

luckily i had never any problems with users accidently changing labels in the label panel.

gregor

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
People's Champ ,
Sep 09, 2011 Sep 09, 2011

Copy link to clipboard

Copied

Sorry, I'm coming in late to this discussion. What is the probem with

insertLabel()?

Ariel

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 ,
Sep 09, 2011 Sep 09, 2011

Copy link to clipboard

Copied

insertLabel() does not correspond to the property label. in my opinion this would be intuitive. the question was about getting things clear with item() and itemByName(). because of downward compatibility there is no easy solution to clear the DOM in this point.

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
LEGEND ,
Sep 09, 2011 Sep 09, 2011

Copy link to clipboard

Copied

Nothing.

insertLabel() is the way to go in my opinion...

Harbs

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
Explorer ,
Sep 09, 2011 Sep 09, 2011

Copy link to clipboard

Copied

Fellow Scripters,

It's a long story. First, referring to page items by pageItems.item("label_string")--where "label_string" was the contents of the object label--was never "intuitive." In all other cases in the DOM, item(string) is used for named objects. But, in the early days, page items didn't have names. By creating a special case for page items, we could use the contents of the label property to refer to page items. It wasn't ideal, but it worked, and everyone got used to it.

I would think that users starting scripting today would expect to be able to set the object name, then use itemByName to get a reference to the object. The Layers panel is usually more visible than the Script Label panel. The only problem is that itemByName doesn't return multiple objects--and it should.

Later, we realized that the simple label property was not enough--scripters needed a way to store other data on objects (and not just page items), so we added insertLabel and extractLabel. They're incredibly useful! Before we had insertLabel/extractLabel, trying to store multiple data values in the single label property was a chore--you had to use some kind of delimiter to separate the values. (My hat is off, as always, to the great engineers behind InDesign scripting, Peter Boctor and Jonathan Brown. It's sad that neither of them are still working in that area.)

Note, in addition, that insertLabel/extractLabel work as expected with the label property--to write to the label, you could use:

insertLabel("Label", "Some value here");

...and you can use extractLabel to get the value. Not that anyone needs to do this, it's just nice that it works.

I think that the changes in this area--since the original implementation--have made things more consistent (and, one hopes, "intuitive"). Unfortunately, the changes, a.) broke something that many scripts depended on, and b.) the new approach, itemByName, does not match the capabilities of the old approach.

Thanks,

Ole

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
New Here ,
Jun 07, 2011 Jun 07, 2011

Copy link to clipboard

Copied

With a script that worked OK in CS4 I now find that when I set the strokewidth of a frame to 0 the result is a frame having a stroke of 1 pt, using the default TextFrame Object style. In both cases I used the same template file to start with so the Object Style is somehow changed or is now applied and not inprevious versions ? Do I need to set the ObjectStyle to None on all frames in CS5 to avoid this ?

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
New Here ,
Jun 07, 2011 Jun 07, 2011

Copy link to clipboard

Copied

Just found out myself that just after setting frame.strokewidth = 0 the value for frame.strokewidth is actually 1 pt; if I set strokewidth = 0.000001 then the value returned is actually 0.000001 pt so will show as 0 in InDesign dialogs.
So now my question is: how to set strokewidth to zero in InDesign CS5 ?

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 ,
Jun 07, 2011 Jun 07, 2011

Copy link to clipboard

Copied

RoelofJanssen2 wrote:

With a script that worked OK in CS4 I now find that when I set the strokewidth of a frame to 0 the result is a frame having a stroke of 1 pt, using the default TextFrame Object style. In both cases I used the same template file to start with so the Object Style is somehow changed or is now applied and not inprevious versions ? Do I need to set the ObjectStyle to None on all frames in CS5 to avoid this ?

There is no StrokeWidth - it ALWAYS was StrokeWeight - 2.0.2/CS1/CS2/CS3/CS4/CS5:

Property StrokeWeight As Variant
    Member of InDesign.TextFrame
    The weight (in points) to apply to the TextFrame's stroke. Type: Unit (Double or String)

robin

www.adobescripts.co.uk

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
New Here ,
Sep 27, 2011 Sep 27, 2011

Copy link to clipboard

Copied

Hi everyone, I am running a VB script that I wrote for InDesign CS2 on CS5. The code below does not seem to work. Does CS5 understand Changecase? If someone knows or could point me to the CS5 VB script reference I would greatly appreciate it. I can't seem to locate any information.

.Paragraphs(2).Changecase (idSentencecase)

Thank you for helping!

Mike

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 ,
Sep 27, 2011 Sep 27, 2011

Copy link to clipboard

Copied

Hi Mike,

.Paragraphs(2).Changecase (idSentencecase)

Try to use numbers:

Const idSentencecase = 1667461987 (&H63637363)

    Member of InDesign.idChangecaseMode

    Makes the first letter of each sentence uppercase.

   .Paragraphs(2).Changecase (1667461987)

Are you sure there is 2nd Paragraph ?

What error do you have ?

Or what is the type of the Text object you try to modify ?

robin

www.adobescripts.co.uk

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
New Here ,
Sep 28, 2011 Sep 28, 2011

Copy link to clipboard

Copied

Using the number worked perfectly. Thank you!!

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
Explorer ,
Nov 26, 2016 Nov 26, 2016

Copy link to clipboard

Copied

My admittedly old CD for InDesign 5 (Windows) is no longer readable. Where can I find a guide to scripting?

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
Explorer ,
Nov 26, 2016 Nov 26, 2016

Copy link to clipboard

Copied

Problem solved!

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

Copy link to clipboard

Copied

LATEST

Hi,

start your ExtendScript Toolkit app (ESTK) and look under "Help".

Don't know the exact paths under Windows, but for Mac OSX you'll find some PDFs about scripting CS5 here:

CS5 (version 7)

/Applications/Utilities/Adobe Utilities - CS5/ExtendScript Toolkit CS5/

ExtendScript Toolkit ReadMe.pdf

/Applications/Utilities/Adobe Utilities - CS5/ExtendScript Toolkit CS5/SDK/English/

Adobe Intro To Scripting.pdf

/Applications/Utilities/Adobe Utilities - CS5/ExtendScript Toolkit CS5/SDK/

JavaScript Tools Guide.pdf

And if you mean scripting of InDesign version 5 (CS3) your ExtendScript Toolkit 2 should lead the way.

If you do not have the ESTK available see here:

ExtendScript Toolkit Archives | Adobe Developer Connection

Indispensable resources of DOM documentation compiled by Jongware:

Indesign JavaScript Help

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