How can I get the angle of the edge , is there a method that return the angle of selected edge ?
In edit mode, with your edges selected, fire up the properties panel N, and click on Edges, & Angle.
It worked for me.
Since you modified your question:
Here is an append to this answer that may get you closer:
To Actually access the information that you need, you could get all the verts and calculate angle based on XYZ deltas:
I'm not going to solve it for you, but I will at least tell you how I would approach it.
I would first loop through the verts using something like:
for vert in bpy.data.meshes['Plane'].vertices:
print(str(vert.co.x) + "," + str(vert.co.y) + "," + str(vert.co.z))
Note this is just printing the coordinates of each vert (not very useful, other than showing you how to access their info).
Then I would calculate the angle between each vert, find the selected edges that match these verts, and spit out the angle.
Please note that you can access
.edges similarly to
.vertices, inside of the
.edges object you will have a
vertices object that is a list of two vertex indices:
It seems doable, just have to figure out the calculations, and how you are going to narrow down your selection.
Hope it helps.
I think that you would have an easier time if you thought about doing the calculations after you account for coordinate system rotations in the following example case I'm simplifying this to only "Z"
Here is a visual circular example to show you what I mean:
From your comment it seems that you are not taking this into account.
It is advisable to calculate the midpoints of the section, and do your calculations from there, because as you see in the circular example on side of the mesh is longer than the other, and getting the midsection helps you to work on the average edge rotation.
Once you have this, you can translate your coordinate locations to rotate about "Z" via the indicated angle.
As another hint, it may be advantageous to think about this angle according to the following (Where I believe that your desired angle is the sum of a2 & a3):
import bpy import math import bmesh vert =  obj = bpy.context.object.data bmsh = bmesh.from_edit_mesh(obj) for elem in reversed(bmsh.select_history): if isinstance(elem, bmesh.types.BMVert): vert.append(elem) v1 = vert.co - vert.co v2 = vert.co - vert.co v1mag = math.sqrt(v1.x * v1.x + v1.y * v1.y + v1.z * v1.z) v1norm = [v1.x/v1mag , v1.y/v1mag , v1.z/v1mag] v2mag = math.sqrt(v2.x * v2.x + v2.y * v2.y + v2.z * v2.z) v2norm = [v2.x/v2mag , v2.y/v2mag , v2.z/v2mag] res = v1norm * v2norm + v1norm * v2norm + v1norm * v2norm angle = (math.acos(res)*180/math.pi) print(angle) bmesh.update_edit_mesh(obj)
this code depend on the selection of three vertices , it will calculate the angle for the second selected vertex.
for edge angle :
angle = (math.acos(res)*180/math.pi)-180