Skip to main content
Known Participant
September 25, 2008
Question

CS3 JS Add group into frame

  • September 25, 2008
  • 2 replies
  • 358 views
Hi
In InDesign UI you can copy a group of frames and paste it into another frame.

I'm trying to replicate the results via JS

I tried this:
x = app.activeDocument.rectangles.add();
y = app.activeDocument.ovals.add();
z = app.activeDocument.ovals.add();
x.groups.add([y,z]);

then this:
x = app.activeDocument.rectangles.add();
x.groups.add([app.activeDocument.ovals.add(),app.activeDocument.ovals.add()]);

Both attempts ended up with "Invalid parameter" error message

Then I tried this:
x = app.activeDocument.rectangles.add();
y = app.activeDocument.ovals.add();
z = app.activeDocument.ovals.add();
g = app.activeDocument.groups.add([y,z]);

g.select();
app.cut();
x.select();
app.pasteInto();

It did the job without errors, but I'm affraid it will be unnecessary slow in real world deployment.

Please, can anyone explain what I did wrong with my first two attempts?

Thanks for help
Weller
This topic has been closed for replies.

2 replies

Inspiring
September 25, 2008
Actually, although the UI won't let you create such an object, it does support them. Objects that start life as Excel charts have exactly this structure. Take them into Illustrator then copy and paste into InDesign and you'll find you have objects that are exactly what you've discovered.

See: http://indesignsecrets.com/easily-add-captions-to-graphics-frames.php

Dave
Known Participant
September 25, 2008
Hi
Having carried out more experiments I made this discovery:
(assuming that "myObject is a rectangle")

after running:

myObject.rectangles.add();
myObject.rectangles.add();
myObject.rectangles.add();

I ended up with a couple of rectangles inside of the "myObject" frame.
But they were not grouped.
Though this partly solves my problem, I'm aware that Indesign won't allow me to do this in UI. (That is, it's only a single object or a group that can be "pasted into"). Am I really in for a big problem if I use this method?