How do you show/hide guides using uxp?

I am trying to use alchemist to get the right property for this.
I inspect the Document properties.

I “Add” the current state, change the guides to show/hide and “Add” again.
The difference selection shows that both are the same.

What am i doing wrong?
How can add a button to show/hide the guides in my uxp plugin

Thanks

Try turning on Listener instead of Inspector.

The only result that could be recorded is the invokeCommand, so it seems that it would be necessary to make sure that the number commandID is always reliable or not.

{
   "_obj": "invokeCommand",
   "commandID": 3503,
   "kcanDispatchWhileModal": true,
   "_isCommand": false
}

Sometimes docs is a good place to start

Thanks, I am already using this, however this is how I create or delete the guides. It doe snot have an option to show or hide them.

Gotcha. Misunderstood the intention :+1:

Thanks. I already tried the ‘Listener’.
This is is not working.

“invokeCommand” is for your information only. This tells you what happened in Photoshop. But this can’t be played.

This is achieved by executing performMenuCommand based on the recorded commandID.

const { core } = require('photoshop') ;

await core.executeAsModal(async () => {
  await core.performMenuCommand({commandID: 3503}) ;
}, {}) ;

How can I know the current state for the guides, whether they are shown or not?

1 Like

It should theoretically be possible to check this with getMenuCommandState.

However, this method found by kbsanders seems more reliable. I actually tried it.

1 Like

thanks, working…

async function myCommandState(tool) {
   var result;
   await require("photoshop").core.executeAsModal(async (executionControl, descriptor) => {
      result = await batchPlay(
         [
            {
               _obj: 'uiInfo',
               _target: {
                 _ref: 'application',
                 _enum: 'ordinal',
                 _value: 'targetEnum',
               },
               command: 'getCommandEnabled',
               commandID: constmenuCommandCode[tool],
             }
         ], 
         {}
      );
   });
   return result[0].result;
}

where constmenuCommandCode is my own array with toolName: tooId

1 Like

sttk
I wanted to know if these id commandID: 3503 they are good for both mac and pc and if there is a possibility that they will change in the future, I know that those that change have a negative value like -1549.

There are multiple posts about command IDs in the forum, but to summarize in short:

  • Negative IDs may change even on re-opening the Ps
  • Positive IDs are the same on Win and Mac
  • Positive IDs should be persistent, but they aren’t. Here’s the case when Adobe decided to just change the ID
2 Likes