Skip to main content
Participant
August 9, 2023
Beantwortet

Reset transformation of every smart object in a PSD file

  • August 9, 2023
  • 2 Antworten
  • 727 Ansichten

Is there a simple way to reset the transformation for every single smart object in a PSD? I know how to do it for a single layer/object but selecting multiple at a time seems to grey out that option for me.

Dieses Thema wurde für Antworten geschlossen.
Beste Antwort von Stephen Marsh

@Aaron22017780e7jg 

 

The following script will reset smart object transformations on all smart objects as top-level layers or inside groups and nested groups. It doesn't edit the smart object for nested smart objects within smart objects, only the top-level smart object is reset.

 

/*
Reset All Smart Object Layer Transformations.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/reset-transformation-of-every-mart-object-in-a-psd-file/td-p/13997343
Stephen Marsh, 10th August 2023 - v1.0
*/

#target photoshop

var myDocument = activeDocument;
myDocument.suspendHistory("processAllSmartObjects", "processSOLayers(myDocument)");

// processSOLayers function courtesy of c.pfaffenbichler
function processSOLayers(theParent) {
    // Loop over all the layers
    for (var i = theParent.layers.length - 1; i >= 0; i--) {
        var theLayer = theParent.layers[i];
        // Apply the function to smart object layers
        if (theLayer.typename === "ArtLayer") {
            if (theLayer.kind === LayerKind.SMARTOBJECT) {
                var theVisibility = theLayer.visible;
                myDocument.activeLayer = theLayer;

                // Run the function to reset transformations
                resetTransforms();
                
                // Reset visibility; 
                theLayer.visible = theVisibility;
            }
            // Run the function on the smart object layers inside layerSets (implied, not explicitly defined)
        } else {
            processSOLayers(theLayer);
        }
    }
    return;

    function resetTransforms() {
        var idplacedLayerResetTransforms = stringIDToTypeID("placedLayerResetTransforms");
        executeAction(idplacedLayerResetTransforms, undefined, DialogModes.NO);
    }
}

 

  1. Copy the code text to the clipboard
  2. Open a new blank file in a plain-text editor (not in a word processor)
  3. Paste the code in
  4. Save as a plain text format file – .txt
  5. Rename the saved file extension from .txt to .jsx
  6. Install or browse to the .jsx file to run:

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html#Photoshop

2 Antworten

Stephen Marsh
Community Expert
Community Expert
August 9, 2023

@Aaron22017780e7jg 

 

The following script will reset smart object transformations on all smart objects as top-level layers or inside groups and nested groups. It doesn't edit the smart object for nested smart objects within smart objects, only the top-level smart object is reset.

 

/*
Reset All Smart Object Layer Transformations.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/reset-transformation-of-every-mart-object-in-a-psd-file/td-p/13997343
Stephen Marsh, 10th August 2023 - v1.0
*/

#target photoshop

var myDocument = activeDocument;
myDocument.suspendHistory("processAllSmartObjects", "processSOLayers(myDocument)");

// processSOLayers function courtesy of c.pfaffenbichler
function processSOLayers(theParent) {
    // Loop over all the layers
    for (var i = theParent.layers.length - 1; i >= 0; i--) {
        var theLayer = theParent.layers[i];
        // Apply the function to smart object layers
        if (theLayer.typename === "ArtLayer") {
            if (theLayer.kind === LayerKind.SMARTOBJECT) {
                var theVisibility = theLayer.visible;
                myDocument.activeLayer = theLayer;

                // Run the function to reset transformations
                resetTransforms();
                
                // Reset visibility; 
                theLayer.visible = theVisibility;
            }
            // Run the function on the smart object layers inside layerSets (implied, not explicitly defined)
        } else {
            processSOLayers(theLayer);
        }
    }
    return;

    function resetTransforms() {
        var idplacedLayerResetTransforms = stringIDToTypeID("placedLayerResetTransforms");
        executeAction(idplacedLayerResetTransforms, undefined, DialogModes.NO);
    }
}

 

  1. Copy the code text to the clipboard
  2. Open a new blank file in a plain-text editor (not in a word processor)
  3. Paste the code in
  4. Save as a plain text format file – .txt
  5. Rename the saved file extension from .txt to .jsx
  6. Install or browse to the .jsx file to run:

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html#Photoshop

Participant
August 10, 2023

Hi Stephen. Your script works perfectly, exactly what I needed thanks! My smart objects were scattered accross several layer groups, but it looks like they all got resized. Thanks a lot!

Stephen Marsh
Community Expert
Community Expert
August 10, 2023

You’re welcome @Aaron22017780e7jg 

Stephen Marsh
Community Expert
Community Expert
August 9, 2023

A script can do this, looping over all layers and only processing smart object layers.

 

Do you only have a single top-level smart object? Do you have smart object layers inside layer group folders? Do you have groups nested inside other groups?

 

Or do you have a smart object that may contain a nested smart object etc.

 

Can you post a screenshot of your layers panel?