Changing RulerUnits via BatchPlay not working

I’m trying to change the rulerUnits via BatchPlay but nothing is happeninig, this is the code I’m using:

require('photoshop').core.executeAsModal(function () {
  try {
          _obj: "set",
          _target: [
              _ref: "property",
              _property: "unitsPrefs"
              _ref: "application",
              _enum: "ordinal",
              _value: "targetEnum"
          to: {
            _obj: "unitsPrefs",
            rulerUnits: {
              _enum: "rulerUnits",
              _value: "rulerPixels"
          _options: {
            dialogOptions: "dontDisplay"
      ], {
      synchronousExecution: false,
      modalBehavior: "fail"
  } catch (e) {

This doesn’t even logs an error, so I don’t know what is happening. I saw that the RulerUnits constant is not available on the DOM yet so I tried with Batchplay to change it but nothing is happeninig.

Am I doing something wrong?

I appreciate your help.

it’s in the DOM now, see the Changelog.

Try this:

const photoshop = require('photoshop');
const app = require('photoshop').app; 
const executeAsModal = photoshop.core.executeAsModal;
const constants = require('photoshop').constants; 

// You need a modal state to change the rulers
await executeAsModal(async () => {
    app.preferences.unitsAndRulers.rulerUnits = constants.RulerUnits.MILLIMETERS
}, { commandName: "Changing ruler units" })


1 Like

Hello Davide!

Thank you very much for your answer it works now!

I’m very happy it has been updated!

I don’t explain myself how in my VS Code doesn’t updates this specific constant colors as “constants.BitsPerChannelType” or “constants.ElementPlacement” does. I actually went to the folder:


and opened the “constants.ts” file but it was not updated there but some how it works, how is it possible?

Kind regards,

The process of updating types for Photoshop is slower than it should be. Check frequently the changelog and the API reference, which is always up-to-date with the latest additions.


1 Like