The BIM Tool workspace now intelligently reflects the active object

This commit is contained in:
Dion Moult
2022-10-09 23:51:40 +11:00
parent 492a535312
commit c9214bf04a
2 changed files with 162 additions and 118 deletions
@@ -42,6 +42,7 @@ class AuthoringData:
cls.load_relating_types_browser() cls.load_relating_types_browser()
cls.data["is_voidable_element"] = cls.is_voidable_element() cls.data["is_voidable_element"] = cls.is_voidable_element()
cls.data["has_visible_openings"] = cls.has_visible_openings() cls.data["has_visible_openings"] = cls.has_visible_openings()
cls.data["active_class"] = cls.active_class()
@classmethod @classmethod
def load_ifc_classes(cls): def load_ifc_classes(cls):
@@ -69,6 +70,12 @@ class AuthoringData:
return True return True
return False return False
@classmethod
def active_class(cls):
element = tool.Ifc.get_entity(bpy.context.active_object)
if element:
return element.is_a()
@classmethod @classmethod
def ifc_classes(cls): def ifc_classes(cls):
results = [] results = []
@@ -134,8 +134,7 @@ class BimTool(WorkSpaceTool):
if relating_type_id.isnumeric(): if relating_type_id.isnumeric():
op.relating_type_id = int(relating_type_id) op.relating_type_id = int(relating_type_id)
if ifc_classes: if AuthoringData.data["active_class"] in ("IfcWall", "IfcWallStandardCase"):
if ifc_class == "IfcWallType":
row = layout.row(align=True) row = layout.row(align=True)
row.prop(data=props, property="extrusion_depth", text="Height") row.prop(data=props, property="extrusion_depth", text="Height")
op = row.operator("bim.change_extrusion_depth", icon="FILE_REFRESH", text="") op = row.operator("bim.change_extrusion_depth", icon="FILE_REFRESH", text="")
@@ -175,7 +174,7 @@ class BimTool(WorkSpaceTool):
row.label(text="", icon="EVENT_G") row.label(text="", icon="EVENT_G")
row.operator("bim.hotkey", text="Regen").hotkey = "S_G" row.operator("bim.hotkey", text="Regen").hotkey = "S_G"
row.operator("bim.join_wall", icon="X", text="").join_type = "" row.operator("bim.join_wall", icon="X", text="").join_type = ""
if ifc_class == "IfcSlabType": elif AuthoringData.data["active_class"] in ("IfcSlab", "IfcSlabStandardCase"):
if not context.active_object: if not context.active_object:
pass pass
elif context.active_object.mode == "OBJECT": elif context.active_object.mode == "OBJECT":
@@ -183,8 +182,14 @@ class BimTool(WorkSpaceTool):
row.label(text="", icon="EVENT_SHIFT") row.label(text="", icon="EVENT_SHIFT")
row.label(text="", icon="EVENT_E") row.label(text="", icon="EVENT_E")
row.operator("bim.hotkey", text="Edit Profile").hotkey = "S_E" row.operator("bim.hotkey", text="Edit Profile").hotkey = "S_E"
elif AuthoringData.data["active_class"] in (
if ifc_class in ("IfcColumnType", "IfcBeamType", "IfcMemberType"): "IfcColumn",
"IfcColumnStandardCase",
"IfcBeam",
"IfcBeamStandardCase",
"IfcMember",
"IfcMemberStandardCase",
):
row = layout.row(align=True) row = layout.row(align=True)
row.prop(data=props, property="cardinal_point", text="Axis") row.prop(data=props, property="cardinal_point", text="Axis")
op = row.operator("bim.change_cardinal_point", icon="FILE_REFRESH", text="") op = row.operator("bim.change_cardinal_point", icon="FILE_REFRESH", text="")
@@ -217,8 +222,12 @@ class BimTool(WorkSpaceTool):
row.label(text="", icon="EVENT_G") row.label(text="", icon="EVENT_G")
row.operator("bim.hotkey", text="Regen").hotkey = "S_G" row.operator("bim.hotkey", text="Regen").hotkey = "S_G"
row.operator("bim.extend_profile", icon="X", text="").join_type = "" row.operator("bim.extend_profile", icon="X", text="").join_type = ""
elif AuthoringData.data["active_class"] in (
if ifc_class in ("IfcWindowType", "IfcDoorType"): "IfcWindow",
"IfcWindowStandardCase",
"IfcDoor",
"IfcDoorStandardCase",
):
row = layout.row(align=True) row = layout.row(align=True)
row.prop(data=props, property="rl", text="RL") row.prop(data=props, property="rl", text="RL")
@@ -292,6 +301,12 @@ class Hotkey(bpy.types.Operator, tool.Ifc.Operator):
def _execute(self, context): def _execute(self, context):
self.props = context.scene.BIMModelProperties self.props = context.scene.BIMModelProperties
self.has_ifc_class = True self.has_ifc_class = True
self.active_class = None
element = tool.Ifc.get_entity(context.active_object)
if element:
self.active_class = element.is_a()
try: try:
self.has_ifc_class = bool(self.props.ifc_class) self.has_ifc_class = bool(self.props.ifc_class)
except: except:
@@ -321,79 +336,101 @@ class Hotkey(bpy.types.Operator, tool.Ifc.Operator):
bpy.ops.bim.add_constr_type_instance() bpy.ops.bim.add_constr_type_instance()
def hotkey_S_C(self): def hotkey_S_C(self):
if self.has_ifc_class and self.props.ifc_class == "IfcWallType": if self.active_class in ("IfcWall", "IfcWallStandardCase"):
bpy.ops.bim.align_wall(align_type="CENTERLINE") bpy.ops.bim.align_wall(align_type="CENTERLINE")
else: else:
bpy.ops.bim.align_product(align_type="CENTERLINE") bpy.ops.bim.align_product(align_type="CENTERLINE")
def hotkey_S_E(self): def hotkey_S_E(self):
if not self.has_ifc_class: if self.active_class in ("IfcWall", "IfcWallStandardCase"):
return
if self.props.ifc_class == "IfcWallType":
bpy.ops.bim.join_wall(join_type="T") bpy.ops.bim.join_wall(join_type="T")
elif self.props.ifc_class == "IfcSlabType": elif self.active_class in ("IfcSlab", "IfcSlabStandardCase"):
if not bpy.context.active_object: if not bpy.context.active_object:
pass pass
elif bpy.context.active_object.mode == "OBJECT": elif bpy.context.active_object.mode == "OBJECT":
bpy.ops.bim.enable_editing_extrusion_profile() bpy.ops.bim.enable_editing_extrusion_profile()
elif self.props.ifc_class in ["IfcColumnType", "IfcBeamType", "IfcMemberType"]: elif self.active_class in (
"IfcColumn",
"IfcColumnStandardCase",
"IfcBeam",
"IfcBeamStandardCase",
"IfcMember",
"IfcMemberStandardCase",
):
bpy.ops.bim.extend_profile(join_type="T") bpy.ops.bim.extend_profile(join_type="T")
def hotkey_S_F(self): def hotkey_S_F(self):
if self.has_ifc_class and self.props.ifc_class == "IfcWallType": if self.active_class in ("IfcWall", "IfcWallStandardCase"):
bpy.ops.bim.flip_wall() bpy.ops.bim.flip_wall()
def hotkey_S_G(self): def hotkey_S_G(self):
if self.has_ifc_class and self.props.ifc_class == "IfcWallType": if self.active_class in ("IfcWall", "IfcWallStandardCase"):
bpy.ops.bim.recalculate_wall() bpy.ops.bim.recalculate_wall()
elif self.props.ifc_class in ["IfcColumnType", "IfcBeamType", "IfcMemberType"]: elif self.active_class in (
"IfcColumn",
"IfcColumnStandardCase",
"IfcBeam",
"IfcBeamStandardCase",
"IfcMember",
"IfcMemberStandardCase",
):
bpy.ops.bim.recalculate_profile() bpy.ops.bim.recalculate_profile()
elif self.props.ifc_class in ["IfcWindowType", "IfcDoorType"]: elif self.active_class in ("IfcWindow", "IfcWindowStandardCase", "IfcDoor", "IfcDoorStandardCase"):
bpy.ops.bim.recalculate_fill() bpy.ops.bim.recalculate_fill()
def hotkey_S_M(self): def hotkey_S_M(self):
if self.has_ifc_class and self.props.ifc_class == "IfcWallType": if self.active_class in ("IfcWall", "IfcWallStandardCase"):
bpy.ops.bim.merge_wall() bpy.ops.bim.merge_wall()
def hotkey_S_R(self): def hotkey_S_R(self):
if not self.has_ifc_class: if self.active_class in ("IfcWall", "IfcWallStandardCase"):
return
if self.props.ifc_class == "IfcWallType":
bpy.ops.bim.rotate_90(axis="Z") bpy.ops.bim.rotate_90(axis="Z")
elif self.props.ifc_class == "IfcColumnType": elif self.active_class in ("IfcColumn", "IfcColumnStandardCase"):
bpy.ops.bim.rotate_90(axis="Z") bpy.ops.bim.rotate_90(axis="Z")
elif self.props.ifc_class in ["IfcBeamType", "IfcMemberType"]: elif self.active_class in ("IfcBeam", "IfcBeamStandardCase", "IfcMember", "IfcMemberStandardCase"):
bpy.ops.bim.rotate_90(axis="Y") bpy.ops.bim.rotate_90(axis="Y")
def hotkey_S_S(self): def hotkey_S_S(self):
if self.has_ifc_class and self.props.ifc_class == "IfcWallType": if self.active_class in ("IfcWall", "IfcWallStandardCase"):
bpy.ops.bim.split_wall() bpy.ops.bim.split_wall()
def hotkey_S_T(self): def hotkey_S_T(self):
if not self.has_ifc_class: if self.active_class in ("IfcWall", "IfcWallStandardCase"):
return
if self.props.ifc_class == "IfcWallType":
bpy.ops.bim.join_wall(join_type="L") bpy.ops.bim.join_wall(join_type="L")
elif self.props.ifc_class in ["IfcColumnType", "IfcBeamType", "IfcMemberType"]: elif self.active_class in (
"IfcColumn",
"IfcColumnStandardCase",
"IfcBeam",
"IfcBeamStandardCase",
"IfcMember",
"IfcMemberStandardCase",
):
bpy.ops.bim.extend_profile(join_type="L") bpy.ops.bim.extend_profile(join_type="L")
def hotkey_S_V(self): def hotkey_S_V(self):
if self.has_ifc_class and self.props.ifc_class == "IfcWallType": if self.active_class in ("IfcWall", "IfcWallStandardCase"):
bpy.ops.bim.align_wall(align_type="INTERIOR") bpy.ops.bim.align_wall(align_type="INTERIOR")
else: else:
bpy.ops.bim.align_product(align_type="POSITIVE") bpy.ops.bim.align_product(align_type="POSITIVE")
def hotkey_S_X(self): def hotkey_S_X(self):
if self.has_ifc_class and self.props.ifc_class == "IfcWallType": if self.active_class in ("IfcWall", "IfcWallStandardCase"):
if bpy.ops.bim.align_wall.poll(): if bpy.ops.bim.align_wall.poll():
bpy.ops.bim.align_wall(align_type="EXTERIOR") bpy.ops.bim.align_wall(align_type="EXTERIOR")
else: else:
bpy.ops.bim.align_product(align_type="NEGATIVE") bpy.ops.bim.align_product(align_type="NEGATIVE")
def hotkey_S_Y(self): def hotkey_S_Y(self):
if self.props.ifc_class == "IfcWallType": if self.active_class in ("IfcWall", "IfcWallStandardCase"):
bpy.ops.bim.join_wall(join_type="V") bpy.ops.bim.join_wall(join_type="V")
elif self.props.ifc_class in ["IfcColumnType", "IfcBeamType", "IfcMemberType"]: elif self.active_class in (
"IfcColumn",
"IfcColumnStandardCase",
"IfcBeam",
"IfcBeamStandardCase",
"IfcMember",
"IfcMemberStandardCase",
):
bpy.ops.bim.extend_profile(join_type="V") bpy.ops.bim.extend_profile(join_type="V")
def hotkey_S_O(self): def hotkey_S_O(self):