2021-08-17 08:55:29 +10:00
|
|
|
# BlenderBIM Add-on - OpenBIM Blender Add-on
|
|
|
|
|
# Copyright (C) 2020, 2021 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/>.
|
|
|
|
|
|
2021-01-04 13:07:29 +11:00
|
|
|
import bpy
|
2021-08-19 22:26:00 +02:00
|
|
|
import blenderbim.bim.module.root.prop as root_prop
|
2021-01-04 13:07:29 +11:00
|
|
|
from bpy.types import Panel
|
2021-01-05 21:15:52 +11:00
|
|
|
from blenderbim.bim.ifc import IfcStore
|
2022-07-06 12:09:37 +02:00
|
|
|
from blenderbim.bim.helper import prop_with_search
|
2021-12-10 13:31:23 +11:00
|
|
|
from blenderbim.bim.module.root.data import IfcClassData
|
2021-01-04 13:07:29 +11:00
|
|
|
|
2021-01-12 15:12:53 +11:00
|
|
|
|
2021-01-04 13:07:29 +11:00
|
|
|
class BIM_PT_class(Panel):
|
2023-07-15 21:02:30 +10:00
|
|
|
bl_label = "Class"
|
2021-01-04 13:07:29 +11:00
|
|
|
bl_idname = "BIM_PT_class"
|
|
|
|
|
bl_space_type = "PROPERTIES"
|
|
|
|
|
bl_region_type = "WINDOW"
|
|
|
|
|
bl_context = "object"
|
2022-01-14 00:09:51 +01:00
|
|
|
bl_parent_id = "BIM_PT_object_metadata"
|
2023-07-15 21:02:30 +10:00
|
|
|
bl_options = {"HIDE_HEADER"}
|
2021-01-04 13:07:29 +11:00
|
|
|
|
2021-01-05 21:15:52 +11:00
|
|
|
@classmethod
|
|
|
|
|
def poll(cls, context):
|
2021-09-27 12:51:43 +02:00
|
|
|
if not context.active_object:
|
|
|
|
|
return False
|
2021-01-05 21:15:52 +11:00
|
|
|
return IfcStore.get_file()
|
|
|
|
|
|
2021-01-04 13:07:29 +11:00
|
|
|
def draw(self, context):
|
2021-12-10 13:31:23 +11:00
|
|
|
if not IfcClassData.is_loaded:
|
|
|
|
|
IfcClassData.load()
|
2021-01-04 13:07:29 +11:00
|
|
|
props = context.active_object.BIMObjectProperties
|
|
|
|
|
if props.ifc_definition_id:
|
2022-01-12 14:29:02 +11:00
|
|
|
if not IfcClassData.data["has_entity"]:
|
|
|
|
|
row = self.layout.row(align=True)
|
|
|
|
|
row.label(text="IFC Element Not Found")
|
|
|
|
|
row.operator("bim.unlink_object", icon="UNLINKED", text="")
|
|
|
|
|
return
|
2021-01-04 13:07:29 +11:00
|
|
|
if props.is_reassigning_class:
|
|
|
|
|
row = self.layout.row(align=True)
|
|
|
|
|
row.operator("bim.reassign_class", icon="CHECKMARK")
|
2021-08-05 21:14:18 +10:00
|
|
|
row.operator("bim.disable_reassign_class", icon="CANCEL", text="")
|
2021-08-19 22:26:00 +02:00
|
|
|
self.draw_class_dropdowns(
|
2021-10-21 11:28:49 +11:00
|
|
|
context,
|
2022-10-18 23:17:31 +02:00
|
|
|
root_prop.get_ifc_predefined_types(context.scene.BIMRootProperties, context),
|
2022-05-01 08:57:23 +10:00
|
|
|
is_reassigning_class=True,
|
2021-09-09 21:27:23 +10:00
|
|
|
)
|
2021-01-04 13:07:29 +11:00
|
|
|
else:
|
|
|
|
|
row = self.layout.row(align=True)
|
2022-01-12 14:29:02 +11:00
|
|
|
row.label(text=IfcClassData.data["name"])
|
|
|
|
|
op = row.operator("bim.select_ifc_class", text="", icon="RESTRICT_SELECT_OFF")
|
|
|
|
|
op.ifc_class = IfcClassData.data["ifc_class"]
|
2021-03-09 12:50:50 +11:00
|
|
|
row.operator("bim.unlink_object", icon="UNLINKED", text="")
|
2023-05-29 17:20:55 +10:00
|
|
|
if IfcClassData.data["can_reassign_class"]:
|
2021-04-22 14:00:18 +10:00
|
|
|
row.operator("bim.enable_reassign_class", icon="GREASEPENCIL", text="")
|
2021-01-04 13:07:29 +11:00
|
|
|
else:
|
2022-10-18 23:17:31 +02:00
|
|
|
ifc_predefined_types = root_prop.get_ifc_predefined_types(context.scene.BIMRootProperties, context)
|
2021-08-19 22:26:00 +02:00
|
|
|
self.draw_class_dropdowns(context, ifc_predefined_types)
|
2021-01-04 13:07:29 +11:00
|
|
|
row = self.layout.row(align=True)
|
|
|
|
|
op = row.operator("bim.assign_class")
|
2021-07-29 23:08:17 +02:00
|
|
|
op.ifc_class = context.scene.BIMRootProperties.ifc_class
|
2021-08-19 22:26:00 +02:00
|
|
|
op.predefined_type = context.scene.BIMRootProperties.ifc_predefined_type if ifc_predefined_types else ""
|
2021-07-29 23:08:17 +02:00
|
|
|
op.userdefined_type = context.scene.BIMRootProperties.ifc_userdefined_type
|
2021-01-04 13:07:29 +11:00
|
|
|
|
2022-05-01 08:57:23 +10:00
|
|
|
def draw_class_dropdowns(self, context, ifc_predefined_types, is_reassigning_class=False):
|
2021-07-29 23:08:17 +02:00
|
|
|
props = context.scene.BIMRootProperties
|
2022-07-03 22:37:41 +02:00
|
|
|
layout = self.layout
|
2022-05-01 08:57:23 +10:00
|
|
|
if not is_reassigning_class:
|
2022-07-03 22:37:41 +02:00
|
|
|
prop_with_search(layout, props, "ifc_product")
|
|
|
|
|
prop_with_search(layout, props, "ifc_class")
|
2021-08-19 22:26:00 +02:00
|
|
|
if ifc_predefined_types:
|
2022-07-03 22:37:41 +02:00
|
|
|
prop_with_search(layout, props, "ifc_predefined_type")
|
|
|
|
|
if props.ifc_predefined_type == "USERDEFINED":
|
|
|
|
|
row = layout.row()
|
|
|
|
|
row.prop(props, "ifc_userdefined_type")
|
2022-05-01 08:57:23 +10:00
|
|
|
if not is_reassigning_class:
|
2022-07-03 22:37:41 +02:00
|
|
|
prop_with_search(layout, props, "contexts")
|