Noob Rigger's Question: Is this a correct way of creating a rigging scrip in MEL?

DCC Package: ___________MAYA 2012
Programming language:____MEL

I have been studying rigging in MEL/Python/PyMel with the help of a fellow programmer for a while now and here we are trying to emulate a “Weight Lifting Pole” in Maya.


//Create new file
file -f -new;

//Procedure that adjusts the height of the joints.
//float "$a": responsible for the slant of the joints.
//float "$th": responsible for the minimum height; when the pole bigins to break.
proc string returnString(string $node0,string $node1, float $a){
	float $th = 1;
	string $tmpstr="if("+$node0+".ty<"+$th+"){"
	+$node1+".ty  = "+$node0+".ty;"
	+"}"
	+"else if("+$node0+".ty<"+($th+$a)+"){"
	+$node1+".ty =" +$th+ ";"
	+"}"
	+"else{"
	+$node1+".ty = ("+$node0+".ty-"+$a+");"
	+"};";
	return $tmpstr;
}

//Number of joints the pole will have.
$num_joints = 10;

//Number of subdivisions of the "y" axis, of the pole that will be created.
$subdivisionsY = 2*(3*($num_joints*2+1));

//$allJoints[]: is a table which will contain all the joints that will be created.
string $allJoints[];

//Adjusting camera position in the project, for ease of use.
string $perspCameras[] = `listCameras -p`;
camera -e -p -15 15 0 -worldCenterOfInterest 0 0 0 -worldUp 0 1 0 $perspCameras[0];

select -cl;

//Creating the first joint. The parent joint and adding it in the table.
$tmpName = `joint -p 0 0 0 -n j_p -radius 0.5`;
$allJoints[0] = $tmpName;

//Clearing selection in order to be able to create more joints without
//connecting the parent joint to the next one created.
select -cl;

//Creating "$num_joints" positionning them equally on the left and right of the parent joint.
//Placing all the joints into the table. Like this: j_p,j_r1,j_l1,j_r2,j_l2...etc
for ($t=1; $t<=$num_joints; $t++){ 
	$tmpNameR = `joint -p 0 0 $t -n ("j_r"+$t) -radius 0.5`;
	select -cl;
	$tmpNameL = `joint -p 0 0 (-$t) -n ("j_l"+$t) -radius 0.5`;
	select -cl;
	$allJoints[$t*2-1] = $tmpNameR;
	$allJoints[$t*2] = $tmpNameL;
}

//Creating the polyCylinder.
$poleName = `polyCylinder -axis 0 0 1 -n Pole -radius 0.5 -h ($num_joints*2+1) -sc 1 -sy $subdivisionsY`;

//SmoothBinding the joints we created above, to the polyCylinder.
skinCluster -polySmoothness 10 $poleName $allJoints;

//Beginning to create the string which will contain all the "if" commands 
//which will go through the "expression" command, at the end of the file.
//I'm doing this because i want to be able to control 
//when(translate.y = ?) the slant will occure on the pole.
string $tmpstr= returnString($allJoints[0],$allJoints[1],0);
$tmpstr+= returnString($allJoints[0],$allJoints[2],0);

//Continuing to add all the "if" commands from the above 
//procedure to the string named "$tmpstr"
for ($t=2; $t<=$num_joints; $t++){
	if ($t<=3){
		$tmpstr+= returnString($allJoints[$t*2-3],$allJoints[$t*2-1],0);
		$tmpstr+= returnString($allJoints[$t*2-2],$allJoints[$t*2],0);
	}else if($t>=$num_joints-4){
		$tmpstr+= returnString($allJoints[$t*2-3],$allJoints[$t*2-1],0.2);
		$tmpstr+= returnString($allJoints[$t*2-2],$allJoints[$t*2],0.2);
	}else{
		$tmpstr+= returnString($allJoints[$t*2-3],$allJoints[$t*2-1],0.05);
		$tmpstr+= returnString($allJoints[$t*2-2],$allJoints[$t*2],0.05);
	}
}
expression -s $tmpstr;

Is this the correct way for creating a rigging script / tool?
I mean…
1)if you wanted to create a weight lifting pole…is this the first step you would maybe take towards creating a weight lifting pole?
2)is the way I am coding, the correct “scripting” way? or am i doing much more programming than i should?
3)would a rigging script include everything i have created above?

all of the 1,2,3 are basically asking the same question…

Sorry for being tiresome…:rolleyes: