0
$\begingroup$

How can I reselect faces that is already selected? I need to get selected faces, do something else, and then reselect those faces again. I tried this ,but it doesn't work.

import bpy


OBJ = bpy.context.edit_object
DATA = OBJ.data
FACES = DATA.polygons

#Get selected faces
FACES = [f for f in FACES if f.select]

#Deselect to see if selection works.
bpy.ops.mesh.select_all(action='DESELECT')

#Select faces again
for S_FACES in FACES: 
    S_FACES.select = True

$\endgroup$
0
$\begingroup$

I generally assign the vertices of the face in a vertex group, and the i click on "select", but i don't think is what you needenter image description here

$\endgroup$
  • $\begingroup$ Well, I guess that is one way I could do it. Not sure why my code doesn't work though. This "FACE = [f for f in FACES if f.select]" will get the selected faces ,but after deselecting it looses it. $\endgroup$ – AFWS Jan 15 at 14:33
0
$\begingroup$

For this you can use bmesh:

import bpy
import bmesh


OBJ = bpy.context.edit_object
DATA = OBJ.data
BM = bmesh.from_edit_mesh(DATA)

#Get selected faces
FACES = [f for f in BM.faces if f.select]

#Deselect to see if selection works.
bpy.ops.mesh.select_all(action='DESELECT')

#Select faces again
for S_FACES in FACES:
    S_FACES.select = True

#updates viewport
bmesh.update_edit_mesh(DATA, True)

Hope this helps :)

$\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.