Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I'm looking to scale one UV shell to mach another identical UV shell that is smaller or bigger by an arbitrary amount. I thought I could do this by comparing the bounding boxes and scaling by the difference, but I can't get it working. I can't seem to get shell 1 to scale exactly to shell 2. Here's my code, I'm not sure why it won't work, it's close to matching, but pretty far off.
//Store two selected UV shells
string $shellUVs[] = `ls -sl -fl`;
string $findShells[] = `texGetShells`;
int $numbShells = `size $findShells`;
global string $m341_udimPacker_largestShell[];
$m341_udimPacker_largestShell = {};
float $compareShell = 0;
int $shellIndex = 0;
//Select the first UV shell
select $findShells[0];
string $uvShell1[] = `ls -sl -fl`;
float $uvBBox1[] = `polyEvaluate -boundingBoxComponent2d -accurateEvaluation $uvShell1`;
float $sizeU1 = $uvBBox1[3] - $uvBBox1[0];
float $sizeV1 = $uvBBox1[4] - $uvBBox1[1];
//Select the second UV shell
select $findShells[1];
string $uvShell2[] = `ls -sl -fl`;
float $uvBBox2[] = `polyEvaluate -boundingBoxComponent2d -accurateEvaluation $uvShell2`;
float $sizeU2 = $uvBBox2[3] - $uvBBox2[0];
float $sizeV2 = $uvBBox2[4] - $uvBBox2[1];
// Calculate the scaling factors
float $scaleU = $sizeU2 / $sizeU1;
float $scaleV = $sizeV2 / $sizeV1;
// Apply scaling to the first UV shell
select $uvShell1;
polyEditUV -su $scaleU -sv $scaleU;
Solved! Go to Solution.