0
$\begingroup$

I am trying to extend an existing script that scans meshes for certain conditions, like poles, non-manifold edges and the like.

When a mirror modifier is present on the mesh, all vertices on the symmetry line fall therefore under the conditions non-manifold and 3-valence pole (in case of quad meshes, at any rate).

I want to select the points on that symmetry axis and gather them in an array, to remove them from the other checks' results.

I am uncertain how to best do that, if anybody has suggestions, I would be very grateful for those.

$\endgroup$
  • $\begingroup$ Edges on the symmetry axis should have only one linked face (generally). So you need these + checking they are on the symmetry plane. $\endgroup$ – lemon Aug 14 at 8:44
  • $\begingroup$ is there a dedicated operator for that, or do I need to take the origin of the mirror modifier and select verts that lie on that coordinate? $\endgroup$ – Ben Aug 14 at 8:51
  • $\begingroup$ You'll need to code that. Bmesh to have an easy way to identify edges linked to one face + mathutils.geometry.distance_point_to_plane as the mirror basically corresponds to a plane axis. $\endgroup$ – lemon Aug 14 at 8:56
  • $\begingroup$ And assuming there is no modifiers previously to the mirror? Is that enough info or do you need more information? $\endgroup$ – lemon Aug 14 at 9:17
  • $\begingroup$ I am trying to find the necessary parameters and how to get them. $\endgroup$ – Ben Aug 14 at 9:44
1
$\begingroup$

A simple code to retrieve vertices that are on the standard (centered X axis) symmetry plane.

This assumes to be without other modifiers before the mirror.

Principle:

  • Get all edges that have only one linked face (border edges)
  • Test their distance to the symmetry plane under a limit which should be similar to the merge limit of the mirror modifier

The code:

import bpy
import bmesh
from mathutils import Vector, geometry

obj = bpy.context.object

bm = bmesh.new()
bm.from_mesh( obj.data )

bm.verts.ensure_lookup_table()
bm.edges.ensure_lookup_table()

# If mirrored on self with X axis
center = Vector( (0,0,0) )
axis = Vector( (1,0,0) )

limit = 0.00001

border_verts = set()

for e in [e for e in bm.edges if len(e.link_faces) == 1]:
    if geometry.distance_point_to_plane( e.verts[0].co, center, axis ) < limit:
        border_verts.add( e.verts[0] )
    if geometry.distance_point_to_plane( e.verts[1].co, center, axis ) < limit:
        border_verts.add( e.verts[1] )

print( len( border_verts ) )
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.