Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
You can group myItem and myRectangle.
You can review discuss at: inserting numbers in a polygon
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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:
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 )
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more