When am I supposed to use BatchPlay vs. ExecuteAsModal?
These two works best together. When you execute as modal you reserve timeframe where only your code will control Photoshop. So nothing else can mess up with your steps by adding something else in between executions.
As Jarda mentioned, they complement each other and are completely different things. With BP you set or get something most of the time.
ExecuteAsModal on the other hand is more like a grouping of multiple BP actions (mostly setters). Also, if you are changing the state of Ps (probably always when you set something), you must run BP inside
ExecuteAsModal, otherwise you’ll get an error
Thanks @Jarda and @Karmalakas. Is it just me (and it could be), but is the photoshop api unnecessarily complicated? You take something like the web and dom and those apis are way simpler and the web is arguable more complicated.
DOM in PS is work in progress. Older UXP plugins did not have ExecuteAsModal therefore even user input could possibly break the process that plugin is trying to do. E.g. when user closes document manualy.