Hi all,
I have pieced together the below to bring in a PDF to illustrator selecting which page to bring in.
set myFile to (choose file with prompt "Select the PDFs to create die line from" with multiple selections allowed)
set myPages to text returned of (display dialog "Which page number:" default answer "" buttons {"Cancel", "OK"} default button 2)
set myFirstFile to first item of myFile as text
tell application "Adobe Illustrator" to activate
openMultipageFile(myFirstFile, myPages)
tell application "Adobe Illustrator"
set thisDoc to current document
set the name of layer "Layer 1" of thisDoc to "Die Line"
end tell
------------------------------------------------------------
on openMultipageFile(fileToOpen, myPage)
tell application "Adobe Illustrator"
set user interaction level to never interact
set page of PDF file options of settings to myPage
open file fileToOpen without dialogs
end tell
end openMultipageFile
My next task is to delete every item on the page which does not have a colour called Cutter applied.
I am really struggling to achieve this. I just can’t seam to select anything. If I select items manually I have worked out how to delete the item.
All help will be greatly received.
Cheers
Andy
Hi. Unless you’re testing the code, you really don’t want to select anything”that just slows down the script.
This should probably work, but is mostly untested:
tell application "Illustrator CS.app"'s document 1 to repeat with Numbr from (count every path item) to 1 by -1
tell path item Numbr to if its fill color's spot's name is not "Cutter" and its stroke color's spot's name is not "Cutter" then delete it
end repeat
Hi there,
Thanks for your reply.
If a box does not have a stroke it appears to error. Below is the responses while running.
tell application “Adobe Illustrator”
activate
set user interaction level to never interact
set page of PDF file options of settings to “1”
open file “Macintosh HD:Users:arw:Desktop:Colours.pdf” without dialogs
→ current application
count every path item of document 1
→ 21
get name of spot of fill color of path item 21 of document 1
→ “UV”
get name of spot of stroke color of path item 21 of document 1
→ error number -1728 from «class caCC» of «class aiSC» of «class caPA» 21 of document 1
Result:
error “Adobe Illustrator got an error: Can’t get spot of stroke color of path item 21 of document 1.” number -1728 from spot of stroke color of path item 21 of document 1
Any ideas?
Thanks in advance
Andy
Hi. I assumed strokes and spots. This a bit more flexible:
tell application "Illustrator CS"'s document 1
repeat with Numbr from (count path items) to 1 by -1
tell path item Numbr to if not (fill color's class is spot color info and fill color's spot's name is "Cutter") and not (stroke color's class is spot color info and stroke color's spot's name is "Cutter") then delete
end repeat
end tell
Thanks that now works a treat
:D:D:D:D:D:D:D:D:D:D
Can we get this to delete text items as well?
have tried adding:
repeat with i from (count text frame) to 1 by -1
tell text frame i to if not (fill color's class is spot color info and fill color's spot's name is ColourToKeep) then delete
end repeat
But doesn’t seam to like it.
Could probably remove all text items as shouldn’t receive a cutter as a text item.
Cheers
Andy
I think you will need to look into the text frame’s story or text path, because every character inside a text frame can have it’s own color.
text path has a fill color property, could look into that.
Not much, just a pointer 
Thanks,
I have ended up deleting all text as it shouldn’t be part of a cutter guide anyway.
Cheers
Andy