Fix misleading CAD Fillet hotkey, add some CAD hotkeys descriptions #5893

It was misleadingly displayed in UI as shift+v while it was shift+f.
This commit is contained in:
Andrej730
2024-12-20 18:41:01 +05:00
parent a79c4b1ace
commit f7395ccd52
4 changed files with 27 additions and 24 deletions
@@ -279,6 +279,7 @@ class CadArcFrom3Points(bpy.types.Operator):
bl_idname = "bim.cad_arc_from_3_points"
bl_label = "CAD Arc from 3 Points"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Create a points based arc from 3 selected points."
resolution: bpy.props.IntProperty(name="Arc Resolution", min=1, default=1)
only_recalculate_center: bpy.props.BoolProperty(name="Only Recalculate Center", default=False)
@@ -622,6 +623,7 @@ class AddIfcCircle(bpy.types.Operator):
class AddIfcArcIndexFillet(bpy.types.Operator):
bl_idname = "bim.add_ifcarcindex_fillet"
bl_label = "Add Arc Index Fillet"
bl_description = "Add a fillet for the selected vertices."
bl_options = {"REGISTER", "UNDO"}
radius: bpy.props.FloatProperty(name="Radius", default=0.1, subtype="DISTANCE")
+16 -24
View File
@@ -88,7 +88,8 @@ class CadTool(WorkSpaceTool):
obj = context.active_object
if not obj or not obj.data:
return
if hasattr(obj.data, "BIMMeshProperties") and obj.data.BIMMeshProperties.subshape_type == "PROFILE":
is_profile = tool.Geometry.is_profile_object_active()
if is_profile:
element = tool.Ifc.get_entity(obj)
if element:
if element.is_a("IfcProfileDef"):
@@ -123,7 +124,7 @@ class CadTool(WorkSpaceTool):
row, "Join", "S_T", "Joins two non-parallel paths at their intersection", ui_context
)
row = row if ui_context == "TOOL_HEADER" else layout.row(align=True)
add_layout_hotkey_operator(row, "Fillet", "S_V", "Fillet", ui_context)
add_layout_hotkey_operator(row, "Fillet", "S_F", bpy.ops.bim.add_ifcarcindex_fillet.__doc__, ui_context)
row = row if ui_context == "TOOL_HEADER" else layout.row(align=True)
add_layout_hotkey_operator(row, "Offset", "S_O", "Offset", ui_context)
row = row if ui_context == "TOOL_HEADER" else layout.row(align=True)
@@ -131,9 +132,9 @@ class CadTool(WorkSpaceTool):
row = row if ui_context == "TOOL_HEADER" else layout.row(align=True)
add_layout_hotkey_operator(row, "Circle", "S_C", "Circle", ui_context)
row = row if ui_context == "TOOL_HEADER" else layout.row(align=True)
add_layout_hotkey_operator(row, "3-Point Arc", "S_V", "3-Point Arc", ui_context)
add_layout_hotkey_operator(row, "3-Point Arc", "S_V", bpy.ops.bim.set_arc_index.__doc__, ui_context)
row = row if ui_context == "TOOL_HEADER" else layout.row(align=True)
add_layout_hotkey_operator(row, "Reset Vertex", "S_X", "Reset Vertex", ui_context)
add_layout_hotkey_operator(row, "Reset Vertex", "S_X", bpy.ops.bim.reset_vertex.__doc__, ui_context)
elif hasattr(obj.data, "BIMMeshProperties") and obj.data.BIMMeshProperties.subshape_type == "AXIS":
add_header_apply_button(layout, "Edit Axis", "bim.set_arc_index", "bim.set_arc_index", ui_context)
@@ -180,13 +181,13 @@ class CadTool(WorkSpaceTool):
row, "Join", "S_T", "Joins two non-parallel paths at their intersection", ui_context
)
row = row if ui_context == "TOOL_HEADER" else layout.row(align=True)
add_layout_hotkey_operator(row, "Fillet", "S_V", "Fillet", ui_context)
add_layout_hotkey_operator(row, "Fillet", "S_F", bpy.ops.bim.add_ifcarcindex_fillet.__doc__, ui_context)
row = row if ui_context == "TOOL_HEADER" else layout.row(align=True)
add_layout_hotkey_operator(row, "Offset", "S_O", "Offset", ui_context)
row = row if ui_context == "TOOL_HEADER" else layout.row(align=True)
add_layout_hotkey_operator(row, "2-Point Arc", "S_C", "2-Point Arc", ui_context)
row = row if ui_context == "TOOL_HEADER" else layout.row(align=True)
add_layout_hotkey_operator(row, "3-Point Arc", "S_V", "3-Point Arc", ui_context)
add_layout_hotkey_operator(row, "3-Point Arc", "S_V", bpy.ops.bim.cad_arc_from_3_points.__doc__, ui_context)
class CadHotkey(bpy.types.Operator):
@@ -208,12 +209,12 @@ class CadHotkey(bpy.types.Operator):
def draw(self, context):
props = context.scene.BIMCadProperties
if self.hotkey == "S_C":
if self.is_profile():
if tool.Geometry.is_profile_object_active():
row = self.layout.row()
row.prop(props, "radius")
elif self.hotkey == "S_F":
if not self.is_profile():
if not tool.Geometry.is_profile_object_active():
row = self.layout.row()
row.prop(props, "resolution")
row = self.layout.row()
@@ -224,7 +225,7 @@ class CadHotkey(bpy.types.Operator):
row.prop(props, "distance")
elif self.hotkey == "S_R":
if self.is_profile():
if tool.Geometry.is_profile_object_active():
row = self.layout.row()
row.prop(props, "x")
row = self.layout.row()
@@ -238,13 +239,13 @@ class CadHotkey(bpy.types.Operator):
self.layout.row().prop(props, "gable_roof_separate_verts")
elif self.hotkey == "S_V":
if not self.is_profile():
if not tool.Geometry.is_profile_object_active():
row = self.layout.row()
row.prop(props, "resolution")
def hotkey_S_C(self):
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
if self.is_profile():
if tool.Geometry.is_profile_object_active():
bpy.ops.bim.add_ifccircle(radius=self.props.radius / si_conversion)
else:
bpy.ops.bim.cad_arc_from_2_points()
@@ -254,7 +255,7 @@ class CadHotkey(bpy.types.Operator):
def hotkey_S_F(self):
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
if self.is_profile():
if tool.Geometry.is_profile_object_active():
bpy.ops.bim.add_ifcarcindex_fillet(radius=self.props.radius / si_conversion)
else:
bpy.ops.bim.cad_fillet(resolution=self.props.resolution, radius=self.props.radius / si_conversion)
@@ -276,7 +277,7 @@ class CadHotkey(bpy.types.Operator):
bpy.ops.bim.edit_extrusion_axis()
def hotkey_S_R(self):
if self.is_profile():
if tool.Geometry.is_profile_object_active():
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
bpy.ops.bim.add_rectangle(x=self.props.x / si_conversion, y=self.props.y / si_conversion)
elif (
@@ -292,24 +293,15 @@ class CadHotkey(bpy.types.Operator):
bpy.ops.bim.cad_mitre()
def hotkey_S_V(self):
if self.is_profile():
if tool.Geometry.is_profile_object_active():
bpy.ops.bim.set_arc_index()
else:
bpy.ops.bim.cad_arc_from_3_points(resolution=self.props.resolution)
def hotkey_S_X(self):
if self.is_profile():
if tool.Geometry.is_profile_object_active():
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.subshape_type == "PROFILE"
)
def add_header_apply_button(layout, text, apply_operator, cancel_operator, ui_context=""):
custom_icon = custom_icon_previews.get(text.upper().replace(" ", "_"), custom_icon_previews["IFC"]).icon_id
@@ -673,6 +673,7 @@ class EditExtrusionProfile(bpy.types.Operator, tool.Ifc.Operator):
class ResetVertex(bpy.types.Operator):
bl_idname = "bim.reset_vertex"
bl_label = "Reset Vertex"
bl_description = "Reset selected vertices group assignments (e.g. remove curve/circle)."
bl_options = {"REGISTER", "UNDO"}
@classmethod
@@ -697,6 +698,9 @@ class ResetVertex(bpy.types.Operator):
class SetArcIndex(bpy.types.Operator):
bl_idname = "bim.set_arc_index"
bl_label = "Set Arc Index"
bl_description = (
"Add an IfcArcIndex based 3 point arc for the selected vertices, add a vertex group to mark the created arc."
)
bl_options = {"REGISTER", "UNDO"}
@classmethod
+5
View File
@@ -947,6 +947,11 @@ class Geometry(bonsai.core.tool.Geometry):
def is_profile_based(cls, data: bpy.types.Mesh) -> bool:
return data.BIMMeshProperties.subshape_type == "PROFILE"
@classmethod
def is_profile_object_active(cls) -> bool:
obj = bpy.context.active_object
return bool(obj and (data := obj.data) and isinstance(data, bpy.types.Mesh) and cls.is_profile_based(data))
@classmethod
def is_swept_profile(cls, representation: ifcopenshell.entity_instance) -> bool:
return ifcopenshell.util.representation.resolve_representation(representation).RepresentationType in (