Monday, July 11, 2005

Python Strike Back

G'day!

I've been taking a short break from complex decimator code today and fiddling with some more fun stuff.

Py Buttons!

Basicly, it evaluates the text as a python expression as if using eval() and puts the value back in the button as usual (meaning it checks for limits and all that). The execution is done sandboxed, it only has access to __builtin__ as well as the Blender and math modules (if it can import them).

Branching to the python evaluation code is based on the presence of the hash (#) symbol as first character. I thought it would be ironic to use the Python comment sign to signal Python evaluation. The irony is nice for memory :P. This is very faculative though, it could very well evaluate everything if it is wanted.

Right now (meaning after capturing the video), it pops the normal Python error message if it hits and error and prints the traceback in the console. It could be done silently though (as shown in the video).

Python Powa!

Martin

4 Comments:

Anonymous Anonymous said...

Does anybody else realize how much great work is contributed by this one person? Great job Theeth!

2:44 PM  
Anonymous Anonymous said...

Really nice, it would be even nicer if it could be evaluated dynamically.

Meaning the python instruction would be kept in the button's memory instead of replacing it by the value it's evaluated to.
The evaluated value would be displayed in the button's label but the button's value would still be the python instruction.

That would allow a bit more of procedurality in Blender.

Whatever, I don't know if I was clear in my explanations but what you did is a good job.

2:12 AM  
Anonymous Anonymous said...

Great work!
[url=http://lxfukfqg.com/csuz/ubky.html]My homepage[/url] | [url=http://dnyidxbp.com/rldl/exiq.html]Cool site[/url]

5:08 PM  
Anonymous Anonymous said...

Thank you!
http://lxfukfqg.com/csuz/ubky.html | http://fllcjwnb.com/xwgu/gfcg.html

5:08 PM  

Post a Comment

<< Home