public class CleanedName
{
// Clean Name
// --------------------------------------------------
// Given a string, this will remove illegal characters so
// it fits within Maya naming conventions
public static string CleanName(string name)
{
// We have to strip out any illegal characters from the name
// a-z A-Z 0-9 and _ are the only accepted characters
StringBuilder cleanedName = new StringBuilder(name.Length);
// We will be moving forward through the name,
// keeping only letters, numbers, and underscores.
foreach (char character in name)
{
if (char.IsLetterOrDigit(character) || character == '_') cleanedName.Append(character);
}
// Convert the stringbuilder into a string
return cleanedName.ToString();
}
}
Comments
0 B
|👍
/👎