Angle between vectors: attribute not found

Hello. In my script I need to find the angle between two edges, so I want to use the proer python function.
I wrote this way, but it gives me "module has no attribute ‘AngleBetweenVecs’ " error.

What’s the correct code?


import bpy
import mathutils
from mathutils import geometry

bpy.ops.object.mode_set(mode = 'OBJECT')

ob = bpy.context.active_object
me = ob.data
    
sel_vert = []

for v in me.vertices:   #fra tutti i vertici della mesh
    if v.select:        #se il vertice è selezionato        
        sel_vert.append(v.index)

AngleBetweenVecs(me.edges[0], me.edges[1])

bpy.ops.object.mode_set(mode = 'EDIT')   

thankyou!

You can’t just make up Blender API commands (unfortunately).

Check here:
http://www.blender.org/documentation/blender_python_api_2_62_2/mathutils.html

It looks like “angle(other, fallback)” is the command you need.

I’m sorry, I have another similar question: I need to get the midpont vector between two vectors, so I’ve found this function in this page: http://www.blender.org/documentation/249PythonDoc/Mathutils-module.html#MidpointVecs , but it seems to be in use no more, like the anglebetweenvecs. What is the correct actual funtion that does the same thing?

Thankyou very much!

@Lell,
You can try something like this below, which I used to find the center point of an edge using the vectors from two verts in an edge. Since the vectors are a local coordinate, the last line finds what the global coordinate is.

obj = bpy.context.object
co1 = obj.data.vertices[0].co
co2 = obj.data.vertices[1].co
localcenter = co1.lerp(co2, 0.5)  # This is finds the center which is 0.5
g_co = obj.matrix_world * localcenter  # This finds the global coordinate of that center