Copy link to clipboard
Copied
I have a group (consisting of either one or two text frames -- an image with an optional caption frame) anchored in text
I need to be able to select the group (via mouse) and then run a script to change the size of the image frame AND resize the caption frame bounds
Scaling the group isn't good because that also scales the text of the caption...
How do I get a reference to the frames inside the group?
(Releasing the group, ungrouping, changing, then regrouping and re-anchoring seems the wrong way to do it...)
Thanks
Hi Akiva,
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.gra
Copy link to clipboard
Copied
With the group selected:
app.selection[0].textFrames[0] // the text frame
app.selection[0].rectangles[0] // the image container
Peter
Copy link to clipboard
Copied
pkakrel: app.selection[0].textFrames[0] only returns one of the frames -- trying app.selection[0].textFrames[1] returns nothing
thanks
Copy link to clipboard
Copied
> app.selection[0].textFrames[0] only returns one of the frames -- trying app.selection[0].textFrames[1] 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.
P.
Copy link to clipboard
Copied
pkahrel
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...)
Copy link to clipboard
Copied
> 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.
Copy link to clipboard
Copied
Thanks to both of you.
Copy link to clipboard
Copied
Uwe
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
thanks again
Copy link to clipboard
Copied
If there is one placed image involved, the image itself (without its container) is counting as a separate pageItem.
Uwe
Copy link to clipboard
Copied
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.
Uwe
Copy link to clipboard
Copied
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:

Uwe
Copy link to clipboard
Copied
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…
Uwe
Copy link to clipboard
Copied
> 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.
Copy link to clipboard
Copied
Hi Akiva,
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?
Why?
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.)
Uwe
Find more inspiration, events, and resources on the new Adobe Community
Explore Now