Print statement in XSI

March 8th, 2005 by Patrick Boucher - Viewed 2577 times - Popularity: 6% [?]




I get an e-mail from Rick Walia at The Mill this morning…

[...snip...]
Anyways, you know you can use the print statement with python & XSI right?

Nope! I hadn”t even tried it out. And check this out:

from time import time
from win32com.client import constants as c

t1 = time()
for x in range(500):
Application.LogMessage(x, c.siComment)
t1 = time() - t1

t2 = time()
for x in range(500):
print x
t2 = time() - t2

print t1
print t2

Besides a bunch of numbers, the output I get is the following:

#1.21900010109
#0.0159997940063

That is 1.219 seconds for 500 Application.LogMessage() calls and 0.015 seconds for 500 print statements. Am I flabergasted or what!

The downside of using the print statement is that it acts like Application.LogMessage(‘’string”, c.siComment) but if you use Application.LogMessage() you can control the severity of the message that gets output to the user through the second argument – default value is c.siInfo.

Upsides and downsides to both methods.

Big thanks Rick!

[ EDIT: April 5th, 2005 at 6:51 pm ]

Seems this tip works if you”re running Python 2.3.x but not Python 2.4.x
Note to Softimage and/or the Python community if anyone is reading: would be cool if the older behavior was supported! ;)

Thanks to Bernard Lebel for making me notice.

Popularity: 6% [?]

5 Responses to “Print statement in XSI”

  1. Hello,

    I have tried several time to use the print statement in my XSI scripts, but it doesn”t produce any result. It’’s like the print statement is not there at all, no error is logged, just emptyness.

    Any idea?

    Thanks
    Bernard

  2. Just tried it out on my computer running ActivePython 2.3.x and a another computer running ActivePython 2.4.x: works on the former but not the latter. If you”re running 2.4.x that might be your answer.

  3. Hum it doesn”t work both in Python 2.3.4 and 2.4.
    I have to say I don”t use the ActiveState distribution of Python, instead I use Python + the pywin32 module (wich is a COM server). Perhaps it is related.

    Thanks for checking out.
    Bernard

  4. Hmmm… On a computer running Python 2.3.5 and pywin32 it works at my end… Are we down to checking XSI Versions? 4.2 here.

  5. [...] thon over other scripting languages for a lot of my work. A while back I talked about the print statement inside XSI. Well, at some version, I don’t remember which, it stopped working. I miss it. I m [...]

Leave a Reply