Hi,
Is this a good way to check if there is a document opened?
const docexists = () => {
return Boolean(app.activeDocument)
}
const exists = docexists()
// console.log(exists) // true | false
Thanks!
Hi,
Is this a good way to check if there is a document opened?
const docexists = () => {
return Boolean(app.activeDocument)
}
const exists = docexists()
// console.log(exists) // true | false
Thanks!
Maybe better Boolean(app.documents?.length)
I’m not sure if you can have open documents and none of them active, but better to be safe and check all (including non-active) docs
Very good point, thank you!
As far I know that is impossible. Or at least I never experience that or heard of it in last 5 years
Syntax tip: !!app.documents?.length
works the same
Thanks Jarda,
It did work but I guess that it’s not reliable solution. I’ve followed Karmalakas suggestion but your syntax tip is also great.
I’m using !!
way all over my plugin, but occasionally keep forgetting about it