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
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:
Does anybody else realize how much great work is contributed by this one person? Great job Theeth!
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.
Great work!
[url=http://lxfukfqg.com/csuz/ubky.html]My homepage[/url] | [url=http://dnyidxbp.com/rldl/exiq.html]Cool site[/url]
Thank you!
http://lxfukfqg.com/csuz/ubky.html | http://fllcjwnb.com/xwgu/gfcg.html
Post a Comment
<< Home