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

script to insert items into a frame

Guest
Jan 05, 2018 Jan 05, 2018

Hello friends.

All of us know this operation "Select and copy any item, then select a rectangle and make a paste into to insert the item into the rectangle".

I can do this writing a scripts something like

myItem.select();

Application.copy();

myRectangle.select();

Application.pasteInto();

I'd like to know if there is way to do the same but without using the select-copy-paste commands. I think this should be some masking operation. Thanks in advance.

TOPICS
Scripting
1.2K
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
Enthusiast ,
Jan 08, 2018 Jan 08, 2018

You can group myItem and myRectangle.

You can review discuss at: inserting numbers in a polygon

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 ,
Jan 08, 2018 Jan 08, 2018

Hi,

as far as I know there is no method that would accomplish this without adding a helper object like a text frame where you can anchor an object to. At least not for all page items you want to paste-inside.

You could experiment with method contentPlace().

Here an example:

Re: Moving embedded graphic to another frame

Regards,
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 ,
Jan 08, 2018 Jan 08, 2018

After some more tests with contentPlace() I think this is the way to go.

For doing more items in one go you have to group the items first. Also watch for the position of the content-placed item.
It is very likely that you have to move the placed item in its container frame to the position of the original.

Some sample code where we have one group and a rectangle on page 1 of a document and we want to "move" a duplicate of the group inside the rectangle:

var source = app.documents[0].pages[0].groups[0];

var gbSource = source.geometricBounds;

var target = app.documents[0].pages[0].rectangles[0];

target.contentPlace([source]);

target.groups[0].move( [gbSource[1] , gbSource[0] ] );

Regards,
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 ,
Jan 08, 2018 Jan 08, 2018

About contentPlace():
That method will always duplicate items to the target.

Just moving items to the target—maintaining their id-numbers—is not possible.

Regards,
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 ,
Jan 10, 2018 Jan 10, 2018

laindustria  wrote

… I think this should be some masking operation. Thanks in advance.

Hi laindustria ,

if your knowledge background is more Adobe Illustrator related, you might think of a masking operation. Simply setting the value of a "clipping" property to true perhaps. InDesign is working differently and that simple "clipping" property is not supported. In Illustrator you simply do a closed path and declare it as mask. That's it.

In InDesign you have to copy/paste inside or you are using contentPlace() as I had shown.

Did you try out contentPlace() and were successful?

Regards,
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 ,
Feb 04, 2020 Feb 04, 2020
LATEST

Hi laindustria,

now the answer is: Yes.

 

The method to add an object inside a graphic frame is to add an MSO ( multistate object ) to the target frame.

The next step is to add the object as state to the MSO, release the state and remove the MSO.

The released object lands inside the target frame. The integrity of the object is maintained. You can see that its ID will not change during the process.

 

See the analog method with "moving" existing items to groups without ungrouping the group:

https://community.adobe.com/t5/indesign/how-to-add-element-s-to-an-existing-group-without-ungrouping...

 

Moving an object out of a graphic frame is also possible:

Just anchor the object to an insertion point of a text frame outside of the graphic frame and release the object from its anchor. Also with this process the integrity of the object is maintained.

 

Regards,
Uwe Laubender

( ACP )

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