Skip to main content
Participant
June 1, 2022
Answered

Applescript to find elements in specific stroke colour and move to specific layer

  • June 1, 2022
  • 2 replies
  • 615 views

Hi scripting community,

I've spent some time searching for what i thought might be something simple but can't find anything that works in the current version of illustrator.

 

I'm after a script that can search the current document for any element with the specific colour name "Cut" and move said items to an existing layer called "Diecut"

 

Thanks for your help!

This topic has been closed for replies.
Correct answer sttk3

Doing something to everything that matches conditions is one of the most AppleScript-friendly processes.

 

The following example moves path items whose editable and stroke color is spot "Cut" to layer "Diecut".

tell application "Adobe Illustrator"
	tell document 1
		set dst_layer to layer "Diecut"
		tell (path items whose (editable of it is true) and (class of stroke color of it is spot color info) and (name of spot of stroke color of it is "Cut")) to move to dst_layer
	end tell
end tell

 

2 replies

sttk3Correct answer
Legend
June 2, 2022

Doing something to everything that matches conditions is one of the most AppleScript-friendly processes.

 

The following example moves path items whose editable and stroke color is spot "Cut" to layer "Diecut".

tell application "Adobe Illustrator"
	tell document 1
		set dst_layer to layer "Diecut"
		tell (path items whose (editable of it is true) and (class of stroke color of it is spot color info) and (name of spot of stroke color of it is "Cut")) to move to dst_layer
	end tell
end tell

 

Participant
June 2, 2022

OMG Yes! @sttk3 Thankyou so much 🙂

 

This works perfectly

femkeblanco
Legend
June 1, 2022

Does it have to be Applescript (i.e. so as to exclude JavaScript)?  Are some of the items nested?  (If so, what is to be done in this case?)  What is the color type? 

Participant
June 1, 2022

Idealy applescript becuase i've already got some code doing other things.  All the elements are of basic constriction (shapes, lines etc) The colour 'Cut' is made as a spot colour and the document format is CMYK.