mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 05:17:58 +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.SelectDataDir,
|
||||||
operator.SelectSchemaDir,
|
operator.SelectSchemaDir,
|
||||||
operator.SelectIfcFile,
|
operator.SelectIfcFile,
|
||||||
operator.ValidateIfcFile,
|
|
||||||
operator.ExportIFC,
|
operator.ExportIFC,
|
||||||
operator.ImportIFC,
|
operator.ImportIFC,
|
||||||
operator.ColourByAttribute,
|
operator.ColourByAttribute,
|
||||||
@@ -221,7 +220,6 @@ if bpy is not None:
|
|||||||
ui.BIM_PT_drawings,
|
ui.BIM_PT_drawings,
|
||||||
ui.BIM_PT_schedules,
|
ui.BIM_PT_schedules,
|
||||||
ui.BIM_PT_sheets,
|
ui.BIM_PT_sheets,
|
||||||
ui.BIM_PT_bim,
|
|
||||||
ui.BIM_PT_psets,
|
ui.BIM_PT_psets,
|
||||||
ui.BIM_PT_classifications,
|
ui.BIM_PT_classifications,
|
||||||
ui.BIM_PT_document_information,
|
ui.BIM_PT_document_information,
|
||||||
|
|||||||
@@ -335,8 +335,6 @@ class IfcImporter:
|
|||||||
self.profile_code("Purge diffs")
|
self.profile_code("Purge diffs")
|
||||||
self.load_existing_rooted_elements()
|
self.load_existing_rooted_elements()
|
||||||
self.profile_code("Load existing rooted elements")
|
self.profile_code("Load existing rooted elements")
|
||||||
self.cache_file()
|
|
||||||
self.profile_code("Caching file")
|
|
||||||
self.load_file()
|
self.load_file()
|
||||||
self.profile_code("Loading file")
|
self.profile_code("Loading file")
|
||||||
self.set_ifc_file()
|
self.set_ifc_file()
|
||||||
@@ -1219,15 +1217,6 @@ class IfcImporter:
|
|||||||
with open(self.ifc_import_settings.diff_file, "r") as file:
|
with open(self.ifc_import_settings.diff_file, "r") as file:
|
||||||
self.diff = json.load(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):
|
def load_file(self):
|
||||||
self.ifc_import_settings.logger.info("loading file %s", self.ifc_import_settings.input_file)
|
self.ifc_import_settings.logger.info("loading file %s", self.ifc_import_settings.input_file)
|
||||||
extension = self.ifc_import_settings.input_file.split(".")[-1]
|
extension = self.ifc_import_settings.input_file.split(".")[-1]
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ from . import ui, operator
|
|||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
operator.CreateProject,
|
operator.CreateProject,
|
||||||
|
operator.ValidateIfcFile,
|
||||||
ui.BIM_PT_project,
|
ui.BIM_PT_project,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import bpy
|
import bpy
|
||||||
|
import logging
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import blenderbim.bim.module.project.create_file as create_file
|
import blenderbim.bim.module.project.create_file as create_file
|
||||||
import blenderbim.bim.module.context.add_context as add_context
|
import blenderbim.bim.module.context.add_context as add_context
|
||||||
@@ -57,3 +58,16 @@ class CreateProject(bpy.types.Operator):
|
|||||||
"relating_object": relating_object,
|
"relating_object": relating_object,
|
||||||
},
|
},
|
||||||
).execute()
|
).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 bpy.types import Panel
|
||||||
from blenderbim.bim.ifc import IfcStore
|
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_decorate = False
|
||||||
self.layout.use_property_split = True
|
self.layout.use_property_split = True
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
props = context.scene.BIMProperties
|
|
||||||
if self.file:
|
if self.file:
|
||||||
pass
|
self.draw_project_ui(context)
|
||||||
else:
|
else:
|
||||||
row = self.layout.row()
|
self.draw_create_project_ui(context)
|
||||||
row.prop(props, "export_schema")
|
|
||||||
row = self.layout.row()
|
def draw_project_ui(self, context):
|
||||||
row.prop(context.scene.unit_settings, "system")
|
props = context.scene.BIMProperties
|
||||||
row = self.layout.row()
|
row = self.layout.row(align=True)
|
||||||
row.prop(context.scene.unit_settings, "length_unit")
|
row.label(text="IFC File", icon="FILE")
|
||||||
row = self.layout.row()
|
row.label(text=os.path.basename(props.ifc_file))
|
||||||
row.prop(props, "area_unit", text="Area Unit")
|
|
||||||
row = self.layout.row()
|
row = self.layout.row(align=True)
|
||||||
row.prop(props, "volume_unit", text="Volume Unit")
|
row.label(text="IFC Schema", icon="FILE_CACHE")
|
||||||
row = self.layout.row()
|
row.label(text=IfcStore.get_file().schema)
|
||||||
row.operator("bim.create_project")
|
|
||||||
|
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"}
|
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):
|
class SelectDataDir(bpy.types.Operator):
|
||||||
bl_idname = "bim.select_data_dir"
|
bl_idname = "bim.select_data_dir"
|
||||||
bl_label = "Select Data Directory"
|
bl_label = "Select Data Directory"
|
||||||
@@ -2210,33 +2197,9 @@ class ReloadIfcFile(bpy.types.Operator):
|
|||||||
bl_label = "Reload IFC File"
|
bl_label = "Reload IFC File"
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
self.diff_ifc()
|
# TODO: reimplement. See #1222.
|
||||||
self.reimport_ifc(context)
|
|
||||||
return {"FINISHED"}
|
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):
|
class AddIfcFile(bpy.types.Operator):
|
||||||
bl_idname = "bim.add_ifc_file"
|
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")
|
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")
|
data_dir: StringProperty(default=os.path.join(cwd, "data") + os.path.sep, name="Data Directory")
|
||||||
ifc_file: StringProperty(name="IFC File")
|
ifc_file: StringProperty(name="IFC File")
|
||||||
ifc_cache: StringProperty(name="IFC Cache")
|
|
||||||
ifc_product: EnumProperty(items=getIfcProducts, name="Products", update=refreshClasses)
|
ifc_product: EnumProperty(items=getIfcProducts, name="Products", update=refreshClasses)
|
||||||
ifc_class: EnumProperty(items=getIfcClasses, name="Class", update=refreshPredefinedTypes)
|
ifc_class: EnumProperty(items=getIfcClasses, name="Class", update=refreshPredefinedTypes)
|
||||||
ifc_predefined_type: EnumProperty(items=getIfcPredefinedTypes, name="Predefined Type", default=None)
|
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")
|
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):
|
class BIM_PT_search(Panel):
|
||||||
bl_label = "IFC Search"
|
bl_label = "IFC Search"
|
||||||
bl_idname = "BIM_PT_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.select_pset", text="", icon="VIEWZOOM")
|
||||||
row.operator("bim.colour_by_pset", text="", icon="BRUSH_DATA")
|
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):
|
class BIM_PT_library(Panel):
|
||||||
|
|||||||
Reference in New Issue
Block a user