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

Is there any way to retrieve angle and scale information of smart object?

Community Beginner ,
Oct 21, 2017 Oct 21, 2017

Copy link to clipboard

Copied

I need to retrieve scale and rotation information changes of a smart object in a video animation using a script.

How can I do this?

TOPICS
Actions and scripting

Views

3.4K

Translate

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

Valorous Hero , Oct 21, 2017 Oct 21, 2017

on CC2018 it works, on CS6 do not.

function get_smart_object_corners() returns array from 4 corner-points (x,y) of smart object in pixels (value with floating point)

you can caclulate angle and vertical or horisontal dimentions.

))

Code example:

////////////////////////////////////////////////////////////////////////////////////////////

var points = get_smart_object_corners();

var w = points[0][0] - points[1][0];

var h = points[0][1] - points[1][1];

var angle = Math.atan(h/w) * 180.0 / Math.PI;

alert ("An

...

Votes

Translate

Translate
Community Expert ,
Oct 21, 2017 Oct 21, 2017

Copy link to clipboard

Copied

Hi

I've moved your post to the Photoshop Scripting forum where you are more likely to get an answer to your question

Dave

Votes

Translate

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 21, 2017 Oct 21, 2017

Copy link to clipboard

Copied

Thanks a lot Dave

Salitha

Votes

Translate

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
LEGEND ,
Oct 21, 2017 Oct 21, 2017

Copy link to clipboard

Copied

I do not believe it is possible the get the smart Object layer associated transform settings with a Photoshop Script.   You can see the values in Photoshop Tool Option Bar when you Place in an image or you target a smart object layer and use Ctrl+T free transform.  The tool option bar will display the smart object layers current transform settings.

JJMack

Votes

Translate

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
Valorous Hero ,
Oct 21, 2017 Oct 21, 2017

Copy link to clipboard

Copied

on CC2018 it works, on CS6 do not.

function get_smart_object_corners() returns array from 4 corner-points (x,y) of smart object in pixels (value with floating point)

you can caclulate angle and vertical or horisontal dimentions.

))

Code example:

////////////////////////////////////////////////////////////////////////////////////////////

var points = get_smart_object_corners();

var w = points[0][0] - points[1][0];

var h = points[0][1] - points[1][1];

var angle = Math.atan(h/w) * 180.0 / Math.PI;

alert ("Angle is " + angle.toFixed(3) + "°");

////////////////////////////////////////////////////////////////////////////////////////////

function get_smart_object_corners()

    {

    try

        {

        var r = new ActionReference();

        r.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );

        var d;

        try { d = executeActionGet(r); } catch (e) { alert(e); return; }

        try { d = d.getObjectValue(stringIDToTypeID("smartObjectMore"));    } catch (e) { alert(e); return; }

        try { d = d.getList(stringIDToTypeID("transform"));                 } catch (e) { alert(e); return; }

        var ret = [[d.getDouble(0),d.getDouble(1)],

                   [d.getDouble(2),d.getDouble(3)],

                   [d.getDouble(4),d.getDouble(5)],

                   [d.getDouble(6),d.getDouble(7)]];

        return ret;

        }

    catch (e) { alert(e); }

    }

Votes

Translate

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
LEGEND ,
Oct 21, 2017 Oct 21, 2017

Copy link to clipboard

Copied

In a video animation how do you tie that to the  timeline where the layer may be be being transformed with rotation,  and how do you get the scaling factors?

JJMack

Votes

Translate

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 22, 2017 Oct 22, 2017

Copy link to clipboard

Copied

Thanks, r-bin.

On CC2017 it works.

On CC2014 and CC2015 it doesn't.

I am looking for a solution Photoshop 2014CC onwards.

Salitha

Votes

Translate

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
Valorous Hero ,
Oct 23, 2017 Oct 23, 2017

Copy link to clipboard

Copied

You can add a rectangular linked vector mask with zero density to the original layer, not an objectively smart object, with dimensions as  the layer. Then, after any transformation or rotation, you can calculate the angles and dimensions using 4 points of the vector mask.
I'm not sure that it will be convenient for you.

ps. hope you understand my poor english )

Votes

Translate

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
LEGEND ,
Oct 23, 2017 Oct 23, 2017

Copy link to clipboard

Copied

The script fails in CC 2014 in followind statement for smartObjectMore does not seem to exist in CC 2014.

d = d.getObjectValue(stringIDToTypeID("smartObjectMore"));

JJMack

Votes

Translate

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
Enthusiast ,
Oct 23, 2017 Oct 23, 2017

Copy link to clipboard

Copied

smartObjectMore was added in 2015.5

Votes

Translate

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
New Here ,
Feb 10, 2023 Feb 10, 2023

Copy link to clipboard

Copied

Hello, thanks for answer. I just want to know how can we use this inside a loop, iterating through all the layers instead of just Trgt. 

Votes

Translate

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
New Here ,
Feb 10, 2023 Feb 10, 2023

Copy link to clipboard

Copied

I have been looking for a solution to get the rotation of all the layers. This code actually worked but it targets the active layer only. I want to iterate through all the layers and get their rotation angle.  

Votes

Translate

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
New Here ,
Feb 17, 2023 Feb 17, 2023

Copy link to clipboard

Copied

angle  is got but how can get scale? IM_p_2023-02-18-14-37-04.png any one know?thanks

Votes

Translate

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
New Here ,
Feb 20, 2023 Feb 20, 2023

Copy link to clipboard

Copied

perfect solution!

 

var smartLayerBounds = getSmartObjectBounds(_layer);//get bound

openSmartObject(_layer);

var smartTargetLayerSourceBounds = getOpenSmartSourceBounds(_layer)

var scale = getScale(smartLayerBounds, smartTargetLayerSourceBounds);

 

https://github.com/tenvick/hugula/blob/master/Client/Assets/Third/PSD2UGUI/JSCode/Export%20PSD%20Xml...

Votes

Translate

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 Expert ,
Feb 21, 2023 Feb 21, 2023

Copy link to clipboard

Copied

LATEST

What if the Smart Object has been rotated? 

Votes

Translate

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
Enthusiast ,
Oct 22, 2017 Oct 22, 2017

Copy link to clipboard

Copied

Hi.. check my script "Undeform" Magic scripts for Photoshop

I solved reading most of deformations. Btw rotation and skew are similar. You can rotate object if you apply 2x skew. If you find the way how to solve perspective, please let me know.

Votes

Translate

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