Hi, I am working on a script where I need to fill in all items of a layer that have a color with black and do the same with strokes. Essentially, I have a 4 color layer and need to create a “white plate”. So everything on the color layer turned black, but retaining all transparency.
The main thing I’m running into is the fact that there is no “ungroup” Applescript command. So instead I am trying to create a list of items that I can operate on which has all path items regardless of whether or not they are in a script. I have a handler which I am using to try to select all items within the group but it isn’t working.
Can someone take a look at it and tell me what I’m doing wrong (or suggest a better way to solve my overall issue)?
on getallitems(oneitem)
set allItems to {}
tell application "Adobe Illustrator"
if class of oneitem is group item then
set the_paths to page items of oneitem
repeat with i from 1 to number of items in the_paths
set this_item to item i of the_paths
if class of this_item is group item then
set allItems to allItems & page items of this_item
end if
end repeat
return allItems
else
set allItems to oneitem
return allItems
end if
end tell
end getallitems
Hi. The basic issue is that there are no page items of page items, only path items.
I believe that you wouldn’t want to attempt the change of any null color so I filtered out that possibility. You’ll need to create 3 additional variations, one for each color class and one for each fill/stroke class.
tell application "Illustrator CS"'s document 1
try-- color class 4C, fill class
set ((page items whose class is group item)'s path items whose fill color's class is CMYK color info and fill color is not {cyan:0.0, magenta:0.0, yellow:0.0, black:0.0})'s fill color to {cyan:0.0, magenta:0.0, yellow:0.0, black:100}
end try
try-- color class gray, fill class
-- set...
end
--etc
end tell
Thanks for your fast answer. I tried this and it works for first level groups, but doesn’t seem to take care of the groups within groups. My guess is that these aren’t path items of the parent group and thus aren’t taken into account.
I can’t replicate the behavior you’re describing, even with groups nested about 10 levels deep. This is probably a version-specific issue, as I now seem to recall seeing added complexity in group disclosure triangles in CS5. Investigate the AS dictionary for your specific version, and fiddle around with it.
Im not sure Im understanding your request fully. If you want a white plate don’t you want all printing areas to be solid black? That a side Shane is right you move items in and out of containers when there are no elements left in a group its gone. An alternative method that may or may not help you.
duplicate your full colour layer
select all the elements of the new layer
call an action that does
Menuitem/Edit/Edit Colors/Convert To Greyscale.