This content has been marked as final.
Show 11 replies
-
1. Re: ExtendScript for CS3 and CS2
(Dave_Saunders) Aug 13, 2008 6:12 PM (in response to John.Kordas)There's an option in the Debug menu called Do not Break on Guarded Exceptions. I seem to recall that in CS2 it defaulted to Off. You need to turn it on.
My approach to creating new objects is to avoid the use of try/catch by doing something like this:
myLayer = aDoc.layers.item("layerName");
if (myLayer == null) {
myLayer = aDoc.layers.add({name:"layerName"});
}
As for setting the activeLayer, that's a property of a document object, so you should be able to just write:
app.documents[0].activeLayer = "Layer 1";
Dave -
2. Re: ExtendScript for CS3 and CS2
John.Kordas Aug 14, 2008 9:15 PM (in response to John.Kordas)Greatly appreciated Dave,
This has been driving me mad.
Cheers, John. -
3. Re: ExtendScript for CS3 and CS2
John.Kordas Aug 19, 2008 5:58 PM (in response to John.Kordas)Unfortunately I have not had any luck with:
app.documents[0].activeLayer = "Layer 1";
did a check in the CS2 reference manual and activeLayer falls under LayoutWindow.
I've tried the following with no luck.
app.documents[0].LayoutWindow.activeLayer = "Layer 1";
app.LayoutWindow.activeLayer = "Layer 1";
app.activeDocument.LayoutWindow.activeLayer = "Layer 1";
Any suggestions? -
4. Re: ExtendScript for CS3 and CS2
(Dave_Saunders) Aug 19, 2008 6:50 PM (in response to John.Kordas)LayoutWindow is an object class. To access a member of the class, you need to address the property of the parent object. So:
app.documents[0].layoutWindows[0].activeLayer = "Layer 1"
is what you need.
Except that that doesn't work! This looks like a documentation problem. If you run that you get an error message to the effect that it was expecting a layer object or a string. But actually, it doesn't take a string, because (I think) layer objects are properties of the document, not the window. So, instead, you must use:
myLayer = app.documents[0].layers.item("Layer 1");
app.documents[0].layoutWindows[0].activeLayer = myLayer;
Dave -
5. Re: ExtendScript for CS3 and CS2
John.Kordas Aug 19, 2008 7:31 PM (in response to John.Kordas)Thanks Dave that did the trick,
var mySluglay = app.activeDocument.layers.item("Slug");
//alert(mySluglay.name);
if (mySluglay != null){
myLayer = app.documents[0].layers.item("Layer 1");
app.documents[0].layoutWindows[0].activeLayer = myLayer;
} -
6. Re: ExtendScript for CS3 and CS2
mcolmenero Jul 10, 2009 3:40 AM (in response to John.Kordas)Hi,
I want to know by javascript wich layers are active in my indesign´s document.
Could you help me please?
Thanks
Best regards
-
7. Re: ExtendScript for CS3 and CS2
liedzeit Jul 10, 2009 4:10 AM (in response to mcolmenero)alert(app.activeWindow.activeLayer.name);
Ralf
-
8. Re: ExtendScript for CS3 and CS2
mcolmenero Jul 10, 2009 4:56 AM (in response to liedzeit)Hi,
And how I know, how many layers I have?
Thanks
Best regards
-
9. Re: ExtendScript for CS3 and CS2
Martin Fischer Jul 10, 2009 5:03 AM (in response to mcolmenero)Well, you will have to count them ... with the count()-command. ;-)
alert( app.documents.firstItem().layers.count() );
Martin Fischer
-
10. Re: ExtendScript for CS3 and CS2
mcolmenero Jul 12, 2009 11:13 PM (in response to Martin Fischer)Hi,
And if I want to reference the layers as index, because I use a For setence?
I write this code, but is not correct.
app.documents.firstItem().layers.item(i);
Thanks
Miguel
-
11. Re: ExtendScript for CS3 and CS2
mcolmenero Jul 12, 2009 11:19 PM (in response to mcolmenero)Hi,
I have found my problem, thank you very much.
The sentence is app.activeDocument.layers.item(i).name
See you

