With the group selected:
app.selection.textFrames // the text frame
app.selection.rectangles // the image container
you'll get access to all frames inside of the group with:
var arrayOfPageItemsInGroup = group.allPageItems;
A loop through the array will lead you to every member of the group.
How you would identify the text frame of the caption?
This could be done perhaps by looking at the used formatting (appliedParagraphStyle) of the text in the text frame.
Or other criteria… like parts of its contents.
How would you identify the container frame of the image?
It is the one holding a graphic. pageItem.graphics.length would be exactly the value 1.
Selecting the group by mouse?
Should that be part of the script?
If you are able to select the group by mouse with a script you are also able to identify the group and run some code on it without doing a selection…
(Maybe I misunderstand what you like to do in what order.)
pkakrel: app.selection.textFrames only returns one of the frames -- trying app.selection.textFrames returns nothing
Thanks -- that works
One Q: A group of two frames has group.allPageItems=3
Looping through the group gives the two frames (ID'd by their unique objectStyle names) and a third object with an object style name of none] -- the group has a different Object Style name -- any idea what the third item is?
(The layer window only shows 2 items in the group)
the group will be selected by mouse -- the group is a picture/caption group -- occasionally the picture will need to be resized along with the caption box for design reasons.
Select the group, then run a script to resize the two frames inside the group based on an inputted width
If there is one placed image involved, the image itself (without its container) is counting as a separate pageItem.
Just show a screen grab of your situation. Also open the Layers Panel and show all page items in that particular layer.
View set to "Show Frame Edges" and select the group before doing the screen grab.
> app.selection.textFrames only returns one of the frames -- trying app.selection.textFrames returns nothing
As I indicated, if you have a group of a text frame and and image, the image is in a rectangle, not a text frame.
> A group of two frames has group.allPageItems=3
Maybe the textframe has an inline frame in it. In that case, the group contains two page items, and one of the page items (the text frame) contains the third page item.
Here a screen grab from my German InDesign CS6 where the Layers Panel is fully expanded:
Note: From the UI you cannot see that a placed image is in fact two pageItems.
The container graphic frame PLUS inside of it the image itself.
Here the situation, if you select the container frame:
Here, if you select the image itself:
if I add a textFrame -- then place an image in it -- isn't it still a textFrame object?
(If not then sorry -- I didn't try rectangle...)
(in my case I start with a textFrame since the contents could be text or an image -- placing into them the contents of a file (the filename is in the inDesign file with a unique char style...)
Here a series of screen grabs with a pasted in placed image to another graphic frame.
The graphic frame where the image (plus container frame) is pasted in has the a yellow fill color to make things more clear.
In the UI it's confusing to read out the Layers Panel and all the page items, because the developers are playing some tricks with the naming of objects there.
Just watch the selection and what is visible in the Layers Panel at the right edge:
I hope, you understand why I asked for some screen grabs showing the group, the text frame where it is anchored and the Layers Panel expanded…
> if I add a textFrame -- then place an image in it -- isn't it still a textFrame object?
No, when you place an image into a text frame, InDesign converts it to a rectangle.
Uwe is right by the way: a placed image counts for two page items: the image itself and its containing rectangle.
Thanks to both of you.