Hey. So I saw your question and I needed the same solution, so I wrote a script. So for anyone, who needs this:
string $mySel[] = `ls -sl`;
string $allGeo[] = `filterExpand -sm 12 $mySel[0]`;
if (size($allGeo) > 1){
string $newPoly[] = `polyUnite -ch 1 -mergeUVSets 2 -centerPivot -name $allGeo`;
select -r $newPoly[0];
select -add $mySel[0];
parent;
select -r $newPoly[0];
DeleteHistory;
}
float $uNums,$vNums;
int $UVNum = 20;
for($u = 0; $u < $UVNum; $u++){
for($v = 0; $v < $UVNum; $v++){
print($u + " " + $v + "\n");
$uNums = $u;
$vNums = $v;
float $uPoint = $uNums + 0.5;
float $vPoint = $vNums + 0.5;
polySelectConstraint -m 3 -t 0x0010 -d 1 -dp $uPoint $vPoint 0 -db 0 0.75;
string $preProcessSel[] = `ls -sl -fl`;
polySelectConstraint -m 0 -t 0x0010 -d 0 -dp 0 0 0 -db 0 0;
resetPolySelectConstraint;
if (size($preProcessSel) > 0){
float $minU = $uNums;
float $minV = $vNums;
float $maxU = $uNums + 1;
float $maxV = $vNums + 1;
string $finalSelection[];
int $counter=0;
for($thisFace in $preProcessSel){
float $tempUVs[] = `polyEditUV -q -u -v $thisFace`;
if(($tempUVs[0] < $maxU && $tempUVs[0] > $minU )&&($tempUVs[1] < $maxV && $tempUVs[1] > $minV )){
//print($minU + " " + $maxU + " " + $minV + " " + $maxV + " " + $tempUVs[0] + " " + $tempUVs[1] + "\n");
$finalSelection[$counter] = $thisFace;
$counter++;
}
}
if (size($finalSelection) > 0){
select -replace $finalSelection;
PolySelectConvert 1;
string $currentSelection[] = `ls -sl`;
string $newMtl=`shadingNode -as -n ("UDIM_10"+$v+($u+1)) blinn`;
string $newSG=`sets -renderable true -noSurfaceShader true -empty -name ( $newMtl + "SG" )`;
print($newMtl + "\n");
print($newSG + "\n");
print( $currentSelection);
connectAttr -f ( $newMtl + ".outColor" ) ( $newSG + ".surfaceShader" );
for ($thisSelection in $currentSelection){
select -r $thisSelection;
sets -e -forceElement $newSG;
}
}
clear $finalSelection;
}
}
}
The first part is merging the geo first. If you dont need that, than skip that step. Also the naming of the UDIM materials are only correct for 1001-1009 after that I couldnt be bothered to check for correct naming. You might need to fix that or do it manually, as I am right now.
Hope that helps you or anyone, who is searching for this.