Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
1

Get Altitude value from Photoshop Javascript

Community Beginner ,
Oct 20, 2023 Oct 20, 2023

Copy link to clipboard

Copied

I am currently working on a script that returns / get the Altitude value from Layer Style -> Global Light.

Elias31446099b2ip_0-1697819258502.png


I am able to get the Global Light Angle through this script:

var r = new ActionReference ();
r.putEnumerated (stringIDToTypeID ("layer"), stringIDToTypeID ("ordinal"), stringIDToTypeID ("targetEnum"));
alert(executeActionGet (r).getInteger(stringIDToTypeID("globalAngle"));


Here is a list of the properties I could find:

Elias31446099b2ip_1-1697819468138.png

 

If someone knows how I can get the Altitude it would help me out so much!

Thank you for taking your time to read this.

TOPICS
Actions and scripting

Views

198
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Oct 25, 2023 Oct 25, 2023

I think this is a bug that apparently hasn't been fixed yet. You can easily get this data from the "application" object. But for "document" and "layer" it is not so simple. For these objects, try to get the “json” object property, and read the “globalLight” object in it. Your desired values will be there.

Votes

Translate
Adobe
Community Beginner ,
Oct 25, 2023 Oct 25, 2023

Copy link to clipboard

Copied

Here is a snippet of the Action Listener that sets the Global Light Angle and Altitude. I still havn't figured out how to read the Altitude value. You can see that:

 

 

desc234.putUnitDouble( idgagl, idAng, 90.000000 ); // Sets the Angle
desc234.putUnitDouble( idglobalAltitude, idAng, 30.000000 ); / Sets the Altitude

 

 

The code below is the Action Listener that sets the Global Light:

 

 

// =======================================================
var idsetd = charIDToTypeID( "setd" );
    var desc233 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idPrpr = charIDToTypeID( "Prpr" );
        var idgblA = charIDToTypeID( "gblA" );
        ref2.putProperty( idPrpr, idgblA );
        var idDcmn = charIDToTypeID( "Dcmn" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref2.putEnumerated( idDcmn, idOrdn, idTrgt );
    desc233.putReference( idnull, ref2 );
    var idT = charIDToTypeID( "T   " );
        var desc234 = new ActionDescriptor();
        var idgagl = charIDToTypeID( "gagl" );
        var idAng = charIDToTypeID( "#Ang" );
        desc234.putUnitDouble( idgagl, idAng, 90.000000 );
        var idglobalAltitude = stringIDToTypeID( "globalAltitude" );
        var idAng = charIDToTypeID( "#Ang" );
        desc234.putUnitDouble( idglobalAltitude, idAng, 30.000000 );
    var idgblA = charIDToTypeID( "gblA" );
    desc233.putObject( idT, idgblA, desc234 );
executeAction( idsetd, desc233, DialogModes.NO );

 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Oct 25, 2023 Oct 25, 2023

Copy link to clipboard

Copied

I think this is a bug that apparently hasn't been fixed yet. You can easily get this data from the "application" object. But for "document" and "layer" it is not so simple. For these objects, try to get the “json” object property, and read the “globalLight” object in it. Your desired values will be there.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 27, 2023 Oct 27, 2023

Copy link to clipboard

Copied

LATEST

Thank you for writing this! I'll look closer into it! 🙂

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines