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
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"));
};
Copy link to clipboard
Copied
great thanks so much for all the helpful info!
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.