PDA

View Full Version : Substitute Geometry Script


xcomb
11-17-2006, 01:49 PM
Hi all!
I have tones of characters that needs to replace their geometries with new one created.
So i use new function substituteGeometry.
I wrote the script which pretty much supposed to deal with lots of geometries, so i don't have to go and select each element and use the substitute geometry.
So i have the problem with loops and don't know what else to append to fix this issue.
When i execute this script, it only works on some parts of the model, not whole parts as i wanned.
Please if you can explain me or help me, i would greatly appritiate!
Here is the script:

if(`window -exists mainWindow`)
deleteUI mainWindow;
window -title "Substitute Geometry" -w 300 -h 400 mainWindow;
string $base[] = `ls -sl`;
string $target[] = `ls -sl`;
columnLayout -adj 1 mainCol;

rowColumnLayout -numberOfRows 2
-rowHeight 1 150
-rowHeight 2 150;
setParent..;
textScrollList -h 300 -w 300 -ams true mainTSL;
button -label "Select Base" -c "baseObj()" baseBtn;
setParent..;
textScrollList -h 300 -w 300 -ams true mainTSL2;
button -label "Select Target" -c "targetObj()" targetBtn;
button -label "Proccess Geometry Substitution!" -c "substituteGeo()";

showWindow mainWindow;

global proc baseObj(){
textScrollList -e -ra mainTSL;
string $listBase[] = `ls -sl`;
string $sortBase[] = `sort($listBase)`;
for($eachBase in $sortBase){
textScrollList -e -append $eachBase mainTSL;
}
}
global proc targetObj(){
textScrollList -e -ra mainTSL2;
string $listTarget[] = `ls -sl`;
string $sortTarget[] = `sort($listTarget)`;
for($eachTarget in $sortTarget){
textScrollList -e -append $eachTarget mainTSL2;
}
}

global proc substituteGeo()
{
string $first[] = `textScrollList -q -si mainTSL`;
string $second[] = `textScrollList -q -si mainTSL2`;
int $sizeBase = size($first);
int $sizeTarget = size($second);
for($eachBase in $first){
//select -r ($eachBase);
for ($eachTarget in $second){
//select -r ($eachTarget);
substituteGeometry $eachBase $eachTarget;
//select -cl;
}
}
}

xcomb
11-17-2006, 02:46 PM
Ok i got it working, except one thing that doesn't work, when i loop through all elements, my hand doesn't get substitutes, except it disappears on both characters!

xcomb
11-17-2006, 03:20 PM
Well i got it all fixed finaly, need to think deeper then i even thought :)
Here is the script if someone needs it to use.


if(`window -exists mainWindow`)
deleteUI mainWindow;
window -title "Substitute Geometry" -w 300 -h 400 mainWindow;
string $base[] = `ls -sl`;
string $target[] = `ls -sl`;
columnLayout -adj 1 mainCol;

rowColumnLayout -numberOfRows 2
-rowHeight 1 150
-rowHeight 2 150;
setParent..;
textScrollList -h 300 -w 300 -ams true mainTSL;
button -label "Select Base" -c "baseObj()" baseBtn;
setParent..;
textScrollList -h 300 -w 300 -ams true mainTSL2;
button -label "Select Target" -c "targetObj()" targetBtn;
button -label "Proccess Geometry Substitution!" -c "substituteGeo()";

showWindow mainWindow;

global proc baseObj(){
textScrollList -e -ra mainTSL;
string $listBase[] = `ls -sl`;
string $sortBase[] = `sort($listBase)`;
for($eachBase in $sortBase){
textScrollList -e -append $eachBase mainTSL;
}
}
global proc targetObj(){
textScrollList -e -ra mainTSL2;
string $listTarget[] = `ls -sl`;
string $sortTarget[] = `sort($listTarget)`;
for($eachTarget in $sortTarget){
textScrollList -e -append $eachTarget mainTSL2;
}
}

global proc substituteGeo()
{
string $first[] = `textScrollList -q -si mainTSL`;
string $second[] = `textScrollList -q -si mainTSL2`;
int $size = size($first);

for($i = 0; $i < 9; $i++){
select -r ($first[$i]);
select -r ($second[$i]);
substituteGeometry $first[$i] $second[$i];
select -cl;
}

}

CGTalk Moderation
11-17-2006, 03:20 PM
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.