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

Photoshop Scripting- Smart objects - How can I get the changes made to a layer that is a smart object

Community Beginner ,
Jan 18, 2018 Jan 18, 2018

Copy link to clipboard

Copied

I'm making a script that deals with layers that point to the same smart object, I would like to know how I can get the changes made to a layers that point to the same smart object.

example:
I have a layer named Layer1 that is a smart object ( SmartObjectFile.psb)
I now apply some transformation, scale, rotation to layer1. ( I have not touched the contents of the smart object file).
I would like to know how much I moved, rotated,scaled the layer, in relation to the smart object, position,rotation & scale.

How could I be able to get that info, the changes from the layer result vs the actual embeded/linked file used in the smart object, Photoshop must keep that info somewhere.

Thanks!

Leo

TOPICS
Actions and scripting

Views

5.8K

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

Community Expert , Jan 18, 2018 Jan 18, 2018
Adobe
Community Expert ,
Jan 18, 2018 Jan 18, 2018

Copy link to clipboard

Copied

I would like to know how much I moved, rotated,scaled the layer, in relation to the smart object, position,rotation & scale.

How could I be able to get that info, the changes from the layer result vs the actual embeded/linked file used in the smart object, Photoshop must keep that info somewhere.

While the scale, angle, warp etc. indeed need to be stored (and can be evaluated by Script since a couple versions) a previous position is not relevant.

When you move a Layer or Smart Object instance the previous position is of no further importance and when it drops from the History it is »gone«.

Edit: Sorry, I may have been mistaken and the original position of a Smart Object instance might indeed be stored.

What are you really trying to achieve?

If the transformation is performed within a Script with user input the values could be cought directly, I guess.

This code might get you started for simple transformations of a Smart Object instance.

#target photoshop

if (app.documents.length > 0) {

var ref = new ActionReference();

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

var layerDesc = executeActionGet(ref);

var soDesc = layerDesc.getObjectValue(stringIDToTypeID('smartObject'));

var soMoreDesc = layerDesc.getObjectValue(stringIDToTypeID('smartObjectMore'));

var placedDesc = soDesc.getEnumerationValue(stringIDToTypeID('placed'));

var theFileRef = soDesc.getString(stringIDToTypeID('fileReference'));

var theDocID = soDesc.getString(stringIDToTypeID('documentID'));

var size = soMoreDesc.getObjectValue(stringIDToTypeID('size'));

var transform = soMoreDesc.getList(stringIDToTypeID("transform"));

var xx = new Array;

for (var m = 0; m < transform.count; m++) {

xx.push(transform.getDouble(m))

};

alert (xx.join("\n"));

};

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 ,
Jan 23, 2018 Jan 23, 2018

Copy link to clipboard

Copied

great thanks so much for all the helpful info!

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 ,
Jan 18, 2018 Jan 18, 2018

Copy link to clipboard

Copied

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 ,
Jan 23, 2018 Jan 23, 2018

Copy link to clipboard

Copied

Thanks so much for all the info, very helpful. - with this I'll be able to get the result I want.

Like you said I just need the rotate and scale values, I'm creating a texture for some 3D assets I'm creating off the photoshop file. All these examples are helping me find the info I need.
I'm basically exporting images from each layer. some of the images are smart objects that are referencing the same image, but they may have been rotated or scaled in some way. what I want is to export the original image inside the smart object and save the info of the rotation & scale offset of each of those layers.  I will then only use the original image as the source to create 3d assets, by adding the offsets I've obtained.

Thanks again for your help!

Leo

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 ,
Jan 23, 2018 Jan 23, 2018

Copy link to clipboard

Copied

LATEST

Sorry, I think I made a mistake and the edit to the first post may have gone unnoticed:

The original position of a Smart Object might be stored after all.

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