View Full Version : code - subd UV layout for Danny UV tools

05 May 2003, 04:57 AM

I posted here some time ago about laying out UVs for Subd. I took it upon myself to edit the fablous Danny UV tools to work with subd surfaces in maya. I was hoping that someone could suggest changes because this is my first time coding in mel. It works with planar proj or automapping (uncomment that automapping line, aruond // 77)

Couple of questions though:

why is there an error at line 1 when I use automapping?

**And most importantly, how would I layout UVs? Can someone help me out here? I notice some weird things happening when I layout UVs after running this script.

Danny UV tools are at:

The code below should be used instead of "uvLayout.mel".




By: Danny Ngan
edited by ktpr to work with subd


This script automatically lays out the UVs of one or more sudb meshes
according to material assignments.

Note: This script is designed to work only with subd objects.
Results could be unexpected with other object types.


Define UV shells on the mesh(es) by assigning unique materials to each group of faces.
Switch to object selection mode (if needed) and select the subd mesh(es). Make sure
no components are selected.
Run the following command from Maya's command line or the script editor:


Edit the UVs in the UV Texture Editor.



global proc uvtest(){

string $objList[] = `ls -sl`; // Get list of selected objects.
int $objListSize = size($objList); // Get number of selected objects.

int $o; // Initialize object increment variable.

string $foobar[];

// Make sure something is selected.
if (`isTrue SomethingSelected`){

// Unwrap UVs for selected objects.
for ($o = 0; $o < $objListSize; $o++){

eval("select -r " + $objList[$o]);

// Get list of shading groups on object.
$sgList = `listSets -type 1 -ets -o $objList[$o]`;

// Get list of all materials connected to shading groups.
string $materialList[];

for ($s = 0; $s < size($sgList); $s++){

$materialList[$s] = `connectionInfo -sfd ($sgList[$s] + ".surfaceShader")`;

// Map the faces.
// is there an off by one error? changed 0 to 1

for ($f = 1; $f < size($materialList); $f++){

// line 77
// change to foobar when proj proves that it works.
//hyperShade -o $materialList[$f];

// should I just use the users settings?
//eval("subdAutoProjection -p 12 -o 0 -sc 1 -l 0 -ch 0 " + `hyperShade -o $materialList[$f]`);

eval("subdPlanarProjection -ch 0 -ibd on -icx 0.5 -icy 0.5 -ra 0 -isu 1 -isv 1 -md b " + `hyperShade -o $materialList[$f]`);

// 87
// How the hell do I layout the faces after I'm done????

// 90
} // end map faces for loop

// Clear selection and switch to object selection mode.
select -cl;
selectMode -object;

// Clear the selection and all arrays for next loop iteration.
select -cl;
clear $materialList;
clear $sgList;

// Debug
print ("UV layout for " + $objList[$o] + " completed.\n");

} // end main UV layout for loop

// Clear selection and re-select object(s).
select -cl;
for ($i = 0; $i < $objListSize; $i++){

eval("select -add " + $objList[$i]);

print ("UV layout completed.\n");
// If nothing is selected, display an error.
error ("Please select at least one subd object.\n");

// }// end of if

}// end of procedure

// end of script

05 May 2003, 06:22 AM
While the script worked on my test subd sphere, when I applied it to the human body it seemed to almost freeze. I let it go after about 10 minutes. Perhaps in the future I'll write a script from scratch that works in conjunction with Assignmaterial.mel. The premise is really simple, apply subdivautomap/planar to each hyperShade -o $materialList[$f]. Maybe someone else can take this up? :shrug:


CGTalk Moderation
01 January 2006, 05:03 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.