Skip to main content
Inspiring
May 1, 2007
Question

With CS3, some things have changed

  • May 1, 2007
  • 60 replies
  • 29793 views
Let's use this topic to record changes that are likely to affect a working script. As I did in the CS2 comparable topic, I'll add an index here in the topic title when the list is long enough (and I have the time).
This topic has been closed for replies.

60 replies

Andreas Jansson
Inspiring
January 19, 2010

Trying to update some scripts and I found a few things I don't recall reading in this thread:

1. Trying to create xmlTag that already exists raises error in CS3

In CS3 (and CS4) you get an error trying to create xml tags that already exist:

myDocument.xmlTags.add(sTag)
Error: A tag with that name already exists.  Please choose a different name.

(while in CS2 the same code just returned the existing tag without an error)

2. Several parents and markupTags for an xmlElement

xmlElement can have several parents. The parent propery is then returned as an array. The same goes for tags.

Having more than one element with the same name, and assuming that there is only one by using myElement.item(the duplicate name here) you seem to get a single xmlElement but it has for example several markupTags (markupTag can be an array in CS3 and later).

Robert at ID-Tasker
Legend
January 23, 2010

Andreas Jansson wrote:

Trying to update some scripts and I found a few things I don't recall reading in this thread:

1. Trying to create xmlTag that already exists raises error in CS3

In CS3 (and CS4) you get an error trying to create xml tags that already exist:

myDocument.xmlTags.add(sTag)
Error: A tag with that name already exists.  Please choose a different name.

(while in CS2 the same code just returned the existing tag without an error)

Don't "add" tag - just use it in taggin process:

    With myXMLelem.XMLElements.Add("character")
        Call .XMLAttributes.Add("type", "text")
        .Contents = "empty paragraph" & vbCr
        Call .XMLAttributes.Add("aid:cstyle", .Texts.Item(1).AppliedCharacterStyle.Name)
    End With

or

    With myTSRangeText.AssociatedXMLElements.Item(1).Parent.XMLElements.Add("character")

        Call .Markup(myTSRangeText)

        Call .XMLAttributes.Add("type", "text")

        Call .XMLAttributes.Add("aid:cstyle", myTSRangeText.AppliedCharacterStyle.Name)

        If .Parent.MarkupTag = "character" Then

            Call .Move(idLocationOptions.idAfter, .Parent)

        End If

    End With

2. Several parents and markupTags for an xmlElement

xmlElement can have several parents. The parent propery is then returned as an array. The same goes for tags.

Having more than one element with the same name, and assuming that there is only one by using myElement.item(the duplicate name here) you seem to get a single xmlElement but it has for example several markupTags (markupTag can be an array in CS3 and later).

Few .parents ? Or you are talking about .AssociatedXMLElements collection for Text object ?

robin

www.adobescripts.com

Andreas Jansson
Inspiring
January 25, 2010

No 1. I might want to create tags (in the tags palette), first, for one reason or another :-)

That is, not in the immediate tagging process.

No matter the reason: there is an add method on the tags collection, and as I see it, it was changed ... and this is the place to record it.

No 2 is about having a reference to an xmlElement object in the structure (XML tree).

Also, I forgot to mention that I'm using javascript, so there might be differences in how the objects are returned.

To illustrate, here is a piece of my code. I have a reference to an xmlElement object in the tree. Let's call it elemToFind:

    if(elemToFind.index.length>1){
         // If elemToFind is not a single object, get its FIRST parent using [0], and go down again to get a SINGLE instance of the object instead.
        elemToFind = elemToFind.parent[0].xmlElements.item(elemToFind.index[0]);
        alertAndLog('The XML element "' + elemToFind.markupTag.name + '" exists more than once, under the same node.');
    }

The elemToFind was set (as I wrote in the previous message) using the item() method of its parent.

If the XML structure looks like this:

Root

  Sibling1

  Sibling2

  Sibling2

  Sibling3

... then I experienced this problem when setting a reference to elemToFind = myParent.item('Sibling2')

Causing elemToFind to behave differently from CS2, where you automatically got a single object reference set to one of the "Sibling2" objects, the first I think.

As you see in the sample code elemToFind.parent is no longer a single object. Probably caused by the new nature of the object returned by xmlElement.item()

(I might also have got the mening of "several" wrong, sorry for the confusion. I meant >1).

Andreas

Known Participant
January 7, 2009
So, we're a little behind...we're just moving from CS2 to CS3. So please bear with me. (We're using Javascipt)

Until I'm able to convert all of our scripts to CS3 compatibility, I created a "Version 4.0" folder in the scripts panel, hoping I can use our CS2 scripts as-is.

One of my CS2 scripts places a snippet on the master pages. Before, it would place by itself with no questions asked. In CS3, the snippet is a loaded cursor wanting me to click to place it. What do I need to change? This is the section of the script

//Place Master Page items
myDocument.masterSpreads.item("A-Master").place(
mcmMasterPage, //the document
[0,0], //top-left coordinate of text frame
undefined, //layer
false, //show options
false ) //autoflow
Participant
September 28, 2008
Hello, I am currently studying InDesign CS3 at Conestoga College in Waterloo, Ontario. I want to congratulate Olav Kvern and Dave Blatner on their Real World InDesign text. It is very well done, and I welcome the many humorous asides. A point of interest: Ken Graham, a professor at the University of Guelph, is a leading authority on William Beckford and is working on a scholarly edition of 'Vathek' and the 'Episodes of Vathek'. My interest in InDesign centers on its usefulness in setting mathematical articles via the InMath plugin. The javascript and XML support looks good too.
Participant
September 19, 2008
how to convert bottom statement from cs2 to sc3

phcode.Rotate (deg)
Known Participant
August 6, 2008
Hi SethMcGraw,

There's a chapter in the Scripting Guide on text and type that includes several find/change examples. The corresponding scripts are available in the Zip archive containing all of the Scripting Guide scripts. Both are available at the InDesign scripting home page--you'll find a link at the top of the forum.

There's also a new version of FindChangeByList available at the same link.

Thanks,

Ole
Participant
August 6, 2008
I am a first day newb to scripting. I need to simply use find/change to delete several instances of text and in one case replace text with a tab. I wan't these to run concurrently. I can't seem to get the findchangelist script to even run after editing the FindChangeList.txt file. I'm using the script that shipped with the application. where can I find a simple tutorial in kindergarten english on the subject?
Participant
May 20, 2008
this code works in CS2 but i doesn't work in cs3 if the insertion point of the frame is overset.

--You must have selected a text frame with text inside it
tell application "Adobe InDesign CS2"
tell active document
set frame to object reference of selection
set insertion_point to object reference of end of last paragraph of parent story of frame
tell insertion_point
make text frame with properties {contents:"Inline text frame", geometric bounds:{"0mm", "0mm", "25mm", "41mm"}}
end tell
end tell
end tell
Participant
April 23, 2008
Hello All,

I want to create 100 Pages in the template using Master A. Right now i am doing manually to create 100 Pages and linking manually. I want to do this in a automized way.

What is the better way to do this. May be via script or via Manullay with single button like that i don't want to do each and every page manually.

Can any body thru something about this and suggest me to do this.

Thanks in advance
Selva
Known Participant
April 17, 2008
Peter Kahrel
Community Expert
Community Expert
March 12, 2008
>How about toggling their visible property?

Right -- hadn't thought about that. Bit of a rash overgeneralisation that the UI isn't available to scripts, which obviously is nonsense given that you can add and remove menu items and toggle panels.

Peter