From d09558d37ac47fc852a22027208eb2ba9df4e235 Mon Sep 17 00:00:00 2001 From: Abdullah Alfaraj Date: Mon, 20 Feb 2023 23:50:55 +0300 Subject: [PATCH] check if the background layer exist before every generation --- index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/index.js b/index.js index f93ddbc..7c9fd68 100644 --- a/index.js +++ b/index.js @@ -2161,6 +2161,17 @@ async function hasSelectionChanged(new_selection, old_selection) { async function easyModeGenerate(mode) { try { + //1)check if documnet has background layer + if ( + (await layer_util.hasBackgroundLayer()) === false && //doesn't have backround layer + (await note.Notification.backgroundLayerIsMissing()) === false //and the user cancled the creation of background layer + ) { + // const is_canceld = + // await note.Notification.backgroundLayerIsMissing() // + + return false + } + let active_layer = await app.activeDocument.activeLayers[0] // store the active layer so we could reselected after the session end clean up //make sure you have selection area active on the canvas const isSelectionAreaValid = await psapi.checkIfSelectionAreaIsActive()