Skip to content

Commit

Permalink
removed resdundant Select menu items. Eveything is available in the F…
Browse files Browse the repository at this point in the history
…aceMap panel
  • Loading branch information
varkenvarken committed Nov 7, 2024
1 parent c56be5a commit 9af1253
Showing 1 changed file with 4 additions and 53 deletions.
57 changes: 4 additions & 53 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, 20241107143407),
"version": (0, 0, 20241107144005),
"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 All @@ -40,44 +40,6 @@
from bpy.types import Panel, UIList


class FacemapSelect(bpy.types.Operator):
bl_idname = "mesh.facemap_select"
bl_label = "FacemapSelect"
bl_description = (
"Select faces based on active facemap (+ Shift add to current selection)"
)
bl_options = {"REGISTER", "UNDO"}

@classmethod
def poll(self, context):
return (
context.mode == "EDIT_MESH"
and context.active_object.type == "MESH"
and context.active_object.data.attributes.active is not None
and context.active_object.data.attributes.active.domain == "FACE"
and context.active_object.data.attributes.active.data_type == "BOOLEAN"
)

def execute(self, context):
if not self.__shift:
bpy.ops.mesh.select_all(action="DESELECT")
attribute_name = context.active_object.data.attributes.active.name
bpy.ops.object.editmode_toggle()
for polygon, facemap_attribute in zip(
context.active_object.data.polygons,
context.active_object.data.attributes[attribute_name].data,
):
polygon.select |= (
facemap_attribute.value
) # keeps polygons selected that already were
bpy.ops.object.editmode_toggle()
return {"FINISHED"}

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


class FacemapCreate(bpy.types.Operator):
bl_idname = "mesh.facemap_create"
bl_label = "FacemapCreate"
Expand Down Expand Up @@ -168,7 +130,7 @@ def execute(self, context):
poly.select = True
if self.param == "Deselect":
poly.select = False
else: # set the selection (deselect act the same regardless whether shift is pressed)
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 = attribute.data[poly.index].value
Expand All @@ -186,7 +148,8 @@ def execute(self, context):
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 Expand Up @@ -310,14 +273,7 @@ def draw(self, context):
sub.operator("mesh.facemap_selections", text="Deselect").param = "Deselect"


def menu_func(self, context):
self.layout.separator()
self.layout.operator(FacemapSelect.bl_idname, text="From facemap")
self.layout.operator(FacemapCreate.bl_idname, text="Create facemap")


classes = [
FacemapSelect,
FacemapCreate,
FMS_OT_facemap_delete,
FacemapAssign,
Expand All @@ -328,7 +284,6 @@ def menu_func(self, context):


classes = [
FacemapSelect,
FacemapCreate,
FMS_OT_facemap_delete,
FacemapAssign,
Expand All @@ -342,15 +297,11 @@ def register():
for cls in classes:
bpy.utils.register_class(cls)

bpy.types.VIEW3D_MT_select_edit_mesh.append(menu_func)


def unregister():
for cls in classes:
bpy.utils.unregister_class(cls)

bpy.types.VIEW3D_MT_select_edit_mesh.remove(menu_func)


if __name__ == "__main__":
register()

0 comments on commit 9af1253

Please sign in to comment.