I'm trying to find a way to save selection faces, tried Vertex Group, the issue with Vertex Group is that it adds the faces that are marked by 4 vertices that are added to the Vertex Group, there are some cases were this doesn't apply, the image explains what I mean. So is there a way to save my selected faces, so I don't have to go through the whole process of reselecting them each time I need to do so?
If you check the image, I didn't assign the hatched faces to the Vertex Group, still when I select the Vertex Group, they get selected, I understand that they got selected because the four boundary vertices are assigned to the Vertex Group, I need to save only face selection, not vertex selection.
3 Answers
This is a limitation of the Vertex Groups system that has been an occasional nuisance.
The reason they are called "Vertex Groups" as opposed to "Face Groups", is the fact that selections of vertex don't unequivocally define groups of faces, since a vertex can belong to any arbitrary number of faces.
For Blender versions prior to 2.8# The way I generally solve this is by using material slots instead, if you don't mind the additional pollution in the materials list.
Go to Properties Window > Materials Tabs > Add New Material Slot button, and then with the desired faces selected press the Assign button.
Since they work on a per-face basis instead of single vertex, they can correctly define face groups. You can still assign materials independently, but you can't have a face belong to more than one slot unfortunately, so you may end up having multiple slots with the same material.
Different intersections of selections on non mutually exclusive groups of faces may require an exponentially growing number of slots which can quickly become unwieldy and unpractical.
For versions 2.8# and up Face Maps feature has been introduced, that allows saving arbitrary selections of faces into separate "Face Groups" layers much like Vertex Groups before them.
You can find them in the Object Data tab of the Properties Window for mesh objects
-
$\begingroup$ But that will change the material, right? $\endgroup$ Apr 23, 2016 at 22:41
-
$\begingroup$ Yeah I guess this is the best solution, in case I need several groups of faces to have the same material, I just have to copy, rename and keep same parameters. Thanks! $\endgroup$ Apr 23, 2016 at 22:50
-
$\begingroup$ Yeah, you can use the same material on multiple slots of the same object. You'll get some redundancy, but I guess it's better than nothing. $\endgroup$ Apr 24, 2016 at 0:46
Actually, in Blender 2.80 you can save face selections using the "Face Maps" grouping. It is located in the "Object Data" panel. It works the same as vertex groups but stores faces instead.
It's possible to store the selection state into a Vertex Color map.
The following script creates a vertex color map Selection
with a black face for every selected face and a white face for every non-selected. Strictly speaking this would be “every vertex of every polygon”. But the main difference to vertex groups is that each vertex appears multiple times in the vertex color map – once for every polygon that it's part of. So it's possible identify the faces by their vertices.
import bpy
obj = bpy.context.active_object
me = obj.data
bpy.ops.object.mode_set(mode='OBJECT')
col = me.vertex_colors.new('Selection')
for poly in me.polygons:
for l_ix in poly.loop_indices:
if poly.select:
col.data[l_ix].color = (0, 0, 0)
bpy.ops.object.mode_set(mode='EDIT')
The following script restores the selection from the vertex color map.
import bpy, bmesh
from mathutils import Color
bpy.context.tool_settings.mesh_select_mode = (False, False, True)
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')
bpy.ops.object.mode_set(mode='OBJECT')
obj = bpy.context.active_object
me = obj.data
bm = bmesh.new()
bm.from_mesh(me)
col = me.vertex_colors['Selection']
for (poly, bm_poly) in zip(me.polygons, bm.faces):
l_ix = poly.loop_indices[0]
# Only look at first vertex as all should have same color
if col.data[l_ix].color == Color((0, 0, 0)):
bm_poly.select_set(True)
bm.to_mesh(me)
bm.free()
bpy.ops.object.mode_set(mode='EDIT')
By adjusting the name of the vertex color map you can store multiple selections for every object.