Accessing the DOM from UPX plugins

I am trying to convert some CEP functions into the UXP environment but I’m having trouble accessing the DOM. For instance this code worked with CEP:

var orig_ruler_units = app.preferences.rulerUnits;
var orig_type_units = app.preferences.typeUnits;
app.preferences.rulerUnits = Units.PIXELS; 
app.preferences.typeUnits = TypeUnits.POINTS; 

But these same lines of code error out in the plugin because the attributes don’t exist. Is there any documentation on what is accessible via the UPX environment? I know how I can find these for use via batchplay but if I can go through the DOM I would prefer that approach.

Hi, you might want to look into using this fantastic Photoshop plugin for UXP “Alchemist” by @Jarda :+1:
You can grab the developper version for free here GitHub - jardicc/alchemist
Highly recommended :wink:

Inside Alchemist, you can shoose to get Application rulerUnits Content:

Here’s the code you can use

const batchPlay = require("photoshop").action.batchPlay;
let getRulerUnits = await batchPlay(
          "_obj": "get",
          "_target": [{
              "_property": "rulerUnits"
              "_ref": "application",
              "_enum": "ordinal",
              "_value": "targetEnum"
          "_options": {}
        }], {
          "synchronousExecution": true
      console.log(`Ruler Units: ${getRulerUnits}`)

Is that what you 're after ?

Thanks, but I was looking to see if I could do this without batchplay. I already have similar code in my script but it seems like every interaction with photoshop is now requiring a batchplay command. I was looking to see if anyone knew if UXP would have access to any of the photoshop objects like Extendscript had.

The rulerunit property is not yet available via DOM. The API will grow over time, but right now this is all that’s accessible on the app object.

Thanks, that is what I thought.