New feature to validate IFC files against specification

This commit is contained in:
Dion Moult
2020-03-30 12:47:14 +11:00
parent df81490f86
commit c4cd6ef710
5 changed files with 27 additions and 2 deletions
@@ -48,6 +48,7 @@ if bpy is not None:
operator.SelectDataDir,
operator.SelectSchemaDir,
operator.SelectIfcFile,
operator.ValidateIfcFile,
operator.ExportIFC,
operator.ImportIFC,
operator.ColourByClass,
+3
View File
@@ -0,0 +1,3 @@
class IfcStore():
path = ''
file = None
@@ -8,6 +8,7 @@ import mathutils
import multiprocessing
from .helper import SIUnitHelper
from . import schema
from . import ifc
class MaterialCreator():
def __init__(self, ifc_import_settings):
@@ -477,9 +478,11 @@ class IfcImporter():
def load_file(self):
self.ifc_import_settings.logger.info('loading file {}'.format(self.ifc_import_settings.input_file))
self.file = ifcopenshell.open(self.ifc_import_settings.input_file)
ifc.IfcStore.file = self.file
def set_ifc_file(self):
bpy.context.scene.BIMProperties.ifc_file = self.ifc_import_settings.input_file
ifc.IfcStore.path = 'self.ifc_import_settings.input_file'
def calculate_unit_scale(self):
units = self.file.by_type('IfcUnitAssignment')[0]
@@ -11,6 +11,7 @@ from . import cut_ifc
from . import sheeter
from . import schema
from . import bcf
from . import ifc
from bpy_extras.io_utils import ImportHelper
from itertools import cycle
from mathutils import Vector, Matrix
@@ -993,6 +994,22 @@ 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)
if bpy.context.scene.BIMProperties.ifc_file \
and bpy.context.scene.BIMProperties.ifc_file != ifc.IfcStore.path:
ifc.IfcStore.file = ifcopenshell.open(bpy.context.scene.BIMProperties.ifc_file)
ifc.IfcStore.path = bpy.context.scene.BIMProperties.ifc_file
ifcopenshell.validate.validate(ifc.IfcStore.file, logger)
return {'FINISHED'}
class SelectDataDir(bpy.types.Operator):
bl_idname = "bim.select_data_dir"
bl_label = "Select Data Directory"
+3 -2
View File
@@ -441,8 +441,9 @@ class BIM_PT_bim(Panel):
row.operator("bim.select_data_dir", icon="FILE_FOLDER", text="")
row = layout.row(align=True)
row.prop(bim_properties, "ifc_file")
row.operator("bim.select_ifc_file", icon="FILE_FOLDER", text="")
row.prop(bim_properties, 'ifc_file')
row.operator('bim.validate_ifc_file', icon='CHECKMARK', text='')
row.operator('bim.select_ifc_file', icon='FILE_FOLDER', text='')
layout.label(text="IFC Categorisation:")