mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
WIP implement project UI to show basic project metadata. See #1222.
This commit is contained in:
@@ -46,7 +46,6 @@ if bpy is not None:
|
||||
operator.SelectDataDir,
|
||||
operator.SelectSchemaDir,
|
||||
operator.SelectIfcFile,
|
||||
operator.ValidateIfcFile,
|
||||
operator.ExportIFC,
|
||||
operator.ImportIFC,
|
||||
operator.ColourByAttribute,
|
||||
@@ -221,7 +220,6 @@ if bpy is not None:
|
||||
ui.BIM_PT_drawings,
|
||||
ui.BIM_PT_schedules,
|
||||
ui.BIM_PT_sheets,
|
||||
ui.BIM_PT_bim,
|
||||
ui.BIM_PT_psets,
|
||||
ui.BIM_PT_classifications,
|
||||
ui.BIM_PT_document_information,
|
||||
|
||||
@@ -335,8 +335,6 @@ class IfcImporter:
|
||||
self.profile_code("Purge diffs")
|
||||
self.load_existing_rooted_elements()
|
||||
self.profile_code("Load existing rooted elements")
|
||||
self.cache_file()
|
||||
self.profile_code("Caching file")
|
||||
self.load_file()
|
||||
self.profile_code("Loading file")
|
||||
self.set_ifc_file()
|
||||
@@ -1219,15 +1217,6 @@ class IfcImporter:
|
||||
with open(self.ifc_import_settings.diff_file, "r") as file:
|
||||
self.diff = json.load(file)
|
||||
|
||||
def cache_file(self):
|
||||
destination = os.path.join(bpy.context.scene.BIMProperties.data_dir, "cache", "ifc")
|
||||
copythread = FileCopy(self.ifc_import_settings.input_file, destination)
|
||||
bpy.context.scene.BIMProperties.ifc_cache = os.path.join(
|
||||
destination, os.path.basename(self.ifc_import_settings.input_file)
|
||||
)
|
||||
copythread.start()
|
||||
copythread.join()
|
||||
|
||||
def load_file(self):
|
||||
self.ifc_import_settings.logger.info("loading file %s", self.ifc_import_settings.input_file)
|
||||
extension = self.ifc_import_settings.input_file.split(".")[-1]
|
||||
|
||||
@@ -3,6 +3,7 @@ from . import ui, operator
|
||||
|
||||
classes = (
|
||||
operator.CreateProject,
|
||||
operator.ValidateIfcFile,
|
||||
ui.BIM_PT_project,
|
||||
)
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import bpy
|
||||
import logging
|
||||
import ifcopenshell
|
||||
import blenderbim.bim.module.project.create_file as create_file
|
||||
import blenderbim.bim.module.context.add_context as add_context
|
||||
@@ -57,3 +58,16 @@ class CreateProject(bpy.types.Operator):
|
||||
"relating_object": relating_object,
|
||||
},
|
||||
).execute()
|
||||
|
||||
|
||||
class ValidateIfcFile(bpy.types.Operator):
|
||||
bl_idname = "bim.validate_ifc_file"
|
||||
bl_label = "Validate IFC File"
|
||||
|
||||
def execute(self, context):
|
||||
import ifcopenshell.validate
|
||||
|
||||
logger = logging.getLogger("validate")
|
||||
logger.setLevel(logging.DEBUG)
|
||||
ifcopenshell.validate.validate(IfcStore.get_file(), logger)
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
from bpy.types import Panel
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
|
||||
@@ -13,19 +14,46 @@ class BIM_PT_project(Panel):
|
||||
self.layout.use_property_decorate = False
|
||||
self.layout.use_property_split = True
|
||||
self.file = IfcStore.get_file()
|
||||
props = context.scene.BIMProperties
|
||||
if self.file:
|
||||
pass
|
||||
self.draw_project_ui(context)
|
||||
else:
|
||||
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")
|
||||
row = self.layout.row()
|
||||
row.operator("bim.create_project")
|
||||
self.draw_create_project_ui(context)
|
||||
|
||||
def draw_project_ui(self, context):
|
||||
props = context.scene.BIMProperties
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text="IFC File", icon="FILE")
|
||||
row.label(text=os.path.basename(props.ifc_file))
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text="IFC Schema", icon="FILE_CACHE")
|
||||
row.label(text=IfcStore.get_file().schema)
|
||||
|
||||
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.validate_ifc_file", icon="CHECKMARK", 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")
|
||||
row = self.layout.row()
|
||||
row.operator("bim.create_project")
|
||||
|
||||
@@ -1220,19 +1220,6 @@ class SelectIfcFile(bpy.types.Operator):
|
||||
return {"RUNNING_MODAL"}
|
||||
|
||||
|
||||
class ValidateIfcFile(bpy.types.Operator):
|
||||
bl_idname = "bim.validate_ifc_file"
|
||||
bl_label = "Validate IFC File"
|
||||
|
||||
def execute(self, context):
|
||||
import ifcopenshell.validate
|
||||
|
||||
logger = logging.getLogger("validate")
|
||||
logger.setLevel(logging.DEBUG)
|
||||
ifcopenshell.validate.validate(ifc.IfcStore.get_file(), logger)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class SelectDataDir(bpy.types.Operator):
|
||||
bl_idname = "bim.select_data_dir"
|
||||
bl_label = "Select Data Directory"
|
||||
@@ -2210,33 +2197,9 @@ class ReloadIfcFile(bpy.types.Operator):
|
||||
bl_label = "Reload IFC File"
|
||||
|
||||
def execute(self, context):
|
||||
self.diff_ifc()
|
||||
self.reimport_ifc(context)
|
||||
# TODO: reimplement. See #1222.
|
||||
return {"FINISHED"}
|
||||
|
||||
def diff_ifc(self):
|
||||
import ifcdiff
|
||||
|
||||
temp_file = tempfile.NamedTemporaryFile(delete=False)
|
||||
temp_file.close()
|
||||
ifc_diff = ifcdiff.IfcDiff(
|
||||
bpy.context.scene.BIMProperties.ifc_cache, bpy.context.scene.BIMProperties.ifc_file, temp_file.name
|
||||
)
|
||||
ifc_diff.diff()
|
||||
ifc_diff.export()
|
||||
bpy.context.scene.BIMProperties.diff_json_file = temp_file.name
|
||||
|
||||
def reimport_ifc(self, context):
|
||||
logger = logging.getLogger("ImportIFC")
|
||||
logging.basicConfig(
|
||||
filename=bpy.context.scene.BIMProperties.data_dir + "process.log", filemode="a", level=logging.DEBUG
|
||||
)
|
||||
ifc_import_settings = import_ifc.IfcImportSettings.factory(
|
||||
context, bpy.context.scene.BIMProperties.ifc_file, logger
|
||||
)
|
||||
ifc_importer = import_ifc.IfcImporter(ifc_import_settings)
|
||||
ifc_importer.execute()
|
||||
|
||||
|
||||
class AddIfcFile(bpy.types.Operator):
|
||||
bl_idname = "bim.add_ifc_file"
|
||||
|
||||
@@ -996,7 +996,6 @@ class BIMProperties(PropertyGroup):
|
||||
schema_dir: StringProperty(default=os.path.join(cwd, "schema") + os.path.sep, name="Schema Directory")
|
||||
data_dir: StringProperty(default=os.path.join(cwd, "data") + os.path.sep, name="Data Directory")
|
||||
ifc_file: StringProperty(name="IFC File")
|
||||
ifc_cache: StringProperty(name="IFC Cache")
|
||||
ifc_product: EnumProperty(items=getIfcProducts, name="Products", update=refreshClasses)
|
||||
ifc_class: EnumProperty(items=getIfcClasses, name="Class", update=refreshPredefinedTypes)
|
||||
ifc_predefined_type: EnumProperty(items=getIfcPredefinedTypes, name="Predefined Type", default=None)
|
||||
|
||||
@@ -732,46 +732,6 @@ class BIM_PT_text(Panel):
|
||||
row.prop(variable, "prop_key")
|
||||
|
||||
|
||||
class BIM_PT_bim(Panel):
|
||||
bl_label = "Building Information Modeling"
|
||||
bl_idname = "BIM_PT_bim"
|
||||
bl_space_type = "PROPERTIES"
|
||||
bl_region_type = "WINDOW"
|
||||
bl_context = "scene"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.use_property_split = True
|
||||
|
||||
scene = context.scene
|
||||
bim_properties = scene.BIMProperties
|
||||
|
||||
layout.label(text="System Setup:")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(bim_properties, "schema_dir")
|
||||
row.operator("bim.select_schema_dir", icon="FILE_FOLDER", text="")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(bim_properties, "data_dir")
|
||||
row.operator("bim.select_data_dir", icon="FILE_FOLDER", text="")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(bim_properties, "ifc_file")
|
||||
row.operator("bim.reload_ifc_file", icon="FILE_REFRESH", text="")
|
||||
row.operator("bim.validate_ifc_file", icon="CHECKMARK", text="")
|
||||
row.operator("bim.select_ifc_file", icon="FILE_FOLDER", text="")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(bim_properties, "ifc_cache")
|
||||
|
||||
layout.label(text="IFC Categorisation:")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.operator("bim.select_class")
|
||||
row.operator("bim.select_type")
|
||||
|
||||
|
||||
class BIM_PT_search(Panel):
|
||||
bl_label = "IFC Search"
|
||||
bl_idname = "BIM_PT_search"
|
||||
@@ -811,6 +771,9 @@ class BIM_PT_search(Panel):
|
||||
row.operator("bim.select_pset", text="", icon="VIEWZOOM")
|
||||
row.operator("bim.colour_by_pset", text="", icon="BRUSH_DATA")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.operator("bim.select_class")
|
||||
row.operator("bim.select_type")
|
||||
|
||||
|
||||
class BIM_PT_library(Panel):
|
||||
|
||||
Reference in New Issue
Block a user