Python or Blender Code

I’m quite stumped at the moment and I need your opinion if I should continue with Python or take the leap into Blender Code. I’m posting in this section because I find it more likely to have experienced users in both Python and Blender Code here.

I have a couple of projects in pre-production which I’m researching and testing the capabilities of Python for, seeing how far I can go with basic routines and how much is exposed. My projects are very focused on user interactivity in the 3d viewport, specifically with armatures and meshes, and I’ve started to wonder if I need to go as far as making a modified Pose Mode (which is Blender Code if I’m not mistaken) to achieve the results I want.

I’ve tried to see how far interactivity goes, how much I can cross between modes and do things out of the ordinary, and I’m starting to wonder if some parts aren’t exposed to Python or if it’s my 3d math skills that is seriously lacking, it most likely is. One example would be to trace from mouse click and see what object I hit, if I hit a specific mesh I should detect what vertices and vertex groups that’s related to where the trace hits. Everything vertex related works just fine, however, the only exposed class I could find for tracing/raycast which isn’t BGE related seems to be quite lacking.

# Trace on active object, example found on some old Blender discussion board
obj = bpy.context.active_object
(pos,normal,faceind) = obj.ray_cast((10,0,1), (-10,0,1))

# Tracing only works on an active object/mesh and it does so on the non-transformed version. Which means the mesh is evaluated as being at Origo (0, 0, 0) with no scale or rotation which defeats the whole purpose of trying to trace at it during animation.

# Mathutils has mathutils.geometry.intersect_ray_tri but that's even more complicated

I expect to run into troubles with interaction later, just like I have with tracing.

All in all I’m asking you, the experienced users of the API, if Python is enough for what I want to achieve or if it’s best to dive into Blender Code.

Thanks in advance!

If i remember right, there is a transformation that can transform 2d screen coordinate to 3d view space coordinate, search in bf-committers mailing list. Python is good, i like it and it is easy, but is slow. If you must do complicate math you should write Cpython modules. Modifying the blender code can be useful if what you need is not exposed in python api, but if you don’t have speed problem and the apis give you what you need, there is no reason to start changing blender code, even if it is always interesting :slight_smile:

Yes, I think I found the 2d/3d screen coordinate classes.

Thanks for the input! :slight_smile: