Illustrator - select type size OR move items to new layer and delete

Hello,

We use a program that creates barcodes, and also creates its own line of unsolicited gobblety gook text. This text is just random numbers and letters at .1pt, rotated 90 degrees, and hidden under the first bar of the barcode.

The type I want to keep is a weird size - 5.98 pt

I was having a hard time writing a script that would select just this tiny type and delete it, so I thought I would move all vector art to its own new layer, move all type over 3 pt size to another new layer, and then just delete the original remaining layer that contains the type I don’t want.

This trial is not hitting the mark either. Any suggestions please? Thanks!


tell application "Adobe Illustrator"	
set allPageItems to every page item of group item 1 of document 1
	move allPageItems to beginning of layer 1 of document 1
	
	
	set barLayer to make layer at document 1 with properties {name:"Bars"}
	set textLayer to make layer at document 1 with properties {name:"Number"}

	set vectorItems to (every vector item)
	move vectorItems to barLayer

	set textItems to (every text item of document 1 whose size is greater than 3)
	move textItems to textLayer
	
	set deleteLayer to "Layer 1"
	delete (every layer of document 1 whose name starts with deleteLayer)
	
	
end tell

Try this:

tell application "Adobe Illustrator"
	delete (every character of every text frame of document 1 whose size is 5.98)
	delete (every text frame of document 1 whose contents is "")
end tell

it deletes every character of a given size then deletes any empty text frames to clean up after itself.

Great! That helped. Thank you.

Can you please explain to me where I was going wrong with getting all my vector items on one layer and my text on another layer?

It’s all in the syntax and hierarchy that the program uses. What you probably want is to set vectorItems to every path item of document 1 which should give you every polygon and path on the page. To move them to the desired layer just use the following:

move every path item to layer "Bars"

This will not move mesh gadients, text, graphs, etc. and it will ungroup group items. To eliminate unwanted things happening you would need to target the items more precisely similar to the following:

move every group item of layer "Layer 1" to layer "Layer 3"
move every path item of layer "Layer 1" to layer "Layer 2"

Thanks Jerome. That makes sense now. :slight_smile: