Compile Blender 2.67b Module for python3.

I succeeded in compile of Blender2.67b as a python module on the ubuntu13.04.  The python3 of Ubuntu13.04 is Python3.3 base, it is very congenial. It is also the biggest reason to not use Ubuntu 12.4LTS and Debian 7;-)

Results:

Imports:
>>> import bpy
>>> import mathutils
>>> import bmesh
>>> import bpy_extras.io_utils
>>> print(bpy)
<module 'bpy' from '/usr/lib/python3.3/dist-packages/2.67/scripts/modules/bpy/__init__.py'>
>>> print(mathutils)
<module 'mathutils'>
>>> print(bmesh)
<module 'bmesh'>
>>> print(bpy_extras)
<module 'bpy_extras' from '/usr/lib/python3.3/dist-packages/2.67/scripts/modules/bpy_extras/__init__.py'>
>>> 

For PyDev Debugger/ Eclipse
Append your code below for example.

if __name__ == '__main__':
  # Convert axis of Y-forward and Z-up(Blender) to -Z-forward and Y-up(For Libgdx, Bullet, OpenGL).
  global_matrix = mathutils.Matrix()
  # It changes by rotation -90 degrees around the X-axis.
  global_matrix = (global_matrix * mathutils.Matrix.Rotation(math.radians(-90.0), 4, 'X'))
  keywords = {"global_matrix":global_matrix}
  bpy.ops.wm.open_mainfile(filepath="test.blend")
  save("", bpy.context, filepath="out_put.obj",**keywords)

...
Note:
Unresolved imports were still marked as errors in you code after setting PYTHONPATH on the PyDev/Eclipse.  I have no idea why. Don't worry, your code will run correctly. Unfortunately, some code may throw exception, please avoid by below code. 

  # copy all collected files.
  if __name__ != '__main__':  # avoid throw exception.
    bpy_extras.io_utils.path_reference_copy(copy_set)




see:

コメント

このブログの人気の投稿

日本でコンピュータサイエンスを学ぶ難しさ

How to preview nif file on the ubuntu.