fixed errors after 13309cb8c #3624

for example it was throwing errors when using WindowTool you selected a wall and it would try to assign current type to wall
This commit is contained in:
Andrej730
2023-08-25 11:21:43 +05:00
parent 1344cbc192
commit 356bc18078
2 changed files with 40 additions and 25 deletions
+5 -3
View File
@@ -27,7 +27,7 @@ from bpy.app.handlers import persistent
from blenderbim.bim.ifc import IfcStore
from blenderbim.bim.module.owner.prop import get_user_person, get_user_organisation
from blenderbim.bim.module.model.data import AuthoringData
from blenderbim.bim.module.model.workspace import LIST_OF_TOOLS
from blenderbim.bim.module.model.workspace import LIST_OF_TOOLS, TOOLS_TO_CLASSES_MAP
from mathutils import Vector
from math import cos, degrees
@@ -130,9 +130,11 @@ def update_bim_tool_props():
if element.is_a("IfcElementType") or element.is_a("IfcElement"):
element_type = ifcopenshell.util.element.get_type(element)
if element_type:
if current_tool.idname == "bim.bim_tool":
is_bim_tool = current_tool.idname == "bim.bim_tool"
if is_bim_tool:
props.ifc_class = element_type.is_a()
props.relating_type_id = str(element_type.id())
if is_bim_tool or TOOLS_TO_CLASSES_MAP.get(current_tool.idname) == element_type.is_a():
props.relating_type_id = str(element_type.id())
extrusion = tool.Model.get_extrusion(representation)
if not extrusion:
return
@@ -78,9 +78,11 @@ class WallTool(BimTool):
bl_description = "Create and edit walls"
bl_icon = os.path.join(os.path.dirname(__file__), "ops.authoring.wall")
bl_widget = None
ifc_element_type = "IfcWallType"
def draw_settings(context, layout, ws_tool):
BimToolUI.draw(context, layout, ifc_element_type="IfcWallType")
@classmethod
def draw_settings(cls, context, layout, ws_tool):
BimToolUI.draw(context, layout, ifc_element_type=cls.ifc_element_type)
class SlabTool(BimTool):
@@ -91,9 +93,11 @@ class SlabTool(BimTool):
bl_description = "Create and edit slabs"
bl_icon = os.path.join(os.path.dirname(__file__), "ops.authoring.slab")
bl_widget = None
ifc_element_type = "IfcSlabType"
def draw_settings(context, layout, ws_tool):
BimToolUI.draw(context, layout, ifc_element_type="IfcSlabType")
@classmethod
def draw_settings(cls, context, layout, ws_tool):
BimToolUI.draw(context, layout, ifc_element_type=cls.ifc_element_type)
class DoorTool(BimTool):
@@ -104,9 +108,11 @@ class DoorTool(BimTool):
bl_description = "Create and edit doors"
bl_icon = os.path.join(os.path.dirname(__file__), "ops.authoring.door")
bl_widget = None
ifc_element_type = "IfcDoorType"
def draw_settings(context, layout, ws_tool):
BimToolUI.draw(context, layout, ifc_element_type="IfcDoorType")
@classmethod
def draw_settings(cls, context, layout, ws_tool):
BimToolUI.draw(context, layout, ifc_element_type=cls.ifc_element_type)
class WindowTool(BimTool):
@@ -117,9 +123,11 @@ class WindowTool(BimTool):
bl_description = "Create and edit windows"
bl_icon = os.path.join(os.path.dirname(__file__), "ops.authoring.window")
bl_widget = None
ifc_element_type = "IfcWindowType"
def draw_settings(context, layout, ws_tool):
BimToolUI.draw(context, layout, ifc_element_type="IfcWindowType")
@classmethod
def draw_settings(cls, context, layout, ws_tool):
BimToolUI.draw(context, layout, ifc_element_type=cls.ifc_element_type)
class ColumnTool(BimTool):
@@ -130,9 +138,11 @@ class ColumnTool(BimTool):
bl_description = "Create and edit columns"
bl_icon = os.path.join(os.path.dirname(__file__), "ops.authoring.column")
bl_widget = None
ifc_element_type = "IfcColumnType"
def draw_settings(context, layout, ws_tool):
BimToolUI.draw(context, layout, ifc_element_type="IfcColumnType")
@classmethod
def draw_settings(cls, context, layout, ws_tool):
BimToolUI.draw(context, layout, ifc_element_type=cls.ifc_element_type)
class BeamTool(BimTool):
@@ -143,9 +153,11 @@ class BeamTool(BimTool):
bl_description = "Create and edit beams"
bl_icon = os.path.join(os.path.dirname(__file__), "ops.authoring.beam")
bl_widget = None
ifc_element_type = "IfcBeamType"
def draw_settings(context, layout, ws_tool):
BimToolUI.draw(context, layout, ifc_element_type="IfcBeamType")
@classmethod
def draw_settings(cls, context, layout, ws_tool):
BimToolUI.draw(context, layout, ifc_element_type=cls.ifc_element_type)
class DuctTool(BimTool):
@@ -156,9 +168,11 @@ class DuctTool(BimTool):
bl_description = "Create and edit ducks" # No, not a typo.
bl_icon = os.path.join(os.path.dirname(__file__), "ops.authoring.duct")
bl_widget = None
ifc_element_type = "IfcDuctSegmentType"
def draw_settings(context, layout, ws_tool):
BimToolUI.draw(context, layout, ifc_element_type="IfcDuctSegmentType")
@classmethod
def draw_settings(cls, context, layout, ws_tool):
BimToolUI.draw(context, layout, ifc_element_type=cls.ifc_element_type)
class PipeTool(BimTool):
@@ -169,9 +183,11 @@ class PipeTool(BimTool):
bl_description = "Create and edit pipes"
bl_icon = os.path.join(os.path.dirname(__file__), "ops.authoring.pipe")
bl_widget = None
ifc_element_type = "IfcPipeSegmentType"
def draw_settings(context, layout, ws_tool):
BimToolUI.draw(context, layout, ifc_element_type="IfcPipeSegmentType")
@classmethod
def draw_settings(cls, context, layout, ws_tool):
BimToolUI.draw(context, layout, ifc_element_type=cls.ifc_element_type)
def add_layout_hotkey_operator(layout, text, hotkey, description):
@@ -394,9 +410,7 @@ class BimToolUI:
else:
row.operator("bim.show_openings", icon="HIDE_OFF", text="")
if AuthoringData.data["active_class"] in (
"IfcOpeningElement",
):
if AuthoringData.data["active_class"] in ("IfcOpeningElement",):
if len(context.selected_objects) == 2:
row = cls.layout.row(align=True)
row.label(text="", icon="EVENT_SHIFT")
@@ -737,9 +751,7 @@ class Hotkey(bpy.types.Operator, tool.Ifc.Operator):
self.props.z = self.z
def hotkey_S_L(self):
if AuthoringData.data["active_class"] in (
"IfcOpeningElement",
):
if AuthoringData.data["active_class"] in ("IfcOpeningElement",):
if len(bpy.context.selected_objects) == 2:
bpy.ops.bim.clone_opening()
@@ -764,3 +776,4 @@ class Hotkey(bpy.types.Operator, tool.Ifc.Operator):
LIST_OF_TOOLS = [cls.bl_idname for cls in (BimTool.__subclasses__() + [BimTool])]
TOOLS_TO_CLASSES_MAP = {cls.bl_idname: cls.ifc_element_type for cls in BimTool.__subclasses__()}