help writing function [solved]

I’m writing a python script and got stuck in a part of it.

I have a dictionary in wich the KEYs are the vertices and the VALUEs are lists of edges that share the vertices.

I need a function that recursively eliminates the edges (from the VALUEs) with a lower angle to a given plane untill each KEY(vertice) has only one VALUE(edge), and get a list with the eliminated edges.

I have this function to get the angles, but don’t know how to continue from here.

edge_group = verts_dict[key] # get edges of (vert=key)
angles = []

for edge in edge_group:
    v1 = Mathutils.Vector(
    v2 = Mathutils.Vector(
    vector_u = Mathutils.Vector(v2 - v1)

    angle = round (Mathutils.AngleBetweenVecs(face_normal, vector_u))

Can you help me with this?:o

Can you post more of your script?
For some good examples of this kind of stuff look and Blender 2.42’s - I added quite a lot of relational mesh data stuff to that.

This is the 1st version of the working script:

This version have problems if 2 selected edges share a vertice.

So i thought in making a filter like,

if 2 or more edges share a vertice
find wich edge is more perpendicular to the plane and eliminate the others from calculation.

I have to find this for all vertices and see if none of the vertices “chose” the same edge (or it gives error again).

I think this is a good filter, because of the nature of the script.
If you have a better idea for a filter, please say it.:slight_smile:

So, i start to implement (with my limitations) the filter.

Here is the “in construction” version.

Hope is not to confuse and thank you to help me in this.:slight_smile:

I have updated my own :
Now it work with external faces selected in/on another mesh . You can select all the edges and the vertices you want to trim, in the order you want that works .

I could help you if I understand :
1/ why you try to work with edges only
2/ why you test all these angles

My script does not do the same as your’s.
If you know Autocad, it as a trim and an extend functions, and what they do is to cut an edge giving another edge as cut frontier, or extend an edge giving another as frontier.

My script intention is to preform does functions, but in 3D, that’s why i’m using a plane as frontier. If you test it, you see that the extention is not orthogonal, it keeps the edge direction. That’s why i’m using the edges.

The angles test is a choice to help the functionality of the script (aldow both options are possible, i think most people who uses the script go to use it for extend edges more perpendicular “or less paralell” to the plane). I can just say “do not select connected edges”, but i want it more user friendly.

If you want a script thet generates edge angles- see’s meshCalcNormals

Thank you, cambo, but Mathutils as that function.
But i didn’t know that blender came with such a good python library!:slight_smile: