PDA

View Full Version : how to source a script?


calinmatney
04-19-2006, 05:46 PM
I am an artist so by natural law I know next to nothing about scripting. I was given a tool and told to "source the script"....... What exactly does that mean and how do I do it?

Here is the script
------------------------------------------------------

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]`;

PolyConvertToRingAndSplit;

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)))+"]");

PolyConvertToRingAndSplit;

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

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

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

}

}

------------------------------------------------------

I've searched for a how to but to no avail on both cgtalk and high end 3d, dunno if I'm just looking in the wrong place or what. And yes I did look at the help file in Maya but this assumes that you know something about scripting and so was no help to me.

Any help would be much appreciated.
Thanks
CTM

mhovland
04-19-2006, 06:04 PM
Put the script in your script path so Maya can find it and type the following.

If Maya is running when you copy the script into the scripts folder, type this:

rehash; source CSmultiLoopSplit;

If you copy the script into the folder, and then start Maya, tyoe this:

source CSmultiLoopSplit;

Once the script is sourced, you call it by entering this:

CSmultiLoopSplit 2;

The above command will tell the script how many splits you want. You can change the number to whatever you like. I would make a few shelf buttons that added different numbers of splits, like this:

CSmultiLoopSplit 1;
CSmultiLoopSplit 2;
CSmultiLoopSplit 3;

I haven't tested the script you posted, so if that doesn't work, let me know and I will test things out.

calinmatney
04-19-2006, 06:08 PM
awsome it worked

thanks so much

Is it possible to make it so that I can just hotkey the script and have it bring up a window requesting how many splits I want instead of having to type the script every time?

Either way, thanks again
CTM

danielpk
04-20-2006, 01:58 PM
You might want to try this script as a GUI interface for the CSmultiLoopSplit script:
http://dpk.stargrav.com/temp/DPK_CSmultiLoopSplitUI.mel

It assumes you have installed the above CSmultiLoopSplit script. I couldn't test whether it works, as I don't have Maya 7... :)

Btw, here's how to set this up as a hotkey:

Open the Hotkey Editor (Window->Settings/Preferences->Hotkeys...)
Select the "User" category
Press the "New" button (on the right)
Enter e.g. "MultiLoopSplit" as the name
Enter "DPK_CSmultiLoopSplitUI;" as command
Press "Accept"
Make sure the new "MultiLoopSplit" entry is selected in the list
Under "Assign New Hotkey" enter e.g. "-" as key and activate the check box "Ctrl"
Press "Query" and make sure you haven't assigned this key combination to another command. In case you have, choose a different key combination and try again.
Press "Assign"
Press "Save" and "Close"

With an edge selected, you can then simply press Ctrl+"-" to open the UI. The field will have focus so that you need two key strokes to split and close the UI. E.g. press 3 and "Enter" on the numpad.

CGTalk Moderation
04-20-2006, 01:58 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.