Skip to main content
Participant
November 21, 2024
Question

Access Image Variables Using Scripts

  • November 21, 2024
  • 2 replies
  • 237 views

I've looked through the Photoshop scripting object model to see if there's a way to create and/or modify image variables & datasets using scripting.  I haven't been able to find anything, and the few things I've found Googling haven't seemed to work.

Ideally there'd be something along the lines of "activeDocument.image.variables.define(...)" 

Does anyone know whether you can do variable changes via scripting?

This topic has been closed for replies.

2 replies

c.pfaffenbichler
Community Expert
Community Expert
November 21, 2024

What would you expect the result of "activeDocument.image.variables.define(...)" to be? 

Participant
November 21, 2024

Well, in the Variables dialog in Photoshop, you can create a variable and associate it with a layer and a particular set of actions.  So (for example) activeDocument.image.variables.define(card_layer, "card_replacement_text", TEXT) would create a variable associated with a layer "card_layer,", would be a text replacement variable named "card_replacement_text."  That variable could then be assigned text in a DataSet and the image updated.

c.pfaffenbichler
Community Expert
Community Expert
November 21, 2024

I was not clear: Do you expect a variable to be created for each (non-background-)Layer? 

Stephen Marsh
Community Expert
Community Expert
November 21, 2024

It's not in the DOM, however, there is some low-level Action Manager code.

 

This is the only example that I have: