Go to: Synopsis. Return value. Related. MEL examples.

Synopsis

string formValidObjectName(string $name)

Form the valid object name. It will replace all the invalid characters with "_". If the string is not start with English character, it will add an "a" at the the beginning of the string. Non-ascii characters will be treated as invalid. If the passed in string is empty or it can't form the valid object name string, it will return "defaultObject" instead.

Return value

None

Related

formValidObjectName, isValidObjectName, isValidString

Arguments

Variable Name Variable Type Description
$namestringThe original name string for generating the valid object name.

MEL examples

 formValidObjectName("FBX Export"); // It will return "FBX_Export"

 formValidObjectName("2FBX Export"); // It will return "a2FBX_Export"

 formValidObjectName("_FBX Export"); // It will return "a_FBX_Export"

 formValidObjectName("FBX2 Export"); // It will return "FBX2_Export"

 formValidObjectName("F_BX Ex_port"); // It will return "F_BX_Ex_port"

 formValidObjectName("F!BX Ex#$port"); // It will return "F_BX_Ex__port"

 formValidObjectName(""); // It will return "defaultObject"

 formValidObjectName("_"); // It will return "a_"

 formValidObjectName("!"); // It will return "a_"

 formValidObjectName("b"); // It will return "b"