How to automatically generate a layer with automap rules?

Is there a script that creates a layer with output_* based on the automapping rules from Tiled?
(unfortunately as a novice I can’t attach files for example)
I automatically create a map image *.png
and Tiles map - *.json
with links to the base tiles from the file *.png
and there is a map with rules /Rules/ *.json
and tails for which /Rules/ *.png
in accordance with the rules, replacements must be made.

At the moment, after each map generation, you have to go into Tiled each time and press Ctrl + M to update the layer ids tails.

I do not understand what you’re asking, your post is worded confusingly. Are you looking to create rules based on some template? To automatically apply rules you have already created? Something else? How do you “generate” maps?

If you’re generating maps via Tiled script, you could add tiled.trigger("AutoMap") to your script to apply all your existing Automapping rules (this will only work if the Tiled GUI is open though, it won’t work if you’re doing this via CLI).
If you’re drawing maps manually, you can potentially use Automap While Drawing.

I apologize for the vague question, I’ll try to explain the problem I’m trying to solve again. Perhaps you will have ideas on how it would be better.

I use simplex noise for procedural map generation
gen_output_map
and create a json file that is read in Tiled and contains layers with the id of each tile and a tileset in the form of all the colors of the map
gen_tileset
As you can see, the attached map is just a set of colors - so I’m looking for a way to quickly use the automap rules in accordance with the rules.
(as I said above, now the visual part is created only through Tiled by pressing ctrl-M)
At the same time, I don’t want to give up the Tiled format due to its support by my game engine (Python Arcade) and the convenience of the GUI in some moments

Thanks for the context, but I still don’t understand exactly what you’re trying to do. Are you looking to apply Automapping automatically to these flat tiles (do you already have the Automapping rules made, or do you need to create those)? Are you looking to replace the external generator with one inside Tiled which will also do Automapping? Are you even talking about Tiled Automapping or something else?

If you want to apply Automapping automatically: You can do this with a Tiled script when the map opens. The easiest way to do this is to add a custom property such as “autoMapMe” to the Tiled map your generator creates, and in Tiled, have a script something like this:

tiled.assetOpened.connect( function(asset) {
   if(!asset.isTileMap) return;
   if(asset.property("autoMapMe") == true) {
      asset.autoMap("path/to/rules");
      asset.removeProperty("autoMapMe");
   }
});

This script checks if any map newly opened in Tiled has the “autoMapMe” property, and if it does, it applies automapping to it, and then removes that property. This script requires a path to the rules, but if you want to use the rules.txt at the map’s location, you can replace asset.autoMap() with

tiled.activeAsset = asset;
tiled.trigger("autoMap");

The assignment to activeAsset makes sure the Automapping is applied to that asset and not to some other document, just in case the recently opened map isn’t the active tab.