# Match multiple layers with Automapping

**URL:** <https://discourse.mapeditor.org/t/match-multiple-layers-with-automapping/7203>\
**Category:** Questions\
**Created:** [January 9, 2025, 3:47pm UTC](https://discourse.mapeditor.org/t/match-multiple-layers-with-automapping/7203 "2025-01-09T15:47:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![marsarkane](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/marsarkane/32/4867_2.png) [@marsarkane](https://discourse.mapeditor.org/u/marsarkane)\
**Post date:** [January 9, 2025, 3:47pm UTC](https://discourse.mapeditor.org/t/match-multiple-layers-with-automapping/7203/1 "2025-01-09T15:47:41Z")

</div>

Hi. I have a question regarding automapping across multiple layers.

I got several tilesets with automapping set up for each, to achieve autotiling paths that I wouldn’t be able to use the terrain feature for. I can pick one key tile from each tileset and simply paint paths, which works great as long as I stick to the one named layer I set the automapping up for. But if I define it for `Layer01`, and I switch to `Layer02`, the automapping obviously doesn’t apply there.

My question now is whether it’s possible to match an input layer to a series of layers, as if using a wildcard. For example: `input_Layer*`. I realize it probably wouldn’t be that simple, because there’d be questions about differently named output layers and stuff, but perhaps there is a solution other than copying the rules for layers 1 through X that I missed 😅

I’m guessing that generally giving the layers the same name might work, but I am currently using a differently named output layer (eg `Layer01Auto`) because I’m using a key tile as the “brush”, and I haven’t found a way to match each tile from only one specific tileset inside the automapping rule map. Hope this makes sense.

TLDR: Ideally I’d like to use multiple tilesets and automapping rule maps, each with the layers `input_Layer*` and `output_Layer*Auto`, and for that to just work with any number of `Layer...`s on my various maps. Is there anything that would allow this? 😅

---

<div class="post-metadata">

**Author:** ![eishiya](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/eishiya/32/2534_2.png) [@eishiya](https://discourse.mapeditor.org/u/eishiya)\
**Post date:** [January 9, 2025, 3:54pm UTC](https://discourse.mapeditor.org/t/match-multiple-layers-with-automapping/7203/2 "2025-01-09T15:54:04Z")

</div>

No, this is not possible. You’d need to make a copies of your rules with input\_Layer02, and so on. A quick way to do this would be to File \> Save As your rules as another map, and then use a script like my [Replace In Layer Name script](https://github.com/eishiya/tiled-scripts/blob/main/ReplaceInLayerName.js) to quickly rename the input/output layers to the new targets. Don’t forget to add the new map(s) to your rules.txt.

Naming multiple layers the same thing would **not** work, Tiled will look at only the first matching layer it finds.

Edit: You could write a script that renames your layers and applies Automapping repeatedly to make sure it gets all the layers, but that would not work with Automap While Drawing. I think multiple sets of rules would be better, though it would make maintaining the rules more difficult.

---

<div class="post-metadata">

**Author:** ![marsarkane](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/marsarkane/32/4867_2.png) [@marsarkane](https://discourse.mapeditor.org/u/marsarkane)\
**Post date:** [January 9, 2025, 4:01pm UTC](https://discourse.mapeditor.org/t/match-multiple-layers-with-automapping/7203/3 "2025-01-09T16:01:17Z")

</div>

Alright, I guess I’ll just copy the layers then and create a couple in advance, like layers 1 through X. Since the rules are the same for each of my tilesets, I can just create one rule map, copy it, and switch out the image for each one.

But perhaps this is something that could be added in the future 🙂 Thanks for the quick response!

---

<div class="post-metadata">

**Author:** ![eishiya](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/eishiya/32/2534_2.png) [@eishiya](https://discourse.mapeditor.org/u/eishiya)\
**Post date:** [January 9, 2025, 4:04pm UTC](https://discourse.mapeditor.org/t/match-multiple-layers-with-automapping/7203/4 "2025-01-09T16:04:57Z")

</div>

There is an issue for pattern-matching that should be less ambiguous than some of the other multi-layer-matching feature requests, perhaps we might see that eventually: [Allow pattern matching on automap input and output. · Issue #4097 · mapeditor/tiled · GitHub](https://github.com/mapeditor/tiled/issues/4097)

---

<div class="post-metadata">

**Author:** ![marsarkane](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/marsarkane/32/4867_2.png) [@marsarkane](https://discourse.mapeditor.org/u/marsarkane)\
**Post date:** [January 21, 2025, 10:24pm UTC](https://discourse.mapeditor.org/t/match-multiple-layers-with-automapping/7203/5 "2025-01-21T22:24:26Z")

</div>

Hi again. I have a follow up question. I just tried duplicating the input and output layers in one rule map to handle automapping on multiple layers, assuming Tiled would go through all uniquely named layers and handle them. But after looking at this, I realize the system probably wouldn’t know which output layer to use.

```plaintext
output_Layer02A
input_Layer02
output_Layer01A
input_Layer01

```

I then tried to use only one output layer, with multiple input layers, but that didn’t seem to work either. My question then is, do I have to create a dedicated rule map for every layer I might want to automap on?

```plaintext
tileset_01_layer01.tmx
- output_Layer01A
- input_Layer01

tileset_01_layer02.tmx
- output_Layer02A
- input_Layer02

...

```

---

<div class="post-metadata">

**Author:** ![eishiya](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/eishiya/32/2534_2.png) [@eishiya](https://discourse.mapeditor.org/u/eishiya)\
**Post date:** [January 21, 2025, 10:28pm UTC](https://discourse.mapeditor.org/t/match-multiple-layers-with-automapping/7203/6 "2025-01-21T22:28:21Z")

</div>

The easiest way to duplicate rules is to **copy the entire map** , as I said. If you want them in the same map, you need to make sure you move the contents of the layers (with cut+paste, not with Offset Layers) so that they’re separate rules and not additional conditions and outputs for the old rules.

---

<div class="post-metadata">

**Author:** ![marsarkane](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/marsarkane/32/4867_2.png) [@marsarkane](https://discourse.mapeditor.org/u/marsarkane)\
**Post date:** [January 21, 2025, 10:33pm UTC](https://discourse.mapeditor.org/t/match-multiple-layers-with-automapping/7203/7 "2025-01-21T22:33:10Z")

</div>

Ah, sorry. It didn’t quite register with me that you meant copying the entire map. Alright, thanks 😅 I hope someone will look into implementing pattern matching 🙂
