Freestyle integration into Blender

May 26, 2008

PythonInterpreter bug fixed using Blender's native Python environment

Filed under: Update — The dev team @ 7:31 PM

I was stuck for a long time today on PythonInterpreter‘s bug. Using gdb, I was able to trace down why it was crashing. Whenever a command was sent to Python using the C interface function PyRun_SimpleString, it would in turn call PyImport_AddModule( "__main__"). For some reason, this command would crash with the "No such file or directory" error. Of course, this error should not happen. __main__ (among others like __built__) is supposed to be initialized with the Py_Initialize() method. It was a weird error. I had made sure that Python was well initialized, but it hadn’t resolve anything.

Understanding that the nature of the problem was probably beyond the project’s interest (and my means…), I decided to use Blender’s Python functions directly (which is planned to be done at phase 2 of the project). I am surprised to see how quick the integration was: I used bf_blenkernel‘s add_text method to load the file into a Text structure, bf_python‘s BPY_txt_do_python_Text method to execute the (fixed) script file, BPY_Err_getLinenumber to display the error line number. The Python script is executed and stops because it doesn’t find the Freestyle module.

Next, I am going to compile the SWIG module wrapper and integrate it so that the Python interpreter can use it to call the Freestyle API functions.

Update:
The code was updated to properly handle PythonInterpreter‘s initialization, following Freestyle original code.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: