Indesign CS5: Grouping via AS doesn't want to work

This is driving me crazy: every time I try to name a selection to group, I keep getting an “invalid parameter” error. Here’s an example:

	tell myNewDoc
		
		set currentPage to active page of layout window 1
		
		tell currentPage
			
			set mySel2 to all page items of myNewDoc
			
			select mySel2
			
			set myGroup2 to make group with properties {group items:mySel2} <--ERROR

		end tell

	end tell

I’ve tried so many different variations I can’t even count anymore. Any ideas? All I want to do is select every page item in the doc so I can group it and tell the group to move elsewhere on the page in one big piece.

hi joecab

I don’t have CS5 loaded here, but try this,

tell application "Adobe InDesign CC 2014"
	set {a, b, c, d} to bounds of page 1 of document 1
	set a_Doc to active document
	set a_Sel to page items of a_Doc
	tell a_Doc
		set _newsel to make group with properties {group items:a_Sel}
		set {w, x, y, z} to geometric bounds of result
		move _newsel by {(d / 2 - (x + z) / 2), (c / 2 - (w + y) / 2)}
	end tell
end tell

Hi. Budgie’s code centers groups on the page, but you really only need planar coordinates for moving by an amount or to a location. Selections are not necessary for grouping and should generally be avoided, unless being used for testing.

tell application "Adobe InDesign CS3"'s document 1 to move (make group at it with properties {group items:page 1's page items}) by {2, 3}

tidy Marc :smiley:

Thanks, but I tried both of your suggestions. Same error. :frowning:

But now I’m wondering if it’s because the objects I’m trying to group and move are centered over the page but they stick out into the pasteboard. (Basically, it’s a bunch of page items copied and resized from another document and pasted into a new documentcreated on the fly.)

For “make group with properties” do all elements need to actually be on the page?

did you try the scripts by just creating rectangles etc on a new page?
if so, then the scripts should work fine, even with items not sitting
directly on the main page, maybe something else is going on
earlier in another part of the code leading up to this point?

Yes. All elements need to be on the page, if you are telling the page what to do with its objects. If in the pasteboard, try “spread.”

Ah, I think that was it. To get around the whole spread/pasteboard thing I make the page view fit in the window to center it, then when I pasted in my page items they were perfectly centered. Thank you both! I don’t think I would have figured this out anytime soon without your help.