Skip to main content
Participant
March 30, 2025
Question

illegal argument - argument 2 - internal error

  • March 30, 2025
  • 2 replies
  • 215 views

I run a script to check smart object on my Photoshop. 

 

 
var doc = app.activeDocument;
 
function checkSmartObjectType(layer) {
    if (layer.kind == LayerKind.SMARTOBJECT) {
        try {
            var ref = new ActionReference();
            ref.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
            var desc = executeAction(charIDToTypeID("getd"), ref, DialogModes.NO);
            var smartObjDesc = desc.getObjectValue(stringIDToTypeID("smartObject"));
 
           
            if (!smartObjDesc.hasKey(stringIDToTypeID("link")) || smartObjDesc.getPath(stringIDToTypeID("link")) == null) {
                alert("Layer '" + layer.name + "' is Embedded Smart Object.");
                return;
            }
 
            if (smartObjDesc.hasKey(stringIDToTypeID("link"))) {
                var linkPath = smartObjDesc.getPath(stringIDToTypeID("link"));
                alert("Layer '" + layer.name + "' is Linked Smart Object.\nFile linked: " + linkPath);
                return;
            }
 
            alert("Layer '" + layer.name + "' is unusual.");
        } catch (e) {
            alert("Error '" + layer.name + "': " + e.message);
        }
    }
}
 
function processLayers(layers) {
    for (var i = 0; i < layers.length; i++) {
        var currentLayer = layers[i];
        checkSmartObjectType(currentLayer);
        
        if (currentLayer.typename == "LayerSet") {
            processLayers(currentLayer.layers);
        }
    }
}
 
if (doc.layers.length > 0) {
    processLayers(doc.layers);
} else {
    alert("No layer!");
}
I create Layer 1 and convert to smart object. Run script and i got error:
 

 

My photoshop version

 

I think it was a bug.

 

2 replies

Stephen Marsh
Community Expert
Community Expert
March 31, 2025

Please use the </> button to enter code, just in case it breaks as regular text.

 

You can compare working code here:

 

mglush
Community Expert
Community Expert
March 31, 2025

Hi @jean_0376 ,

 

Thank you for reporting this problem. What version of Windows OS are you using? Did this issue just start happening or have you installed an update recently?

Michelle