check if the background layer exist before every generation

notification
Abdullah Alfaraj 2023-02-20 23:50:55 +03:00
parent 058edea552
commit d09558d37a
1 changed files with 11 additions and 0 deletions

View File

@ -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()