Re: duplicate symmetry

Date : Tue, 26 Jul 2005 18:45:04 +0000
To : XSI(at)Softimage.COM
From : "brad" <brad(at)cg-soup.com>
Subject : Re: duplicate symmetry
The script below will do what you need using Regular Expressions: (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/js56jsgrpregexpsyntax.asp) 

// Strips numbers off end of name
// Swaps leftStr and rightStr from the beginning of input object names
function NameSymmetry(inColl, leftStr, rightStr)
{
	// verify input args and set defaults
	if(!inColl) inColl = Selection;	
	if(!leftStr) leftStr = 'Left';
	if(!rightStr) rightStr = 'Right';
	
	for(var e = new Enumerator(inColl); !e.atEnd(); e.moveNext()){
		var nm = e.item().name;
		
		// Strip off end numbers
		nm = nm.replace(/[\d]*$/,'');
		
		var leftRE = new RegExp('^' + leftStr);
		var rightRE = new RegExp('^' + rightStr);

		// Test for leftStr		
		if(nm.match(leftRE)){
			nm = nm.replace(leftRE, rightStr);
		}

		// Test for rightStr
		else if(nm.match(rightRE)){
			nm = nm.replace(rightRE, leftStr);
		}
		e.item().name = nm;
	}
}


-------Original Message-------
>  if you duplicate symmetry a skeleton structure with the word Right in it, it
>  will become RightNNN1.
>  Is there something that make is easy to rename the new structure so it
>  replace the word Right with Left
>  and removes the 1 on the end?
>  
>  cheers,
>  Carl
>  
>  
>  ---
>  Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
>  unsubscribe xsi
>  
-------Original Message-------
---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi


Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.