is it possible in blender v2.70 or with a python function deselect neighbours faces, so that they are alone ?

i'll upload a picture to understand what I mean.enter image description here

I hope it's doable.


Using bmesh

Yes it is do-able.

  • Add all selected faces to one set
  • Remove the active face from set
  • Find all neighbouring faces

    • Going by screenshot, this is any face that has an edge in the edge loop of each of its vertices is deselected.
  • Remove them from the selection

  • Repeat with next selected face until exhausted.

enter image description here Result of running on this grid with all selected

Test script, run in edit mode. Have a face as the active selection.

import bpy
import bmesh

context = bpy.context
ob = context.edit_object
me = ob.data
bm = bmesh.from_edit_mesh(me)

selfaces = set(f for f in bm.faces if f.select)

f = bm.select_history.active
while True:

    # find all "neighbours" of f
    desel = set(f for v in f.verts for el in v.link_edges for f in el.link_faces)
    for f in selfaces.intersection(desel):
        f.select = False
    selfaces -= desel
    if not selfaces:
    f = selfaces.pop()

Recommend checking out bmesh via the py console. With a mesh in edit mode

>>> import bmesh
>>> bm = bmesh.from_edit_mesh(C.object.data)
>>> bm
<BMesh(0x7f3308fde308), totvert=100, totedge=261, totface=162, totloop=486>
  • $\begingroup$ batFINGER you are a GOD ('o') $\endgroup$ – DevilSam Jan 15 '19 at 9:45
  • $\begingroup$ the script from blender.stackexchange.com/questions/128870/… i get "AttributeError: object has no attribute 'ensure_lookup_table'" in Blender v2.70, but if I put this in blender v2.79 it works, but than when i start the (Deselect Neighbours Faces script) I get the "Report Error KeyError: None" $\endgroup$ – DevilSam Jan 16 '19 at 11:22
  • $\begingroup$ Why blender 2.70? On the keyerror, most likely at selfaces.remove(f) How are you choosing f? bm.faces.active can be None, as can select history active. Trying to remove None from a list that doesn't contain it will throw that keyerror. This is why I implore you to test things out in the py console. For some random selected face f = selfaces.pop(randint(0, len(selfaces) - 1) will randomly remove one selected face (still selected) from list. Using this won't need that remove statement. Why the need to loop this? $\endgroup$ – batFINGER Jan 16 '19 at 12:03
  • $\begingroup$ i use blender v2.70 because the functions that work under 2.70 are also the new versions of compatible. here a video: streamable.com/j9ojn $\endgroup$ – DevilSam Jan 16 '19 at 12:57

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.