View Full Version : Adding an Option Window to a script?

04 April 2006, 07:21 PM
Ok I got one question answered but now I have another so I've got a script that I can run to connect edge rings with a set number of loops - CSMultiLoopSplit5; or CSMultiLoopSplit10; and so on and so forth, 5 or 10 being the number of loops.

What would be really helpfull is to have just CSMultiLoopSplit; set to a hotkey and have a window pop up and ask you how many loops you want.

I did a search and came up with a few things but nothing helpfull to someone with no MEL skills at all. So if anybody with scripting skills has a spare moment I would be eternaly gratefull... At least for a little bit, if they could modify this script to bring up a window like I said.

global proc CSmultiLoopSplit (float $numSplits)


string $shape[] = `listRelatives -p`;

string $edge[] = `filterExpand -sm 32`;

if (size($edge)!=1) { warning "select single edge to do multiSplit on, multi multiLoopSplit not supported"; return;}

int $edgeNum[] = `polyEvaluate -e $shape[0]`;


int $edgeNumPost[] = `polyEvaluate -e $shape[0]`;

int $edgeStep = $edgeNumPost[0] - $edgeNum[0];

string $polSplt[] = `listConnections -type polySplitRing $shape[0]`;

setAttr ($polSplt[0]+".weight") (1/($numSplits+1));

string $mulSplit = `rename $polSplt[0] multiSplit`;

// addAttr -ln "splits" -at long -min 2 -smx 30 -dv $numSplits $mulSplit;

//scriptJob -ac ($mulSplit+".splits") ("CSmultiLoopSplitChangeCallback "+$mulSplit +" " +$shape[0]+" " + $edgeNum[0] + " " + $edgeStep);

for ($i = 1; $i < $numSplits; $i++)


select -r ($shape[0] + ".e["+($edgeNum[0] + ($edgeStep*($i-1)))+"]");


string $polSplt[] = `listConnections -type polySplitRing $shape[0]`;

setAttr ($polSplt[0]+".weight") (1/($numSplits-($i-1)));

rename $polSplt[0] ($mulSplit+ "_" + ($i+1));




Again, any help would be much appreciated

04 April 2006, 07:52 PM
You could call this from a hotkey and it should work ok.

global proc getAValue()
string $intVal;
string $result = `promptDialog
-title "CSmultiLoopSplit"
-message "Enter A Number:"
-button "OK" -button "Cancel"
-defaultButton "OK" -cancelButton "Cancel"
-dismissString "Cancel"`;

if ($result == "OK") {
$intVal = `promptDialog -query -text`;
CSmultiLoopSplit $intVal;

04 April 2006, 09:38 PM
That doesn't do anything no matter where I enter it, no error's just.... nothing.

actually it doesn't even run when I do it from a hotkey

04 April 2006, 10:02 PM
Hey dude. Do the following. Create a txt file, and change its extension from .txt to .mel
Then copy/paste the code you provided on your first post, and the code goleafsgo posted, into that "mel" file(open it with NOTEPAD or so). Then copy the file to you Maya scripts directory, possibly under "my documents/maya/VERSION/scripts"

After this, be sure that you restart Maya. Then type in the Maya command line:


and you can put this little command in the shelf, or create a hotkey to it.

If you followed all my steps, you should have no problem...



04 April 2006, 10:21 PM
awsome everything works

thanks so much from this humble artist

CGTalk Moderation
04 April 2006, 10:21 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.