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.
I hope it's doable.
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.
I hope it's doable.
Using bmesh
Yes it is do-able.
Find all neighbouring faces
Remove them from the selection
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
selfaces.remove(f)
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:
break
f = selfaces.pop()
bmesh.update_edit_mesh(me)
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>
selfaces.remove(f)How are you choosing f?bm.faces.activecan 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 facef = 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? – batFINGER Jan 16 '19 at 12:03