Skip to main content
Participant
September 18, 2008
Question

CS2 JS - targetting frame labels within groups

  • September 18, 2008
  • 4 replies
  • 681 views
I have some CS2 JS scripts that cycle through sequentially labelled frames but they fail if the target frame happens to be part of an object group.

Is it possible to target frames via their labels whilst they are still grouped together or perhaps grouped with other objects?

thanks

Greg
This topic has been closed for replies.

4 replies

Known Participant
September 19, 2008
Thanks for the tips Robert and Kasyan!
Kasyan Servetsky
Legend
September 19, 2008
Hi Greg and Brett,

Here is what Robin said but in JS. It works even for nested groups.

Kasyan
//---------------------------
var myDoc =app.activeDocument;

var myFrame = myDoc.textFrames.item("red");
// do something here
myFrame.fillColor = myDoc.colors.item("C=0 M=100 Y=0 K=0");
var myGroups = myDoc.groups;
for ( i = 0; i < myGroups.length; i++) {
var myItems = myGroups.allPageItems;
for ( j = 0; j < myItems.length; j++) {
if (myItems.constructor.name == "TextFrame" && myItems.label == "red") {
// do something here
myItems.fillColor = myDoc.colors.item("C=0 M=100 Y=0 K=0");
}
}
}
Participant
September 20, 2008
Thanks everyone, great tips.

Greg
Known Participant
September 18, 2008
I have run into this issue as well (a real pain).

I ended up ungrouping once the group had served its purpose (ie moved from one location to another). I could then select the objects via their label. The problem with doing it this way would be if I had to move the non existant group again, thankfully I did not.

Brett
Known Participant
September 19, 2008
instead of ungrouping - you can do this:

myGroup.AllPageItems.Item(myLabel)

robin

--
www.adobescripts.com
Known Participant
September 18, 2008
try:

myDoc.AllPageItems.Item(myLabel)

instead of:

myDoc.PageItems.Item(myLabel)

(VB example - convert to JS)

robin

--
www.adobescripts.com