i attached a quick Blenders geometry node example that packs all same mat ID UV islands in sort of automated style as rows. it uses material id index to shift UV in U direction each in 1 . So each UV islands having mat ID 1 shifts to 1 , islands with matID2 shifts to 2 etc. They all scales back to 0-1 in the end . I have 4…
you can use python in max - chatgpt might do better with that personally I'd recommend working out how to write the code yourself - at least you'll be able to see where the robot makes mistakes