Skip to main content
Inspiring
Jul 18, 2018 12:02 PM UTC
Question

Test if guides visible?

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 is closed to new replies. Start a new post to keep the conversation going.

13 replies

Legend
Jul 18, 2018 4:16 PM UTC

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); }

    }

Translate
frmorelAuthor
Inspiring
Jul 19, 2018 6:42 AM UTC

, your function show_guides() works fine.

Translate
Kukurykus
Legend
Jul 18, 2018 1:23 PM UTC

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'))

Translate
c.pfaffenbichler
Community Expert
Community Expert
Jul 18, 2018 1:04 PM UTC

#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")));

};

Translate
frmorelAuthor
Inspiring
Jul 18, 2018 1:14 PM UTC

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.

Translate
c.pfaffenbichler
Community Expert
Community Expert
Jul 18, 2018 1:23 PM UTC

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?

Translate