I need to create a layer on the bottom of a document that has a certain spot stroke color and no fill. I’ve got it almost working perfectly but I can’t get it to have no fill. It always fills with the default color.
I also need to make an if else command so it will skip the spot color creation and layer creation if they already exist. But that’s secondary and easy…I think.
tell application "Adobe Illustrator"
set bottomLayer to make new layer ¬
at end of document 1 with properties {name:"Through Cut"}
set spotColorCount to count of spots in document 1
set newSpot to make new spot in document 1 with properties ¬
{name:"Through Cut", color:{cyan:0.0, magenta:100.0, yellow:0.0, black:0.0}}
set default stroke color of document 1 to {spot:newSpot}
set docRef to the current document
tell docRef
set |page width| to width
set |page height| to height
set ruler origin to {0, 0}
set {|rectangle width|, |rectangle height|} to {width, height}
set |rectangle| to make at end new rectangle with properties ¬
{name:"rectangle", position:{((|page width| - |rectangle width|) / 2), ((|page height| + |rectangle height|) / 2)}, width:{|rectangle width|}, height:{|rectangle height|}}
set fill color of |rectangle| to {swatch:swatch "None"} --This line not working
end tell
end tell
Hi. You’re using unnecessary pipes and variables, and your code can be simplified by directing commands as a block. Since you’re starting out, I’d encourage you to download Adobe’s free AppleScript scripting guide for Illustrator; it helped me.
tell application "Adobe Illustrator"'s document 1
if not (exists layer "through cut") then make layer at end with properties {name:"Through Cut"}
if not (exists spot "Through Cut") then make spot with properties {name:"Through Cut", color:{cyan:0.0, magenta:100.0, yellow:0.0, black:0.0}}
set default stroke color to {spot:spot "Through Cut"}
make rectangle at end with properties {name:"rectangle", bounds:{0, 0, width * 1, height * 1}, filled:0} --multiplication for coercion to real
end tell
My default settings may be different than yours, so try reinserting your ruler origin line that I removed; that should fix the misalignment. The rectangle duplication problem just needs an if consideration, like the first two lines.
Perfect! And then I added a ruler origin to fix the displacement problem.
tell application "Adobe Illustrator"'s document 1
if not (exists layer "Through Cut") then make layer at end with properties {name:"Through Cut"}
if not (exists spot "Through Cut") then make spot with properties {name:"Through Cut", color:{cyan:0.0, magenta:100.0, yellow:0.0, black:0.0}}
set default stroke color to {spot:spot "Through Cut"}
set ruler origin to {0, 0}
if not (exists page item "Through Cut") then make rectangle at end with properties {name:"Through Cut", bounds:{0, 0, width * 1, height * 1}, filled:0} --multiplication for coercion to real
end tell