Skip to main content
AlexPrint
Inspiring
June 14, 2023
Question

Simple Script to Move an Smart Object

  • June 14, 2023
  • 1 reply
  • 279 views

I tried some code to move an smart object as with other kind of layer but it was unsuccessful,

for some reason it does not work with layers when they are smart objects,

also tried to find something to at least align to the bottom left using

ActionDescriptor and ActionReference objects too but no results,

 

Does anyone knows a code to move the active layer (which it is an smart object) to specific

X,Y, coordinates ?

I hope some one can help me. Blessings.

This topic has been closed for replies.

1 reply

AlexPrint
AlexPrintAuthor
Inspiring
June 14, 2023

Hello Guys, I resolved by Myself, Give this code a try when the layer ( smart object ) you want to move

is the Photoshop Active Layer, it will do the job:

 

offsetX = 200 - app.activeDocument.activeLayer.bounds[0].as("px");
offsetY = 500 - app.activeDocument.activeLayer.bounds[1].as("px");
app.activeDocument.activeLayer.translate(offsetX, offsetY);

 

200 and 500 are the coordinates set in pixels in my case.