Displays text in the Script Editor. You can use this function to display the contents of attributes and variables. This is helpful for debugging an expression.
text is either a string enclosed in quote marks or an attribute name or string variable containing text.
number is a number without the quote marks. Numerical arguments display as strings.
There is no returned value for this function.
Note the following display considerations.
For example, a vector <<1.518876356, 0, -1.290387446>> appears in the Script Editor as this:
1.518876356 0 -1.290387446
"text1" + "text2"
text1text2
"text" + 1
text1
Variable data type | String assignment | Data displayed |
---|---|---|
float | "3.14" | 3.14 |
int | "3.14" | 3 |
vector | "3.14" | 3.14 0 0 |
float | "pi is 3.14" | 0, error message |
As shown in the last row of the table, if a variable is assigned a string that starts with a non-numerical character, Maya converts the string to 0.
print(time);
print("\n");
The first statement displays the value of time. The second statement displays a new-line character after the value of time, so the time appears on a separate line in the Script Editor.
float $f = 3.14159;
print($f);
Displays the floating point number 3.14159.
string $s = "Hello There";
print($s);
Displays the string Hello There.
vector $v;
$v = <<1.2,2.3,3.4>>;
print($v);
Displays the vector as 1.2 2.3 3.4.
string $a[];
$a = eval("ls -lights");
print($a+" are the lights in my scene.\n");
The print function causes an error message because you cannot use the + operator with a string array.