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

New Here ,
May 31, 2022 May 31, 2022

Copy link to clipboard

Copied

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!

TOPICS
Scripting

Views

83

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Jun 01, 2022 Jun 01, 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

Likes

Translate

Translate
Advisor ,
Jun 01, 2022 Jun 01, 2022

Copy link to clipboard

Copied

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? 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 01, 2022 Jun 01, 2022

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 01, 2022 Jun 01, 2022

Copy link to clipboard

Copied

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

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 01, 2022 Jun 01, 2022

Copy link to clipboard

Copied

LATEST

OMG Yes! @sttk3 Thankyou so much 🙂

 

This works perfectly

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines