PDA

View Full Version : [HELP] symbolButton


cyrus3v
09-28-2010, 04:47 PM
Hi everyone.

Hi need a little help on a script that I made. In resume I need something that read the amount of poses of certain character and then create a window with buttons, each on relative to a pose.

This check the amount of poses.

global proc string[] currentCharacterPoses()
{
string $allPoses[];
string $characters[] = `currentCharacters`;
int $n=0;
int $nchars = size($characters);

if ($nchars == 0) return allCharacterPoses();

for ($i=0; $i < $nchars; $i++)
{
string $poses[] = `pose -q -n $characters[$i]`;
for ($j=0; $j < size($poses); $j++)
$allPoses[$n++] = $poses[$j];
}
return $allPoses;
}


And based on that information.


string $posesDo[] = `currentCharacterPoses`;
int $i;
for ($i=1; $i< size($posesDo);$i++)
{
symbolButton -i ($filePath + "Corpo_P" + $i + ".BMP") -w 75 -h 75 -ann "$i" -c "doPose";
}


But now I have a problem. Every button that I create will have as command "doPose" and I don't want that. Or I need a way to identify every button so later I can use that information to search and applied the correspondent pose.

Can anyone help me with this, please? :blush:

jaydru
09-28-2010, 05:22 PM
can you not store the pose as an argument for the command?

string $posesDo[] = `currentCharacterPoses`;
int $i;
for ($i=1; $i< size($posesDo);$i++)
{
symbolButton -i ($filePath + "Corpo_P" + $i + ".BMP") -w 75 -h 75 -ann "$i" -c "doPose(\"" + $posesDo[$1] + "\")";
}

thats just a guess mind :)

cyrus3v
09-28-2010, 05:35 PM
jaydru thanks for the reply

The doPose command on the button is the following:


global proc int doPose ()

{
select -r "*Corpo_P0";
string $obj[]= `ls -sl`;
string $character = "*DOcorpo";
pose -apply -name $obj $character;
return 1;
}


I tried the paste your code but I get syntax error. :\

rahulsg2901
09-29-2010, 06:24 AM
Check out this


global proc string[] currentCharacterPoses()
{
string $allPoses[];
string $characters[] = `currentCharacters`;
int $n=0;
int $nchars = size($characters);

//if ($nchars == 0) return allCharacterPoses();

for ($i=0; $i < $nchars; $i++)
{
string $poses[] = `pose -q -n $characters[$i]`;
for ($j=0; $j < size($poses); $j++)
{
//$allPoses[$n++] = $poses[$j];


//Apply current pose for thumbnails
pose -n $poses[$j] -a $characters[$i];
//Save thumbnails (Check out more flags for playblast )
playblast -filename $poses[$j] -st 1 -et 2 -percent 100 -widthHeight 200 200 ;

}

}


return $allPoses;
};



You get stuck because of $allPosed once the procedure end, other procedures doesnít know about string $allPoses. So we have to do all in same procedure. So I just modify to apply current pose in scene & play blast it for thumbnails letís say in default directory make sure thumbnail file has same name of pose.

Now we have pose name with thumbnails we just have to apply that image & name to the shelf button


window;
gridLayout -numberOfColumns 2 -cellWidthHeight 200 200;
shelfButton -image1 "sphere.png" -command "sphere";
shelfButton -image1 "sphere.png" -command "sphere";
shelfButton -image1 "sphere.png" -command "sphere";
shelfButton -image1 "sphere.png" -command "sphere";
shelfButton -image1 "sphere.png" -command "sphere";
shelfButton -image1 "sphere.png" -command "sphere";

showWindow;


Hope that help :bounce:

cyrus3v
09-29-2010, 09:57 AM
rahulsg2901 thanks for the reply and the code too.

But I already have the thumbnails. All I need is a way to create automatically a certain amount of buttons with a unique command based on the amount of poses. I can create the button with the respective image based on the pose, but when I create the button I need to give a unique command to apply that pose. And I need to use this script with several characters, but that is not the problem because the global proc currentCharacterPoses do all the work, checking what is the poses to the character with character set on.

I gonna post here all the code


