group and scale all items in an illustrator CS 2 document

Hi,

I am trying to select all items in a document, group them, then scale the group by 400%.

At the moment I can select all items and scale them with out any problems. But the scale needs to size them in relation to each other so I need to group them first then scale them. Below is the code I have so far. But I am getting an error at “move selected items…”, the error is “Adobe Illustrator got an error: and Illustrator error occurred: 1346458189 (‘PARM’)”. I just can’t seem to put them in a group.

set selection of document i to {}
		
		set groupRef to make new group item at document i
		
		if (count page items of document i) > 0 then
			set layerCount to count layers in current document
			repeat with l from 1 to layerCount
				set layerRef to layer l of document i
				if (count page items of layer l of document i) > 0 then
					set selected of (every page item of document i whose container is layerRef) to true
				end if
			end repeat
		end if
		
		set selectedItems to selection of document i
		
		move selectedItems to beginning of groupRef
		
		tell document i
			scale selectedItems horizontal scale 400.0 vertical scale 400.0 about center
		end tell

I am not even sure if “move selectedItems to beginning of groupRef” is valid. The Adobe AppleScripting Guide does not explain how to add existing items to a group, I can create new rectangles in a group, just not existing items. If you could just show me how to group all items then I think I will be set.

Thanks in advance for your help.

Try this i know its just in cs but you might be able to make it work for your version it does what you want it to on my mac…
if it doesn’t work i’m sorry cause i’m new to scripting myself


set selection of document 1 to {}
tell application “Illustrator CS”

set groupRef to make new group item at end of document 1

if (count of page items of document 1) is greater than 0 then
	set layerCount to count layers in current document
	repeat with l from 1 to layerCount
		set layerRef to layer l of document 1
		if (count page items of layer l of document 1) > 0 then
			set selected of (every page item of document 1 whose container is layerRef) to true
		end if
	end repeat
end if

set selectedItems to selection of document 1
move every path item of layer 1 of document 1 to end of groupRef


tell document 1
	scale groupRef horizontal scale 400.0 vertical scale 400.0 about center
end tell

end tell

pidge1, thanks for the reply.

Adding “move every path item of layer 1 of document 1 to end of groupRef” only groups all the path objects. So it works, but my set of files just happen to contain several groups that are not all in one group :frowning:

For example the file contains 2 groups. I want these two groups in one group. :slight_smile:

If I change it to:

move every group item of layer 1 of document 1 to end of groupRef

I get an error because I think it is also trying to group the groupRef group item into it’s self. How can I exclude this new empty group that I created earlier in the script?

Can I do something like… except who’s name is groupRef ???

Thanks

Try this a guy on here called pretech gave me abit of script to ungroup stuff this should ungroup everthing then regroup the lot then scale them up…
hope this works…

set selection of document 1 to {}
tell application "Illustrator CS"
	activate
	set thisdoc to current document
	try
		set selection to every group item of layer "Layer 1" of thisdoc -- you can have it select every group item of the document also.
	on error
		display dialog "No group items" giving up after 2
	end try
	tell thisdoc
		move every path item of selection to beginning of layer "Layer 1" of thisdoc
	end tell
	
	set groupRef to make new group item at end of document 1
	
	if (count of page items of document 1) is greater than 0 then
		set layerCount to count layers in current document
		repeat with l from 1 to layerCount
			set layerRef to layer l of document 1
			if (count page items of layer l of document 1) > 0 then
				set selected of (every page item of document 1 whose container is layerRef) to true
			end if
		end repeat
	end if
	
	set selectedItems to selection of document 1
	move every path item of layer 1 of document 1 to end of groupRef
	
	
	tell document 1
		scale groupRef horizontal scale 400.0 vertical scale 400.0 about center
	end tell
end tell

I don’t know if this is true. but in my findings I needed to also account for the stroke weights being scaled by the same percentage. It would be ideal if it relied upon how Illustrator’s preferences were set, but it seems that without this code strokes would not be scaled. I am using CS4.

scale groupRef horizontal scale 400.0 vertical scale 400.0 line scale 400.0 about center