Skip to content

Commit

Permalink
shift select now replaces the current selection
Browse files Browse the repository at this point in the history
  • Loading branch information
varkenvarken committed Nov 7, 2024
1 parent c4e366d commit c56be5a
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions facemap_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
bl_info = {
"name": "FacemapSelect",
"author": "Michel Anders (varkenvarken) with contribution from Andrew Leichter (aleichter) and Tyo79",
"version": (0, 0, 20241107141318),
"version": (0, 0, 20241107143407),
"blender": (4, 0, 0),
"location": "Edit mode 3d-view, Select- -> From facemap | Create facemap",
"description": "Select faces based on the active boolean facemap or create a new facemap",
Expand Down Expand Up @@ -142,7 +142,7 @@ def execute(self, context):
class FacemapSelections(bpy.types.Operator):
bl_idname = "mesh.facemap_selections"
bl_label = "Facemap Selections"
bl_description = "Select or deselect faces marked in the active facemap"
bl_description = "Select or deselect faces marked in the active facemap\nShift-Select replaces the selection"
param: bpy.props.StringProperty()

@classmethod
Expand All @@ -160,13 +160,21 @@ def execute(self, context):

if attribute_name in obj.data.attributes:
attribute = obj.data.attributes[attribute_name]
for poly in obj.data.polygons:
# if poly.select:
if attribute.data[poly.index].value:
if not self.__shift: # add to or remove from selection
for poly in obj.data.polygons:
# if poly.select:
if attribute.data[poly.index].value:
if self.param == "Select":
poly.select = True
if self.param == "Deselect":
poly.select = False
else: # set the selection (deselect act the same regardless whether shift is pressed)
for poly in obj.data.polygons:
if self.param == "Select":
poly.select = True
if self.param == "Deselect":
poly.select = attribute.data[poly.index].value
if self.param == "Deselect" and attribute.data[poly.index].value:
poly.select = False

edge = bpy.context.object.data.edges
for i in edge:
i.select = False
Expand All @@ -175,7 +183,10 @@ def execute(self, context):

return {"FINISHED"}


def invoke(self, context, event):
self.__shift = event.shift
return self.execute(context)

class FMS_OT_facemap_delete(bpy.types.Operator):
bl_idname = "fms.facemap_delete"
bl_label = "FacemapDelete"
Expand Down

0 comments on commit c56be5a

Please sign in to comment.