Skip to main content
Inspiring
July 18, 2018
Question

Test if guides visible?

  • July 18, 2018
  • 3 replies
  • 1319 views

Hello,

Is there a way to test in Javascript if document's guides are visible or not (shown or hidden by user)?

Thank you.

This topic has been closed for replies.

3 replies

Braniac
July 18, 2018

And why do you need to know the guides are visible or not?

On CS6 it's impossible to know.

You can use the function to force the visibility of the guides.

Works in CS6 and CC2018.

show_guides()

function show_guides()

    {

    try {

        var d1 = new ActionDescriptor();

        var d2 = new ActionDescriptor();

        d2.putUnitDouble( charIDToTypeID( "Pstn" ), charIDToTypeID( "#Prc" ), 200 );

        d2.putEnumerated( charIDToTypeID( "Ornt" ), charIDToTypeID( "Ornt" ), charIDToTypeID( "Hrzn" ) );

        d1.putObject( charIDToTypeID( "Nw  " ), charIDToTypeID( "Gd  " ), d2 );

        executeAction( charIDToTypeID( "Mk  " ), d1, DialogModes.NO );

        app.activeDocument.guides[app.activeDocument.guides.length-1].remove();

        }

    catch (e) { alert(e); throw(e); }

    }

frmorelAuthor
Inspiring
July 19, 2018

, your function show_guides() works fine.

Kukurykus
Braniac
July 18, 2018

Another version for CC 2018:

function sTT(v) {return stringIDToTypeID(v)}

(ref = new ActionReference()).putProperty(sTT('property'), sTT('menuBarInfo'))

ref.putEnumerated(sTT('application'), sTT('ordinal'), sTT('tergetEnum'))

Object.prototype.get = function(v) {return this.getList(sTT('submenu')).getObjectValue(v)}

executeActionGet(ref).getObjectValue(sTT('menuBarInfo')).get(8).get(18).get(0).getString(sTT('enabled'))

c.pfaffenbichler
Braniac
July 18, 2018

#target photoshop

if (app.documents.length > 0) {

var ref = new ActionReference();

ref.putProperty (stringIDToTypeID ("property"), stringIDToTypeID ("guidesVisibility"));

ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

var docDesc = executeActionGet(ref);

alert (docDesc.getBoolean(stringIDToTypeID("guidesVisibility")));

};

frmorelAuthor
Inspiring
July 18, 2018

Thank you for your reply.

Unfortunately, line var docDesc = executeActionGet(ref); throws an error, telling this action isn't available.

Photoshop 13.0 (CS6) on Mac.

c.pfaffenbichler
Braniac
July 18, 2018

Quite frankly I am not going to install an obsolete Photoshop version to test this, but in 19.1.5 it works fine.

Does removing the line

ref.putProperty (stringIDToTypeID ("property"), stringIDToTypeID ("guidesVisibility"));

make a difference?

Could you post a screenshot of the Script in ESTK?