HI,
how can I generate a meshplane by averaging a selection of verts?
So 3 or more points…
I’m thinking the average is exactly 1 vertex, care to elaborate?
You need to average the location of the vertices (for the location for the plane if this is not an infinite plane) and find the normal (depending on how you get them you can use cross product or use some bmesh functions). There are couple functions to turn the normal to a relative rotation for the new plane, see the math lib.
Averaging the normals of the selected vertices might be the best choice… Just add all normal vectors together, and then normalize the result vector.
I think there is another and a better way, using the transform orientations to get the matrix, all that comes for free with it.
bpy.data.scenes[0].transform_orientation_slots[0].custom_orientation.matrix.to_euler()
But in that case you need to define the transform matrix by hand (that means: for each set of vertices you’ll need to create/define a matrix)… It sure gives more control, but defining a normal vector (3 components) directly is easier than defining a matrix (16 components) to get the transformed Z vector and use it as a normal… 
The simplest way to generate a plane from averaging a set of vertices is simply averaging the vertices location (as you sugested), and averaging the normals (a plane is by definition a point, and a normal).
When you create a transform orientation (from the viewport header menu for instance), it already averages the normals based on the selection (and world aligned) and the matrix that I gave above can be used to align a plane.
I think that both methods are legit.
hi, Yes I should explain what i want to achieve.
I want to planarise an edgerow / a selection of verts.
There is a few steps to it, from what think.
1-I have a selection of minimum 3 Verts (to define a plane- at least thats how I used to do it in CAD)
most likley it will be far more than 3 Vertices
2-This plane(or coordinates) I want to generate an actual Geometry-plane.
3-Now I want the same selection of Vertices to be Puled/Shrinkwraped onto this plane, planarizing them…
(I had this functionality in CAD/ Nurbs modelling and it helped a lot to clean up the geometry.)
I would wish for simple tool/addon that does this in an automated way…
Doesnt sound very complicated, or does it?
Sadly I have close to noe Python experience-
But in tools like Grasshopper (for Rhino3d) it is actually quite simple to put together.
Excuse me again, for I am a bumpkin.
Are you asking how to flatten a bunch of points? So if we had a point cloud, and by miracle they were all Z-Up, you would scale z to 0 and call it a day?
The flattening should happen relative to that custom plane defined by 3(actually4) or more selected verts of that same edge row.-
Again, Alias has such tools for a long time-
Also here in Blender "mira"tools have a few tools that come quite close, but not exactly what i want…
BTWNurbs modeller Like Alias and rhino, have a conzept called “construction planes” its like custom/alternative coordinate systems, which are very usefull as well, and could do something similar, as they can be positioned freely in space, temporarily redefinig xyz -
So you could really scale z=0, but relative to that custom coordinate system!
Would be awsome to have something like this in Blender- but this goes to far.
Haveing an planrarize/average selected Edgerow would already be a big helper…
Ok take 2 with my guesswork.
After watching the video, here is my next guess for the explanation of what you wanted.
Given an already existing plane, whether bended or jagged, select an edge from 1 side to the other. Then, along the sub-edges of that selection from 1 edge to the next, rotate them so that their total angle is 0, and so that the adjacent faces of each individual sub-edge have the same normal as they initially had.
This is how its done in Alias, the tool is called hull planarise

-and this is how i Would like to have it in blender, the plane, the vertex group and the shrinkwrap modifier should automatically be created, applied, and deleted after its finished…
And the plane could (maybe) be generated using 3 points like it is in here

-and this is how i Would like to have it in blender, the plane, the vertex group and the shrinkwrap modifier should automatically be created, applied, and deleted after its finished…

Have you tried the ‘Looptools’ addon?
The Relax and the Space operators are quite nice to deal with these situations…
Yes, I know them, but forgot about them 
I just revisited them, and in theory the Flatten with best fit seems to get close… but im not sure if its very precise… is there any documentation on what exactly is done by the different looptools?
There are some tutorials in youtube…
And there’s this old manual, thought not much changed since then.
The source code is also a valuable source of information.