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-20 16:53:34 +11:00
|
|
|
import os
|
2021-04-20 12:45:20 +10:00
|
|
|
from bpy.types import Panel, UIList
|
2021-01-05 21:15:52 +11:00
|
|
|
from blenderbim.bim.ifc import IfcStore
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BIM_PT_project(Panel):
|
|
|
|
|
bl_label = "IFC Project"
|
|
|
|
|
bl_idname = "BIM_PT_project"
|
|
|
|
|
bl_space_type = "PROPERTIES"
|
|
|
|
|
bl_region_type = "WINDOW"
|
|
|
|
|
bl_context = "scene"
|
|
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
self.layout.use_property_decorate = False
|
|
|
|
|
self.layout.use_property_split = True
|
2021-02-03 19:15:25 +11:00
|
|
|
props = context.scene.BIMProperties
|
2021-09-11 20:29:14 +10:00
|
|
|
pprops = context.scene.BIMProjectProperties
|
2021-01-05 21:15:52 +11:00
|
|
|
self.file = IfcStore.get_file()
|
2021-09-11 20:29:14 +10:00
|
|
|
if pprops.is_loading:
|
|
|
|
|
self.draw_load_ui(context)
|
|
|
|
|
elif self.file or props.ifc_file:
|
2021-01-20 16:53:34 +11:00
|
|
|
self.draw_project_ui(context)
|
2021-01-05 21:15:52 +11:00
|
|
|
else:
|
2021-01-20 16:53:34 +11:00
|
|
|
self.draw_create_project_ui(context)
|
|
|
|
|
|
2021-09-11 20:29:14 +10:00
|
|
|
def draw_load_ui(self, context):
|
|
|
|
|
pprops = context.scene.BIMProjectProperties
|
|
|
|
|
row = self.layout.row()
|
|
|
|
|
row.prop(pprops, "collection_mode")
|
|
|
|
|
row = self.layout.row()
|
2021-09-12 15:25:03 +10:00
|
|
|
row.prop(pprops, "filter_mode")
|
2021-09-12 16:02:08 +10:00
|
|
|
if pprops.filter_mode != "NONE":
|
2021-09-12 15:25:03 +10:00
|
|
|
self.layout.template_list(
|
|
|
|
|
"BIM_UL_filter_categories",
|
|
|
|
|
"",
|
|
|
|
|
pprops,
|
|
|
|
|
"filter_categories",
|
|
|
|
|
pprops,
|
|
|
|
|
"active_filter_category_index",
|
|
|
|
|
)
|
2021-09-12 15:42:59 +10:00
|
|
|
row = self.layout.row(align=True)
|
2021-09-12 15:25:03 +10:00
|
|
|
row.operator("bim.load_project_elements")
|
2021-09-12 15:42:59 +10:00
|
|
|
row.operator("bim.unload_project", text="", icon="CANCEL")
|
2021-09-11 20:29:14 +10:00
|
|
|
|
2021-01-20 16:53:34 +11:00
|
|
|
def draw_project_ui(self, context):
|
|
|
|
|
props = context.scene.BIMProperties
|
2021-03-14 20:38:13 +11:00
|
|
|
pprops = context.scene.BIMProjectProperties
|
2021-01-20 16:53:34 +11:00
|
|
|
row = self.layout.row(align=True)
|
2021-02-03 19:15:25 +11:00
|
|
|
row.label(text="IFC Filename", icon="FILE")
|
2021-01-21 21:55:08 +11:00
|
|
|
row.label(text=os.path.basename(props.ifc_file) or "No File Found")
|
2021-01-20 16:53:34 +11:00
|
|
|
|
2021-02-03 19:15:25 +11:00
|
|
|
if IfcStore.get_file():
|
2021-05-28 09:50:55 +10:00
|
|
|
row.prop(pprops, "is_authoring", icon="MODIFIER", text="")
|
|
|
|
|
if pprops.is_editing:
|
|
|
|
|
row.operator("bim.edit_header", icon="CHECKMARK", text="")
|
|
|
|
|
row.operator("bim.disable_editing_header", icon="CANCEL", text="")
|
|
|
|
|
else:
|
|
|
|
|
row.operator("bim.enable_editing_header", icon="GREASEPENCIL", text="")
|
|
|
|
|
|
2021-02-03 19:15:25 +11:00
|
|
|
row = self.layout.row(align=True)
|
|
|
|
|
row.label(text="IFC Schema", icon="FILE_CACHE")
|
|
|
|
|
row.label(text=IfcStore.get_file().schema)
|
2021-05-28 09:50:55 +10:00
|
|
|
|
|
|
|
|
if pprops.is_editing:
|
|
|
|
|
row = self.layout.row(align=True)
|
|
|
|
|
row.prop(pprops, "mvd")
|
|
|
|
|
|
|
|
|
|
row = self.layout.row(align=True)
|
|
|
|
|
row.prop(pprops, "author_name")
|
|
|
|
|
row = self.layout.row(align=True)
|
|
|
|
|
row.prop(pprops, "author_email")
|
|
|
|
|
|
|
|
|
|
row = self.layout.row(align=True)
|
|
|
|
|
row.prop(pprops, "organisation_name")
|
|
|
|
|
row = self.layout.row(align=True)
|
|
|
|
|
row.prop(pprops, "organisation_email")
|
|
|
|
|
|
|
|
|
|
row = self.layout.row(align=True)
|
|
|
|
|
row.prop(pprops, "authorisation")
|
|
|
|
|
else:
|
|
|
|
|
row = self.layout.row(align=True)
|
|
|
|
|
row.label(text="IFC MVD", icon="FILE_HIDDEN")
|
|
|
|
|
mvd = "".join(IfcStore.get_file().wrapped_data.header.file_description.description)
|
|
|
|
|
if "[" in mvd:
|
|
|
|
|
mvd = mvd.split("[")[1][0:-1]
|
|
|
|
|
row.label(text=mvd)
|
2021-02-03 19:15:25 +11:00
|
|
|
else:
|
|
|
|
|
row = self.layout.row(align=True)
|
|
|
|
|
row.label(text="File Not Loaded", icon="ERROR")
|
2021-01-20 16:53:34 +11:00
|
|
|
|
|
|
|
|
row = self.layout.row(align=True)
|
|
|
|
|
row.prop(props, "ifc_file", text="")
|
|
|
|
|
row.operator("bim.reload_ifc_file", icon="FILE_REFRESH", text="")
|
|
|
|
|
row.operator("bim.select_ifc_file", icon="FILE_FOLDER", text="")
|
|
|
|
|
|
|
|
|
|
row = self.layout.row(align=True)
|
|
|
|
|
row.prop(props, "schema_dir")
|
|
|
|
|
row.operator("bim.select_schema_dir", icon="FILE_FOLDER", text="")
|
|
|
|
|
|
|
|
|
|
row = self.layout.row(align=True)
|
|
|
|
|
row.prop(props, "data_dir")
|
|
|
|
|
row.operator("bim.select_data_dir", icon="FILE_FOLDER", text="")
|
|
|
|
|
|
|
|
|
|
def draw_create_project_ui(self, context):
|
|
|
|
|
props = context.scene.BIMProperties
|
|
|
|
|
row = self.layout.row()
|
|
|
|
|
row.prop(props, "export_schema")
|
|
|
|
|
row = self.layout.row()
|
|
|
|
|
row.prop(context.scene.unit_settings, "system")
|
|
|
|
|
row = self.layout.row()
|
|
|
|
|
row.prop(context.scene.unit_settings, "length_unit")
|
|
|
|
|
row = self.layout.row()
|
|
|
|
|
row.prop(props, "area_unit", text="Area Unit")
|
|
|
|
|
row = self.layout.row()
|
|
|
|
|
row.prop(props, "volume_unit", text="Volume Unit")
|
2021-09-11 20:29:14 +10:00
|
|
|
row = self.layout.row(align=True)
|
2021-01-20 16:53:34 +11:00
|
|
|
row.operator("bim.create_project")
|
2021-09-11 20:29:14 +10:00
|
|
|
row.operator("bim.load_project")
|
2021-04-20 12:45:20 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class BIM_PT_project_library(Panel):
|
|
|
|
|
bl_label = "IFC Project Library"
|
|
|
|
|
bl_idname = "BIM_PT_project_library"
|
2021-04-21 16:45:11 +10:00
|
|
|
bl_options = {"DEFAULT_CLOSED"}
|
2021-04-20 12:45:20 +10:00
|
|
|
bl_space_type = "PROPERTIES"
|
|
|
|
|
bl_region_type = "WINDOW"
|
|
|
|
|
bl_context = "scene"
|
|
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
self.layout.use_property_decorate = False
|
|
|
|
|
self.layout.use_property_split = True
|
|
|
|
|
self.props = context.scene.BIMProjectProperties
|
|
|
|
|
row = self.layout.row(align=True)
|
|
|
|
|
row.label(text=IfcStore.library_path or "No Library Loaded", icon="ASSET_MANAGER")
|
2021-04-20 13:51:41 +10:00
|
|
|
if IfcStore.library_file:
|
|
|
|
|
row.label(text=IfcStore.library_file.schema)
|
|
|
|
|
row.operator("bim.save_library_file", text="", icon="EXPORT")
|
2021-04-20 12:45:20 +10:00
|
|
|
row.operator("bim.select_library_file", icon="FILE_FOLDER", text="")
|
|
|
|
|
if IfcStore.library_file:
|
|
|
|
|
self.draw_library_ul()
|
|
|
|
|
|
|
|
|
|
def draw_library_ul(self):
|
|
|
|
|
if not self.props.library_elements:
|
|
|
|
|
row = self.layout.row()
|
|
|
|
|
row.label(text="No Assets Found", icon="ERROR")
|
|
|
|
|
return
|
|
|
|
|
row = self.layout.row(align=True)
|
|
|
|
|
row.label(text=self.props.active_library_element or "Top Level Assets")
|
|
|
|
|
if self.props.active_library_element:
|
|
|
|
|
row.operator("bim.rewind_library", icon="FRAME_PREV", text="")
|
|
|
|
|
row.operator("bim.refresh_library", icon="FILE_REFRESH", text="")
|
|
|
|
|
self.layout.template_list(
|
|
|
|
|
"BIM_UL_library",
|
|
|
|
|
"",
|
|
|
|
|
self.props,
|
|
|
|
|
"library_elements",
|
|
|
|
|
self.props,
|
|
|
|
|
"active_library_element_index",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BIM_UL_library(UIList):
|
|
|
|
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
|
|
|
|
if item:
|
|
|
|
|
row = layout.row(align=True)
|
|
|
|
|
if not item.ifc_definition_id:
|
|
|
|
|
op = row.operator("bim.change_library_element", text="", icon="DISCLOSURE_TRI_RIGHT", emboss=False)
|
|
|
|
|
op.element_name = item.name
|
|
|
|
|
row.label(text=item.name)
|
2021-04-20 13:51:41 +10:00
|
|
|
if (
|
2021-04-21 16:45:11 +10:00
|
|
|
item.ifc_definition_id
|
|
|
|
|
and IfcStore.library_file.schema != "IFC2X3"
|
|
|
|
|
and IfcStore.library_file.by_type("IfcProjectLibrary")
|
2021-04-20 13:51:41 +10:00
|
|
|
):
|
2021-04-21 16:45:11 +10:00
|
|
|
if item.is_declared:
|
|
|
|
|
op = row.operator("bim.unassign_library_declaration", text="", icon="KEYFRAME_HLT", emboss=False)
|
|
|
|
|
op.definition = item.ifc_definition_id
|
|
|
|
|
else:
|
|
|
|
|
op = row.operator("bim.assign_library_declaration", text="", icon="KEYFRAME", emboss=False)
|
|
|
|
|
op.definition = item.ifc_definition_id
|
|
|
|
|
if item.ifc_definition_id:
|
2021-09-01 00:01:44 +02:00
|
|
|
if item.is_appended:
|
|
|
|
|
row.label(text="", icon="CHECKMARK")
|
|
|
|
|
else:
|
|
|
|
|
op = row.operator("bim.append_library_element", text="", icon="APPEND_BLEND")
|
|
|
|
|
op.definition = item.ifc_definition_id
|
|
|
|
|
op.prop_index = data.get_library_element_index(item)
|
2021-09-12 15:25:03 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class BIM_UL_filter_categories(UIList):
|
|
|
|
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
|
|
|
|
if item:
|
|
|
|
|
row = layout.row(align=True)
|
|
|
|
|
row.label(text=f"{item.name} ({item.total_elements})")
|
|
|
|
|
row.prop(
|
|
|
|
|
item,
|
|
|
|
|
"is_selected",
|
|
|
|
|
icon="CHECKBOX_HLT" if item.is_selected else "CHECKBOX_DEHLT",
|
|
|
|
|
text="",
|
|
|
|
|
emboss=False,
|
|
|
|
|
)
|