Skip to main content
Participant
August 18, 2023
Question

How can I make a script that uses the Auto Align Layers

  • August 18, 2023
  • 3 replies
  • 899 views

I keep trying but it just comes up with Error 8800: General Photoshop error occured. This functionality may not be available in this version of Photoshop. - The command "<unknown>" is not currently available.

This is always happening with this code on the executeAction line.

 

// Run Auto-Align Layers on all layers in the new document using Perspective projection
         var idautoAlignLayers = stringIDToTypeID("autoAlignLayers");
         var desc2 = new ActionDescriptor();
         var idprojection = stringIDToTypeID("projection");
         desc2.putInteger(idprojection, 3); // Perspective projection
         executeAction(idautoAlignLayers, desc2, DialogModes.NO);

 

 I think it must be a bug because there's no other reason. I have it all set up properly, with two layers selected.

 

This topic has been closed for replies.

3 replies

Stephen Marsh
Community Expert
Community Expert
August 18, 2023
Participant
March 23, 2024

Hi! 
I am following and hoping for help.

@Stephen Marsh the link did not help in my case. I was just trying to automate the aligning and blending of layers. As I was not able to realise it in a simple Javascript I started to use UXP to write it. Sadly I get the same error like the thread starter, 8800 general Photoshop error.
Anyone able to help?

document.addEventListener("DOMContentLoaded", () => {
    const alignButton = document.getElementById("alignLayersBtn");
    const populateButton = document.getElementById("populateLayersBtn");
    
    if (alignButton) {
        alignButton.addEventListener("click", alignLayersAutomatically);
    }
    if (populateButton) {
        populateButton.addEventListener("click", populateLayers);
    }
});

async function alignLayersAutomatically() {
    require('photoshop').core.executeAsModal(async () => {
        try {
            console.log("Starte automatische Ausrichtung der Ebenen");
            const result = await require('photoshop').action.batchPlay([
                {
                    "_obj": "autoAlignLayers",
                    "_target": [{ "_ref": "layer", "_enum": "ordinal", "_value": "targetEnum" }],
                    "autoAlignType": { "_enum": "autoAlignType", "_value": "auto" }
                }
            ], {});
            console.log("Ebenen ausgerichtet: ", result);
            await showAlert("Ebenen wurden erfolgreich ausgerichtet!");
        } catch (error) {
            console.error("Fehler beim Ausrichten der Ebenen: ", error);
            await showAlert("Fehler beim Ausrichten der Ebenen. Siehe Konsole für Details.");
        }
    }, {commandName: "alignLayersAutomatically"});
}

async function populateLayers() {
    try {
        const app = require("photoshop").app;
        const layers = app.activeDocument.layers;
        const layerNames = layers.map(layer => layer.name);
        const layerListElement = document.getElementById("layerList");
        layerListElement.innerHTML = "<ul>" + layerNames.map(name => `<li>${name}</li>`).join("") + "</ul>";
    } catch (error) {
        console.error("Fehler beim Auflisten der Ebenen: ", error);
        await showAlert("Fehler beim Auflisten der Ebenen. Siehe Konsole für Details.");
    }
}

async function showAlert(message) {
    await require('photoshop').core.showAlert({message});
}

 Let me know if I can provide further info.

To my defense: I am not able to code properly (but willing to listen and learn), this is me plus chatGPT.
Thanks a lot!

c.pfaffenbichler
Community Expert
Community Expert
August 18, 2023

What code do you get when you record the operation with ScriptingListener.plugin? 

Bojan Živković11378569
Community Expert
Community Expert
August 18, 2023

I will tag a few scripters that can help you. Next time add scripting tag to your question.

@c.pfaffenbichler @Stephen Marsh @jazz-y @r-bin