Keep selected color, delete the rest

I am trying to get Illustrator to recognise different variations of a certain color, and then delete any elements which are not made up of that color.
I have tried many things, and have come close. This is the script shown below.
the error i get is "cannot get every group item of layer 1 of document 1 whose swatch spot color into ≠“Color|color|COLOR”.


tell application "Illustrator CS"
	set mydoc to document 1
	activate
	tell mydoc
		try
			swatch "Cutter" = true
			set value_1 to "Color"
		on error
			try
				swatch "cutter" = true
				set value_1 to "color"
			on error
				try
					swatch "CUTTER" = true
					set value_1 to "COLOR"
				on error
					try
						swatch "Cutter|cutter|CUTTER" = true
						set value_1 to "Color|color|COLOR"
					on error
						display dialog "No Color Found
Now Halting Script" buttons {"OK"} default button {"OK"}
						stop
					end try
				end try
			end try
		end try
	end tell
	--tell application "Illustrator CS"
	tell (every group item of layer 1 of mydoc where swatch spot color info is value_1)
		delete (every group item of layer 1 of mydoc where swatch spot color info is not value_1)
	end tell
	tell (every path item of layer 1 of mydoc where swatch spot color info is not value_1)
		delete every path item of layer 1 of mydoc
	end tell
end tell

Any help with this is greatly apprecited.

cs_field,

You’re going to have to loop through the path items, text items that make up the group to select the individual elements of the group whose color is the type you’re looking for. You cannot set fill color of a group item or get the fill color of a group item (as far as I know). You can get the color info for the swatch and then compare it to the fill color of a path item.

tell application "Illustrator CS"
	activate
	set thisDoc to current document
	get properties of group item 1 of thisDoc
	tell thisDoc
		if swatch "Proof Blue" = true then
			set swatchIndex to index of swatch "Proof Blue"
			set value_1 to "Color"
			set theColor to color of swatch swatchIndex
		end if
	end tell
end tell

You can then use the info to acomplish your task.

PreTech