string $fileUser = `internalVar -userScriptDir`;
string $filePasta = "Poses/Do/";
string $filePath = $fileUser + $filePasta ; // logo da janela
string $filePaththumb = ""; // thumbs
window -tlb off -rtf on -sizeable off -t "Poses Do";
columnLayout -adjustableColumn true;
image -w 450 -h 100 -i ($filePath + "logo.BMP");
rowColumnLayout -numberOfRows 3 -rowHeight 1 75 -rowHeight 2 75 -rowHeight 3 75;


Then I use a default global proc from Maya to check the amount of character poses the global proc is currentCharacterPoses.


global proc string[] currentCharacterPoses()

{
string $allPoses[];
string $characters[] = `currentCharacters`;
int $n=0;
int $nchars = size($characters);

if ($nchars == 0) return allCharacterPoses();

for ($i=0; $i < $nchars; $i++)

{

string $poses[] = `pose -q -n $characters[$i]`;
for ($j=0; $j < size($poses); $j++)
$allPoses[$n++] = $poses[$j];

}

return $allPoses;

}


Then with this information


string $posesDo[] = `currentCharacterPoses`;
int $i;
for ($i=1; $i< size($posesDo);$i++)
{
symbolButton -i ($filePath + "Corpo_P" + $i + ".BMP") -w 75 -h 75 -ann "$i" -c ("doPose(" + $i + ");");

}

global proc int doPose (int $i)

{

/*select -r "*Corpo_P0";
string $obj[]= `ls -sl`;
string $character = "*DOcorpo";
pose -apply -name $obj $character;
return 1;*/


string $corpoP = "*Corpo_P";
string $total = $corpoP + $i;
select -r total;
string $obj[]= `ls -sl`;
string $character = "*DOcorpo";
pose -apply -name $obj $character;
return 1;

}

showWindow;



And jaydru I have follow your advice and use the command flag

-c ("doPose(" + $i + ");")

But first I need to tell proc $doPose what is variable $i. Never mind -> Unfortunately I can make this work because I get a error say that $corpo_P is an undeclared variable. :s But I already declared that this is a string variable.

EDIT

I made a mistake. It wasn't $corpo_P but instead $corpoP. Sorry about that.

cyrus3v
09-29-2010, 12:51 PM
Another thing is about the variable $corpoP = "*Corpo_P" and $character = "*DOcorpo". The Corpo_P is the name of the pose and DOcorpo is the name of the character. My idea is to create a different script to each character. So I already know the name of the character and the pose too.

rahulsg2901
09-29-2010, 04:39 PM
I made this script for pose management but difference is only that i made pose file in hard drive & u making in character set so i am assuming that u hv window created with thumbnails. chk out this script

but make sure something

1 u r thumbnails file names must have like this characterSet name + _ + pose name
don't use space in file name

2 u r symbol button command look like this

after doPose must have one blank space

-c ("doPose " + "ThumbnailFileName")

3 make sure u give internal name to the symbol button best name is same as u r thumb name for eg in u code

symbolButton -i ($filePath + "Corpo_P" + $i + ".BMP") -w 75 -h 75 -ann "$i" -c ("doPose " + ThumbnailFileName) ThumbnailFileName;



then use this script



global proc doPose (string $poseName)

{
string $s1 = `substitute "_" $poseName " "`;
string $List[];
tokenizeList($s1, $List);
pose -n $List[1] -a $List[0];
};





& if there more than hundred character it a stupid thing to make script for each one so make just 1 script that work for all

cyrus3v
12-22-2010, 08:59 PM
I made this script for pose management but difference is only that i made pose file in hard drive & u making in character set so i am assuming that u hv window created with thumbnails. chk out this script

but make sure something

1 u r thumbnails file names must have like this characterSet name + _ + pose name
don't use space in file name

2 u r symbol button command look like this

after doPose must have one blank space

-c ("doPose " + "ThumbnailFileName")

3 make sure u give internal name to the symbol button best name is same as u r thumb name for eg in u code

symbolButton -i ($filePath + "Corpo_P" + $i + ".BMP") -w 75 -h 75 -ann "$i" -c ("doPose " + ThumbnailFileName) ThumbnailFileName;



then use this script



global proc doPose (string $poseName)

{
string $s1 = `substitute "_" $poseName " "`;
string $List[];
tokenizeList($s1, $List);
pose -n $List[1] -a $List[0];
};





& if there more than hundred character it a stupid thing to make script for each one so make just 1 script that work for all

Thanks for the reply rahulsg2901 :)

I gonna try your script and post some news :)

CGTalk Moderation
12-22-2010, 08:59 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.