Skip to main content
AlexPrint
Inspiring
June 8, 2023
Answered

Change Smart Object Size

  • June 8, 2023
  • 1 reply
  • 317 views

Hello guys, I am trying to make an script where I can change the size of the current layer

but it is an smart object, is that possible?

This topic has been closed for replies.
Correct answer AlexPrint

I've resolved my problem with the next code:

 

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.

1 reply

c.pfaffenbichler
Community Expert
Community Expert
June 8, 2023

One can transform (scale, rotate, …) a Smart Object via Script so what is giving you problems? 

AlexPrint
AlexPrintAuthorCorrect answer
Inspiring
June 9, 2023

I've resolved my problem with the next code:

 

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.