Get layer ID from doing mergeVisible batchPlay command?

I would like to get the ID of the new layer generated by sending a “mergeVisible” command to batchPlay. I was hoping that would be in the promise object returned from batchPlay, but I can’t figure out how to do anything with that promise object.

const mergeVisible = async (newLayername) => {
  return executeAsModal( async () => {
    command = [
      {
        _obj: "mergeVisible",
        duplicate: true,
        _options: {
            dialogOptions: "dontDisplay"
        }
      }
    ]
    const result = await batchPlay(command,{})
    console.log("mergeVisible result: ",result)
  }, { commandName: "mergeVisible" })
    .then(res => console.log("mergeVisible success"))
    .catch(err => {
      throw new Error("Error mergeVisible: ", err)
    });
}

Fortunately, it seems that the mergeVisible BatchPlay command auto-selects the newly merged layer, so no need to get the ID or the name of it so that I can select it.

1 Like

Let’s hope they will never change it ever. :smiley: Alternative would be collect all layer IDs before and after and compare it what is new.

2 Likes