#1153 New CAD workspace with hotkeys for super fast CAD operations

This commit is contained in:
Dion Moult
2022-04-30 15:50:40 +10:00
parent ac4679a376
commit 03831d440c
4 changed files with 76 additions and 9 deletions
@@ -1,5 +1,5 @@
# BlenderBIM Add-on - OpenBIM Blender Add-on
# Copyright (C) 2020, 2021 Dion Moult <dion@thinkmoult.com>
# Copyright (C) 2022 Dion Moult <dion@thinkmoult.com>
#
# This file is part of BlenderBIM Add-on.
#
@@ -17,16 +17,19 @@
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
import bpy
from . import operator
from . import operator, workspace
classes = (
operator.TCAutoVTX,
operator.CadTrimExtend,
workspace.CadHotkey,
)
def register():
pass
if not bpy.app.background:
bpy.utils.register_tool(workspace.CadTool, after={"builtin.transform"}, separator=True, group=True)
def unregister():
pass
if not bpy.app.background:
bpy.utils.unregister_tool(workspace.CadTool)
@@ -27,11 +27,12 @@ messages = {
}
class TCAutoVTX(bpy.types.Operator):
class CadTrimExtend(bpy.types.Operator):
"""Weld intersecting edges, project converging edges towards their intersection"""
bl_idname = "bim.vtx"
bl_label = "VTX autoVTX"
bl_idname = "bim.cad_trim_extend"
bl_label = "CAD Trim / Extend"
join_type: bpy.props.StringProperty()
@classmethod
def poll(cls, context):
@@ -44,7 +45,6 @@ class TCAutoVTX(bpy.types.Operator):
return {"CANCELLED"}
def execute(self, context):
# final attempt to enter unfragmented bm/mesh
# ghastly, but what can I do? it works with these
# fails without.
@@ -0,0 +1,64 @@
# BlenderBIM Add-on - OpenBIM Blender Add-on
# Copyright (C) 2022 Dion Moult <dion@thinkmoult.com>
#
# This file is part of BlenderBIM Add-on.
#
# BlenderBIM Add-on is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# BlenderBIM Add-on is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
import os
import bpy
import blenderbim.bim.module.type.prop as type_prop
from bpy.types import WorkSpaceTool
from blenderbim.bim.ifc import IfcStore
from blenderbim.bim.module.model.data import AuthoringData
class CadTool(WorkSpaceTool):
bl_space_type = "VIEW_3D"
bl_context_mode = "EDIT_MESH"
bl_idname = "bim.cad_tool"
bl_label = "CAD Tool"
bl_description = "Gives you CAD authoring related superpowers"
bl_icon = os.path.join(os.path.dirname(__file__), "ops.authoring.cad")
bl_widget = None
# https://docs.blender.org/api/current/bpy.types.KeyMapItems.html
bl_keymap = (
("bim.cad_hotkey", {"type": "E", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_E")]}),
)
def draw_settings(context, layout, tool):
row = layout.row(align=True)
row.label(text="", icon="EVENT_SHIFT")
row.label(text="Extend / Trim", icon="EVENT_E")
class CadHotkey(bpy.types.Operator):
bl_idname = "bim.cad_hotkey"
bl_label = "CAD Hotkey"
bl_options = {"REGISTER", "UNDO"}
hotkey: bpy.props.StringProperty()
def execute(self, context):
self.props = context.scene.BIMModelProperties
self.has_ifc_class = True
try:
self.has_ifc_class = bool(self.props.ifc_class)
except:
pass
getattr(self, f"hotkey_{self.hotkey}")()
return {"FINISHED"}
def hotkey_S_E(self):
bpy.ops.bim.cad_trim_extend(join_type="T")