Name Values

The Name class defines the characteristics of names. Names are primarily used as parameters in function calls to signify one of a set of options.

Literal

#<var_name>

See Names for a description of Name literals.

Constructors

<string> as name

Converts a String value into a name.

Operators

<name> == <name>
<name> != <name>
<name> < <name>
<name> > <name>
<name> <= <name>
<name> >= <name>

Comparison of names is alphabetic (caseless). Among other things, this allows arrays of names to be sorted using the array sort function.

Methods

copy <name>

Creates a new copy of the name value.

<name> makeValidName <string>

Returns a valid name value name from the specified string, where all spaces and punctuation are replaced with the underscore '_' character. This can be useful for safely creating rollout controls or scripted Paramblock2 parameters from strings.

Available in 3ds Max 2018 or higher.

When outputting a name value to a stream, if the name value string contains non-alphanumeric characters other than underscores, the string portion is enclosed in single quotes. If the name value string contains escaped characters (\n, \r, \t, \\, \'), the string portion will contain those as escaped characters.

Available in 3ds Max 2027.2 or higher.

The following script shows the use of various literals, constructors, and operators of the Name class.

SCRIPT

   -- name test bed
   name1=#Hello-- set variable to name literal
   name2="HELLO" as name-- convert string to name
   if name1 == name2 do print "names are equal"-- compare the names
   box_props=getpropnames box-- get the properties of box class
   sort box_props-- sort the property names
   format "%\n" #'A\nB\rC\tD\\E\'F\n\r\t\\\'' -- name value with non-alphanumerics

OUTPUT:

   #Hello-- result of line 2
   #Hello-- result of line 3
   "names are equal"-- output from line 4
   "names are equal"-- result of line 4
   -- following are the results of lines 5 and 6
   #(#height, #length, #lengthsegs, #width, #widthsegs, #mapCoords, #heightsegs)
   #(#height, #heightsegs, #length, #lengthsegs, #mapCoords, #width, #widthsegs)
   #'A\nB\rC\tD\\E\'F\n\r\t\\\''