Skip to main content
Participant
November 19, 2021
Answered

Script to Apply Blending Mode to New Layer

  • November 19, 2021
  • 2 replies
  • 1122 views

I'm looking to make a basic script that creates a new layer and sets the blending mode of that layer to "Darken." I've tried using Applescript and get an error stating "Can’t make some data into the expected type." I believe this is because it's expecting to apply the blend mode to an object instead of the layer itself. Is this possible either in Applescript or Javascript? Below is the code I attempted using Applescript

tell application "Adobe Illustrator"
	set layerRef to make layer at document 1 with properties {name:"Spot White", blend mode:"darken"}
end tell

 

This topic has been closed for replies.
Correct answer hhas01

According to Illustrator’s AppleScript dictionary, the `blend mode` property requires an enumeration (symbol) value, not a string. Use:

{name:"Spot White", blend mode:darken}

 

2 replies

hhas01Correct answer
Inspiring
November 21, 2021

According to Illustrator’s AppleScript dictionary, the `blend mode` property requires an enumeration (symbol) value, not a string. Use:

{name:"Spot White", blend mode:darken}

 

Participant
November 22, 2021

Ah-hah, that explains it! Worked like a charm after removing the quotes. Thanks!

femkeblanco
Legend
November 19, 2021

In Javascript (replace "Layer 1" with the name of your layer in quotations): 

 

app.activeDocument.layers["Layer 1"].blendingMode = BlendModes.DARKEN;

 

Participant
November 22, 2021

Thanks! I'll give that a try if I make a javascript version to use on my Windows PC.