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

With CS2, some things have changed

Participant ,
Apr 25, 2005 Apr 25, 2005
I have not located a place where changes in scripting between CS and CS2 are reported, so I thought I'd start a topic here with some of the things I know about.

This is about changes to the object model that are not related to changes in the functionality that have taken place.


1. User Interaction Control
2. Table Labels
3. Parent Text Frame
4. New Beep Function
5. Find/Change symbol for End Nested Style Here
6. Convert to Table
7. Active Script in doScript
8. Text selections more specific

9. Table selections
10. Indexes
11. Basic Paragraph style
12. Enumeration Name Changes
13. Placed Assets
14. Previous Text Frame
15. Version Property
16. Add Page Reference (Index)


In describing these in the following messages, I'll use JavaScript terminology, but most of these issues are independent of the language.
TOPICS
Scripting
16.3K
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
Participant ,
Apr 30, 2005 Apr 30, 2005
Basic Paragraph Style can't be Deleted

A couple of days ago, I posted a script that started out by deleting all paragraph styles. Even in CS, you had to avoid attempting to delete the "first" paragraph style ("No paragraph style"), but in CS2 you also need to avoid deleting the second one, also.

By the way, this is quite an annoyance in the UI. If you select all unused and your Basic Paragraph style is not in use and so gets selected (something which is more likely to happen with converted documents than newly created ones), the Delete menu item is greyed out in the Paragraph Style palette menu because you can't delete that style.

I see that the code I posted the other day:
myStyles = doc.paragraphStyles;

try {
for (i = (myStyles.length -1); i > 0; i--) {
myStyles.remove();
}
} catch (e) {}

does in fact work thanks to the try construction, but in CS2, you might as well limit the loop with i > 1, like this:
myStyles = doc.paragraphStyles;

for (i = (myStyles.length -1); i > 1; i--) {
myStyles.remove();
}

Dave
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
Participant ,
May 01, 2005 May 01, 2005
Enumeration Name Changes

SelectionOptions.replace is now SelectionOptions.replaceWith

For scripts that might need to run with both versions, I do this:
if (app.version != 3) {

app.select(theStory.paragraphs.insertionPoints[-2],SelectionOptions.replaceWith);
} else {
app.select(theStory.paragraphs.insertionPoints[-2],SelectionOptions.replace);
}

Dave
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
Participant ,
May 01, 2005 May 01, 2005
Place Asset from Library

When an asset is placed on a document from a library, in CS it became the selection. In CS2, this is no longer the case, so you cannot rely on the selection to get a reference to what was just placed (something which I've been doing although it wasn't strictly necessary).

The following code works in both CS and CS2 and so is the preferred way of doing this:

myObj = myAsset.placeAsset(myDoc)[0];

The index is needed because an asset might consist of multiple page items, so placeAsset returns an array of references even when there's only one item.

Dave
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
Participant ,
May 01, 2005 May 01, 2005
Place Asset -- Big Fat Hairy Warning

In CS2, do not attempt to place an asset on a document if you have an active selection in that document. The code in the previous message only works if you do not have a selection. If you have one, strange things happened. You might even conclude that your document is haunted.

I had this:

myFrame = app.selection[0];
myNewFrame = myAsset.placeAsset(myDoc)[0];

and all kinds of weird things happened. The only thing that made sense of the error messages I received was that somehow myNewFrame == myFrame and indeed, the debugger confirmed this was true.

Changing the above to:

myFrame = app.selection[0];
app.selection = null;
myNewFrame = myAsset.placeAsset(myDoc)[0];

got things working.

Dave
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
New Here ,
May 05, 2005 May 05, 2005
Can we have this what's changed information for AppleScripter also?

TIA
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
New Here ,
May 13, 2005 May 13, 2005
Previous text frame

Another difference. Suppose you want to link a textframe between two others. In CS you do

frame1.previousTextFrame = frame2.previousTextFrame;
frame2.previousTextFrame = frame1;

This gives an error in CS2, because frame2.previousTextFrame is already frame1, as this confirms:

frame1.previousTextFrame = frame2.previousTextFrame;
if (frame2.previousTextFrame != frame1){
frame2.previousTextFrame = frame1;
}

Teus de Jong
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
New Here ,
May 16, 2005 May 16, 2005
Yikes, I was under the impression that there wouldn't be that many changes but there sure are. I've identified 3412 (!) differences so far, by comparing the scripting libs of CS and CS2 via reflection. This excludes all new types, such as ObjectStyle.

One very, very bad thing is that the scripting lib is now even less (by magnitudes) typesafe than it was before, making typesafe scripting in .NET a PITA.

Not very inspiring....
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
Participant ,
May 16, 2005 May 16, 2005
Working with the selection object is easier. This script works in CS2 but not in CS (in that the selection is re-established in CS2 but not in CS):
if (app.selection.length >= 0) {

var mySel = app.selection;
app.select(null);
}
app.layoutWindows[0].zoom(ZoomOptions.fitPage);
app.layoutWindows[0].zoomPercentage = 191;
try {
app.select(mySel);
} catch (e) {};


But in CS, you had to do something like this:
if (app.selection.length >= 0) {

var mySel = app.selection;
app.select(null);
}
app.layoutWindows[0].zoom(ZoomOptions.fitPage);
app.layoutWindows[0].zoomPercentage = 191;
try {
app.selection = makeArray(mySel);
} catch (e) {};

function makeArray(theSel) {
var myArray = new Array();
var theLim = theSel.length;
for (j=0; theLim>j; j++) {
myArray.push(theSel);
}
return myArray
}

