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

modifying parts of an anchored group

Explorer ,
Apr 15, 2016 Apr 15, 2016

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

TOPICS
Scripting
809
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

correct answers 1 Correct answer

Community Expert , Apr 15, 2016 Apr 15, 2016

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

...
Translate
Community Expert ,
Apr 15, 2016 Apr 15, 2016

With the group selected:

app.selection[0].textFrames[0]  // the text frame

app.selection[0].rectangles[0]   // the image container

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
Explorer ,
Apr 15, 2016 Apr 15, 2016

pkakrel: app.selection[0].textFrames[0] only returns one of the frames -- trying app.selection[0].textFrames[1] returns nothing

thanks

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 ,
Apr 15, 2016 Apr 15, 2016

> 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.

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 ,
Apr 15, 2016 Apr 15, 2016

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...)

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 ,
Apr 15, 2016 Apr 15, 2016

> 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.

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 ,
Apr 15, 2016 Apr 15, 2016
LATEST

Thanks to both of you.

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 ,
Apr 15, 2016 Apr 15, 2016

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

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 ,
Apr 15, 2016 Apr 15, 2016

If there is one placed image involved, the image itself (without its container) is counting as a separate pageItem.

Uwe

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 ,
Apr 15, 2016 Apr 15, 2016

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

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 ,
Apr 15, 2016 Apr 15, 2016

Here a screen grab from my German InDesign CS6 where the Layers Panel is fully expanded:

AnchoredGroup-LayersPanelExpanded.png

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:

AnchoredGroup-LayersPanelExpanded-ContainerSelected.png

Here, if you select the image itself:

AnchoredGroup-LayersPanelExpanded-ImageSelected.png

Uwe

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 ,
Apr 15, 2016 Apr 15, 2016

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:

Bildschirmfoto 2016-04-15 um 16.42.03.png

Bildschirmfoto 2016-04-15 um 16.42.22.png

Bildschirmfoto 2016-04-15 um 16.42.33.png

Bildschirmfoto 2016-04-15 um 16.42.41.png

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

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 ,
Apr 15, 2016 Apr 15, 2016

> 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.

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 ,
Apr 15, 2016 Apr 15, 2016

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

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