(MEL) Hair Card Deformer

This is my first version of my hair card deformer. Which creates a curve between two edges and wire deforms that curve to the geometry then locks the length of the curve.

You will need to have Track Selection Order turned on in your preferences, although the Script will ask you this as well.

global proc HairCardDeformer()
{
	// checking if 'Track Selection Order' is turned on in preference settings
	int $TSO = `selectPref -q -tso`;
	if($TSO != 1)
	{
		string $confirm = `confirmDialog 	-title "Track Selection Order"
											-message "'Track Selection Order' is needed for this script to function properly. Would you like to turn it on?"
											-button "Yes"
											-button "No"
											-defaultButton "Yes"
											-cancelButton "No"
											-dismissString "No"`;
		if($confirm == "Yes")
		{
			selectPref -tso true;
				confirmDialog 				-title "Restart Script"
											-message "'Track Selection Order' has been turned on. Please re-run this script"
											-button "OK"
											-defaultButton "OK"
											-cancelButton "OK"
											-dismissString "OK";
			error "Please re-run script";
		}
		else
		{
			error "Script cannot run without 'Track Selection Order' Turned on.";
		}
	
	}
	
	// save object to variable
		string $parentShape[] 		= `listRelatives -p`;
		string $parentGeo[] 		= `filterExpand -sm 12 $parentShape[0]`;
	
		// select edges in order
		string $selectionEdge[] 	= `ls -os`;
		print "\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n";
		print ($selectionEdge[0] + "\n");
		print $selectionEdge[1];
		print "\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n";
	
	for($i = 0; $i < 2; $i++)
	{
		select -r $selectionEdge[$i];
		ConvertSelectionToVertices;
		string $selectionVerts[2] 	= `filterExpand -sm 31`;
		
		print "\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n";
		print ($selectionVerts[0] + "\n");
		print $selectionVerts[1];
		print "\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n";

		float $fEV1[3] 				= `xform -q -t -ws $selectionVerts[0]`;
		float $fEV2[3] 				= `xform -q -t -ws $selectionVerts[1]`;
		
		spaceLocator -n ("tempLocator" + $i);
		move -a (($fEV1[0] + $fEV2[0])/2) (($fEV1[1] + $fEV2[1])/2) (($fEV1[2] + $fEV2[2])/2) ("tempLocator" + $i);
	}
	
// Get position of temp locators
	float $firstCurve[3] 			= `xform -q -t -ws tempLocator0`;
	float $secondCurve[3] 			= `xform -q -t -ws tempLocator1`;
	
// create curve at locator locations
	string $deformerCurve 			= `curve -n "deformerCurve" -d 1 -p $firstCurve[0] $firstCurve[1] $firstCurve[2] -p $secondCurve[0] $secondCurve[1] $secondCurve[2] -k 0 -k 1`;
	delete tempLocator0 tempLocator1;

// Rebuild curve to have higher number of control vertices	
	rebuildCurve -ch 1 -rpo 1 -rt 0 -end 1 -kr 0 -kcp 0 -kep 1 -kt 0 -s 16 -d 1 -tol 0 $deformerCurve;

// wire deformer for mesh and newly created wire	
	wire -dds 0 10.0 -w $deformerCurve $parentGeo;
	
	LockCurveLength $deformerCurve;
}