global proc string MCPXGetNodeUUID(string $plug){
    string $buffer[];
    tokenize($plug, ".", $buffer);
    string $node = $buffer[0];
    string $uuids[] = `ls -uuid $node`;
    string $uuid = $uuids[0];

    return $uuid;
}


// modified Autodesk AEnewNonNumericMultiAddNewItem proc
// (or similar python's createNonNumericMultiAddNewItem for Maya > 2019)
// mental ray operations removed
global proc MCPXCreateNonNumericMultiAddNewItem(string $node, string $multiAttr)
{
	string $attr = ($node + "." + $multiAttr);

	// Find the next available index
	int $nextAvailable = 0;

	string $buffer;
	if( `getAttr -s $attr` > 0 )
	{
		//	Get currently used indices
		//	The return value looks like this: {rgb[0], rgb[0].r, rgb[0].g, rgb[0].b, rgb[3], ... }
		string $multi[] = `listAttr -multi $attr`;

		for($m in $multi)
		{
			//	Find index [n]
			$buffer = match("\\[[0-9]+\\]", $m);
			//	Find n. Use implicate data type conversion. string "15" is converted to int 15
			int $index = match("[0-9]+", $buffer);

			if ( $index >= $nextAvailable )
				$nextAvailable = $index + 1;
		}
	}

	// Creat a new plug.
	string $plugName = $attr + "[" + $nextAvailable + "]";

	// Create a plug by accessing it
	catchQuiet( `getAttr -type $plugName`);
}


// modified Autodesk deleteShelfTab proc
// dialogs removed, file of shelf will be deleted (not renamed)
global proc int MCPXDeleteShelfTab(string $shelfName)
{
	int $returnStatus = 0;

	global string $gShelfForm;
	global string $gShelfTopLevel;

	setParent $gShelfTopLevel;
	string $shelves[] = `tabLayout -q -ca $gShelfTopLevel`;
	int $numShelves = size($shelves);


	// Bail if there is something really weird going on
	if ($numShelves <= 0) return $returnStatus;


	int $i = 0;
	int $nShelves = 0;
	int $shelfNum = 0;

	//  update the preferences.
	//
	$nShelves = `shelfTabLayout -q -numberOfChildren $gShelfTopLevel`;
	for ($shelfNum = 1; $shelfNum <= $nShelves; $shelfNum++) {
		if ($shelfName == `optionVar -q ("shelfName" + $shelfNum)`) {
			break;
		}
	}
	for ($i = $shelfNum; $i <= $nShelves; $i++) {
		string $align = "left";
		if ( `optionVar -ex ("shelfAlign" + ($i+1))` )
			$align = `optionVar -q ("shelfAlign" + ($i+1))`;
		optionVar
			-iv ("shelfLoad" + $i) `optionVar -q ("shelfLoad" + ($i+1))`
			-sv ("shelfName" + $i) `optionVar -q ("shelfName" + ($i+1))`
			-sv ("shelfAlign" + $i) $align
			-sv ("shelfFile" + $i) `optionVar -q ("shelfFile" + ($i+1))`;
	}
	optionVar -remove ("shelfLoad" + $nShelves)
		-remove ("shelfName" + $nShelves)
		-remove ("shelfAlign" + $nShelves)
		-remove ("shelfFile" + $nShelves);

	// The optionVars have all been updated, so it's safe to delete and have
	// the shelfTabChange() method triggered. See Maya-3288.
	//
	deleteUI -layout ($gShelfTopLevel + "|" + $shelfName);

	string $shelfDirs = `internalVar -userShelfDir`;
	string $shelfArray[];
	string $PATH_SEPARATOR = `about -win`? ";" : ":";
	tokenize($shelfDirs, $PATH_SEPARATOR, $shelfArray);
	for( $i = 0; $i < size($shelfArray); $i++ ) {
		$fileName = ($shelfArray[$i] + "shelf_" + $shelfName + ".mel");

		if (`filetest -r $fileName`) {
			sysFile -delete $fileName;
			break;
		}
	}

	//  Make sure the new active shelf tab has buttons.
	shelfTabChange();

	$returnStatus = 1;

	return $returnStatus;
}
