mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-09 21:53:40 +00:00
New feature to validate IFC files against specification
This commit is contained in:
@@ -48,6 +48,7 @@ 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.ColourByClass,
|
operator.ColourByClass,
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
class IfcStore():
|
||||||
|
path = ''
|
||||||
|
file = None
|
||||||
@@ -8,6 +8,7 @@ import mathutils
|
|||||||
import multiprocessing
|
import multiprocessing
|
||||||
from .helper import SIUnitHelper
|
from .helper import SIUnitHelper
|
||||||
from . import schema
|
from . import schema
|
||||||
|
from . import ifc
|
||||||
|
|
||||||
class MaterialCreator():
|
class MaterialCreator():
|
||||||
def __init__(self, ifc_import_settings):
|
def __init__(self, ifc_import_settings):
|
||||||
@@ -477,9 +478,11 @@ class IfcImporter():
|
|||||||
def load_file(self):
|
def load_file(self):
|
||||||
self.ifc_import_settings.logger.info('loading file {}'.format(self.ifc_import_settings.input_file))
|
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)
|
self.file = ifcopenshell.open(self.ifc_import_settings.input_file)
|
||||||
|
ifc.IfcStore.file = self.file
|
||||||
|
|
||||||
def set_ifc_file(self):
|
def set_ifc_file(self):
|
||||||
bpy.context.scene.BIMProperties.ifc_file = self.ifc_import_settings.input_file
|
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):
|
def calculate_unit_scale(self):
|
||||||
units = self.file.by_type('IfcUnitAssignment')[0]
|
units = self.file.by_type('IfcUnitAssignment')[0]
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ from . import cut_ifc
|
|||||||
from . import sheeter
|
from . import sheeter
|
||||||
from . import schema
|
from . import schema
|
||||||
from . import bcf
|
from . import bcf
|
||||||
|
from . import ifc
|
||||||
from bpy_extras.io_utils import ImportHelper
|
from bpy_extras.io_utils import ImportHelper
|
||||||
from itertools import cycle
|
from itertools import cycle
|
||||||
from mathutils import Vector, Matrix
|
from mathutils import Vector, Matrix
|
||||||
@@ -993,6 +994,22 @@ 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)
|
||||||
|
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):
|
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"
|
||||||
|
|||||||
@@ -441,8 +441,9 @@ class BIM_PT_bim(Panel):
|
|||||||
row.operator("bim.select_data_dir", icon="FILE_FOLDER", text="")
|
row.operator("bim.select_data_dir", icon="FILE_FOLDER", text="")
|
||||||
|
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.prop(bim_properties, "ifc_file")
|
row.prop(bim_properties, 'ifc_file')
|
||||||
row.operator("bim.select_ifc_file", icon="FILE_FOLDER", text="")
|
row.operator('bim.validate_ifc_file', icon='CHECKMARK', text='')
|
||||||
|
row.operator('bim.select_ifc_file', icon='FILE_FOLDER', text='')
|
||||||
|
|
||||||
layout.label(text="IFC Categorisation:")
|
layout.label(text="IFC Categorisation:")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user