Operator to clear parametric vertices when editing profile

This commit is contained in:
Dion Moult
2022-09-28 23:04:07 +10:00
parent cbf213952b
commit 766ffa71cd
3 changed files with 38 additions and 5 deletions
@@ -41,6 +41,7 @@ class CadTool(WorkSpaceTool):
("bim.cad_hotkey", {"type": "Q", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_Q")]}),
("bim.cad_hotkey", {"type": "T", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_T")]}),
("bim.cad_hotkey", {"type": "V", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_V")]}),
("bim.cad_hotkey", {"type": "X", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_X")]}),
)
def draw_settings(context, layout, tool):
@@ -62,6 +63,11 @@ class CadTool(WorkSpaceTool):
row.label(text="", icon="EVENT_T")
row.operator("bim.cad_hotkey", text="Mitre").hotkey = "S_T"
row = layout.row(align=True)
row.label(text="", icon="EVENT_SHIFT")
row.label(text="", icon="EVENT_O")
row.operator("bim.cad_hotkey", text="Offset").hotkey = "S_O"
row = layout.row(align=True)
row.label(text="", icon="EVENT_SHIFT")
row.label(text="", icon="EVENT_C")
@@ -74,8 +80,8 @@ class CadTool(WorkSpaceTool):
row = layout.row(align=True)
row.label(text="", icon="EVENT_SHIFT")
row.label(text="", icon="EVENT_O")
row.operator("bim.cad_hotkey", text="Offset").hotkey = "S_O"
row.label(text="", icon="EVENT_X")
row.operator("bim.reset_vertex", text="Reset Vertex")
else:
row = layout.row(align=True)
row.label(text="", icon="EVENT_SHIFT")
@@ -161,6 +167,10 @@ class CadHotkey(bpy.types.Operator):
else:
bpy.ops.bim.cad_arc_from_3_points(resolution=self.resolution)
def hotkey_S_X(self):
if self.is_profile():
bpy.ops.bim.reset_vertex()
def is_profile(self):
obj = bpy.context.active_object
return obj and obj.data and hasattr(obj.data, "BIMMeshProperties") and obj.data.BIMMeshProperties.is_profile
@@ -45,6 +45,7 @@ classes = (
slab.EditSketchExtrusionProfile,
slab.EnableEditingExtrusionProfile,
slab.EnableEditingSketchExtrusionProfile,
slab.ResetVertex,
slab.SetArcIndex,
prop.BIMModelProperties,
prop.ConstrTypeInfo,
@@ -724,6 +724,29 @@ class EditExtrusionProfile(bpy.types.Operator):
return value / self.unit_scale
class ResetVertex(bpy.types.Operator):
bl_idname = "bim.reset_vertex"
bl_label = "Reset Vertex"
@classmethod
def poll(cls, context):
obj = context.active_object
return bool(obj) and obj.type == "MESH"
def cancel_message(self, msg):
self.report({"WARNING"}, msg)
return {"CANCELLED"}
def execute(self, context):
obj = context.active_object
bpy.ops.object.mode_set(mode="OBJECT")
selected_vertices = [v.index for v in obj.data.vertices if v.select]
for group in obj.vertex_groups:
group.remove(selected_vertices)
bpy.ops.object.mode_set(mode="EDIT")
return {"FINISHED"}
class SetArcIndex(bpy.types.Operator):
bl_idname = "bim.set_arc_index"
bl_label = "Set Arc Index"
@@ -744,9 +767,8 @@ class SetArcIndex(bpy.types.Operator):
in_group = any([bool(obj.data.vertices[v].groups) for v in selected_vertices])
for group in obj.vertex_groups:
group.remove(selected_vertices)
if in_group is False:
group = obj.vertex_groups.new(name="IFCARCINDEX")
group.add(selected_vertices, 1, "REPLACE")
group = obj.vertex_groups.new(name="IFCARCINDEX")
group.add(selected_vertices, 1, "REPLACE")
bpy.ops.object.mode_set(mode="EDIT")
return {"FINISHED"}