Dave
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
Explorer ,
May 16, 2005 May 16, 2005
E Gunnar Liljas wrote: "Yikes, I was under the impression that there wouldn't be that many changes but there sure are. I've identified 3412 (!) differences so far, by comparing the scripting libs of CS and CS2 via reflection. This excludes all new types, such as ObjectStyle."

Again, you can use script versioning to run CS (3.x) version scripts in CS2 (4.x)--see Olav Kvern, "InDesign CS2 Script Versioning" #7, 27 Apr 2005 12:25 pm

Thanks,

Ole
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
New Here ,
May 16, 2005 May 16, 2005
Unfortunately that is not an option when working from .NET
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
Explorer ,
May 17, 2005 May 17, 2005
Hi E Gunnar Lijas--

You should be able to use the CS (3.x) version of the scripting model with VB.NET, as described in the earlier post (publish the terms, then add the reference to your VB.NET project). If that doesn't work, you can alway send a string as VBScript and target the 3.x version of the model.

Thanks,

Ole
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
New Here ,
May 17, 2005 May 17, 2005
OK, that seems to work. However, there still exist a few changes, especially for the ChangePreferences and FindPreferences, where all properties are of type "object" now. They used to be strongly typed.

Is this change done in order to make it possible to unset the properties of ChangePreferences and FindPreferences, by using null/Nothing, or it it something else?
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
Explorer ,
May 17, 2005 May 17, 2005
Hi E Gunnar Liljas wrote: "Is this change done in order to make it possible to unset the properties of ChangePreferences and FindPreferences, by using null/Nothing"

Yes. (It was possible in CS, as well.)

Thanks,

Ole
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
New Here ,
May 17, 2005 May 17, 2005
It was possible in weakly typed environments, but not in C# et. al.
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
Participant ,
May 25, 2005 May 25, 2005
Version property

app.version is a string in CS2 but it is a number in CS, so while:
>if (app.version.split(".")[0] != 4)

works in CS2, it doesn't in CS.

What I've been using to distinguish CS2 from CS is:
>if (app.version != 3)

but if I want to also distinguish CS2 from some future CS3, I need to check for 4, so:
>if (String(app.version).split(".")[0] != 4)

seems to be needed.

Dave
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
New Here ,
Sep 01, 2005 Sep 01, 2005
The syntax of adding a page reference to an index topic has changed. In effect the first two parameters have been combined.

Where in CS you would have (leaving out the last two optional parameters PageReferenceLimit and PageNumberStyleOverride, which didn't change):

myTopic.pageReferences.add(myStory, myIndex, PageReferenceType.currentPage);

where myStory is the story in which the pagereference is and myIndex the index in the story (storyoffset) where the pagereference is.
In CS2 this would become:

myTopic.pageReferences.add(myStory.insertionPoints[myindex], PageReferenceType.currentPage);

Although formally the first parameter of pageReferences.add is of the type Text, an insertionpoint will be accepted.

Teus
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 ,
Sep 21, 2005 Sep 21, 2005
Re: pageReference

You don't need an index or any (direct) reference to a story either. You could cycle through a collection of found items, as in
myItems = app.activeDocument.search( 'wildebeest' )

for( i = myItems.length-1; i > -1; i-- )
myTopic.pageReferences.add( myItems, pageReferenceType.currentPage )

Peter
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
New Here ,
Sep 21, 2005 Sep 21, 2005
That's right Peter: in CS2 you only need a parameter sourceText; this can be any text item. I just gave the example to illustrate how to convert CS scripts to CS2.

Teus
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
New Here ,
Oct 31, 2005 Oct 31, 2005
Hi, I'm looking for an Acrobat patch. Does anybody has one? My InDesign isn't any longer able to read Acrobat. Maybe it is also unable to open QUark. Acro Writer isn't able to write. Several problems. Maybe there is a loss of dates.
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
Participant ,
Oct 31, 2005 Oct 31, 2005
This is surely not the place to look. Why not try one of the Acrobat forums.

I'll leave your message and this response here for a day and then delete both.

Dave Saunders
Host

PS: I have already deleted the duplicates you left attached to other messages in this forum.
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
New Here ,
Nov 03, 2005 Nov 03, 2005
Hi I've seen also some changes for the Excel import preferences. On CS you could set the select sheet with:

iApp.ExcelImportPreferences.SheetName = sheet
iApp.ExcelImportPreferences.RangeName = range
iApp.ExcelImportPreferences.DecimalPlaces = 3

This works no more on CS2. That's really desapointing because it was a great feature for automated import.
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
Participant ,
Nov 03, 2005 Nov 03, 2005
All three of those properties are apparently still supported by the object model (according to the CS2 scripting reference). Are you sure you're not suffering from a problem elsewhere in your script? Or maybe this is a bug. It doesn't look to be a deliberate change in functionality.

Dave
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
New Here ,
Nov 03, 2005 Nov 03, 2005
Dave,

You're right, all properties are supported, but they doesn't seem to work as in CS anymore. I tried to run a simple script using this propoerties, it works fine in CS but setting those properties in CS2 is useless. maybe it's a bug.
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
Participant ,
Nov 03, 2005 Nov 03, 2005
Did you make sure that your TableFormattingOptions were set for formatted input? That could be a factor here.

Dave
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
New Here ,
Nov 03, 2005 Nov 03, 2005
I tried to add the TableFormattingOptions, but it doesn't change the result. The real problem is when I use the command "Place", Indesign should use the "sheetname", "RangeName",... properties if they have been set previously. But in my case I set all the properties of existing sheets in my excel file, but at the execution of the place command in my script, the import window still open asking me which sheet to import.
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