diff --git a/src/ifcblenderexport/io_export_ifc/__init__.py b/src/ifcblenderexport/io_export_ifc/__init__.py new file mode 100644 index 0000000000..d22c4def64 --- /dev/null +++ b/src/ifcblenderexport/io_export_ifc/__init__.py @@ -0,0 +1,71 @@ +bl_info = { + "name": "IfcBlenderExport", + "description": "Export files in the " + "Industry Foundation Classes (.ifc) file format", + "author": "Dion Moult, IfcOpenShell", + "blender": (2, 80, 0), + "location": "File > Export", + "tracker_url": "https://sourceforge.net/p/ifcopenshell/" + "_list/tickets?source=navbar", + "category": "Import-Export"} + +if "bpy" in locals(): + from importlib import reload + reload(export) + del reload + +import bpy +import time +from . import export +import os +from bpy.props import (StringProperty,) + +cwd = os.path.dirname(os.path.realpath(__file__)) + os.path.sep + +class ExportIFC(bpy.types.Operator): + bl_idname = "export.ifc" + bl_label = "Export .ifc file" + filename_ext = ".ifc" + #filter_glob: StringProperty(default="*.ifc", options={'HIDDEN'}) + filepath: StringProperty(subtype='FILE_PATH') + + def invoke(self, context, event): + if not self.filepath: + self.filepath = bpy.path.ensure_ext(bpy.data.filepath, ".ifc") + WindowManager = context.window_manager + WindowManager.fileselect_add(self) + return {'RUNNING_MODAL'} + + def execute(self, context): + print('# Starting export') + start = time.time() + ifc_export_settings = export.IfcExportSettings() + ifc_export_settings.bim_path = cwd + ifc_export_settings.output_file = bpy.path.ensure_ext(self.filepath, '.ifc') + ifc_parser = export.IfcParser(ifc_export_settings) + ifc_schema = export.IfcSchema(ifc_export_settings) + qto_calculator = export.QtoCalculator() + ifc_exporter = export.IfcExporter(ifc_export_settings, ifc_schema, ifc_parser, qto_calculator) + ifc_exporter.export() + print('# Export finished in {:.2f} seconds'.format(time.time() - start)) + return {'FINISHED'} + + +def menu_func(self, context): + self.layout.operator(ExportIFC.bl_idname, + text="Industry Foundation Classes (.ifc)") + +classes = (ExportIFC,) + +def register(): + for cls in classes: + bpy.utils.register_class(cls) + bpy.types.TOPBAR_MT_file_export.append(menu_func) + +def unregister(): + for cls in reversed(classes): + bpy.utils.unregister_class(cls) + bpy.types.TOPBAR_MT_file_export.remove(menu_func) + +if __name__ == "__main__": + register() diff --git a/src/ifcblenderexport/data/Pset_FurnitureTypeCommon/monkey.csv b/src/ifcblenderexport/io_export_ifc/data/Pset_FurnitureTypeCommon/monkey.csv similarity index 100% rename from src/ifcblenderexport/data/Pset_FurnitureTypeCommon/monkey.csv rename to src/ifcblenderexport/io_export_ifc/data/Pset_FurnitureTypeCommon/monkey.csv diff --git a/src/ifcblenderexport/data/Pset_FurnitureTypeCommon/monkeyoverride.csv b/src/ifcblenderexport/io_export_ifc/data/Pset_FurnitureTypeCommon/monkeyoverride.csv similarity index 100% rename from src/ifcblenderexport/data/Pset_FurnitureTypeCommon/monkeyoverride.csv rename to src/ifcblenderexport/io_export_ifc/data/Pset_FurnitureTypeCommon/monkeyoverride.csv diff --git a/src/ifcblenderexport/data/class/classifications.csv b/src/ifcblenderexport/io_export_ifc/data/class/classifications.csv similarity index 100% rename from src/ifcblenderexport/data/class/classifications.csv rename to src/ifcblenderexport/io_export_ifc/data/class/classifications.csv diff --git a/src/ifcblenderexport/data/class/references.csv b/src/ifcblenderexport/io_export_ifc/data/class/references.csv similarity index 100% rename from src/ifcblenderexport/data/class/references.csv rename to src/ifcblenderexport/io_export_ifc/data/class/references.csv diff --git a/src/ifcblenderexport/data/constraint/objectives.csv b/src/ifcblenderexport/io_export_ifc/data/constraint/objectives.csv similarity index 100% rename from src/ifcblenderexport/data/constraint/objectives.csv rename to src/ifcblenderexport/io_export_ifc/data/constraint/objectives.csv diff --git a/src/ifcblenderexport/data/doc/foo/bar.pdf b/src/ifcblenderexport/io_export_ifc/data/doc/foo/bar.pdf similarity index 100% rename from src/ifcblenderexport/data/doc/foo/bar.pdf rename to src/ifcblenderexport/io_export_ifc/data/doc/foo/bar.pdf diff --git a/src/ifcblenderexport/data/doc/test.pdf b/src/ifcblenderexport/io_export_ifc/data/doc/test.pdf similarity index 100% rename from src/ifcblenderexport/data/doc/test.pdf rename to src/ifcblenderexport/io_export_ifc/data/doc/test.pdf diff --git a/src/ifcblenderexport/export.py b/src/ifcblenderexport/io_export_ifc/export.py similarity index 98% rename from src/ifcblenderexport/export.py rename to src/ifcblenderexport/io_export_ifc/export.py index eff9da66e8..41eded9e91 100644 --- a/src/ifcblenderexport/export.py +++ b/src/ifcblenderexport/io_export_ifc/export.py @@ -63,8 +63,8 @@ class QtoCalculator(): return volume class IfcSchema(): - def __init__(self): - self.schema_dir = '/home/dion/Projects/IfcOpenShell/src/ifcblenderexport/schema/' + def __init__(self, ifc_export_settings): + self.schema_dir = '{}schema/'.format(ifc_export_settings.bim_path) self.property_file = ifcopenshell.open(self.schema_dir + 'IFC4_ADD2.ifc') self.psets = {} self.qtos = {} @@ -84,7 +84,7 @@ class IfcSchema(): class IfcParser(): def __init__(self, ifc_export_settings): - self.data_dir = '/home/dion/Projects/IfcOpenShell/src/ifcblenderexport/data/' + self.data_dir = '{}data/'.format(ifc_export_settings.bim_path) self.ifc_export_settings = ifc_export_settings @@ -672,8 +672,8 @@ class SIUnitHelper: class IfcExporter(): def __init__(self, ifc_export_settings, ifc_schema, ifc_parser, qto_calculator): - self.template_file = '/home/dion/Projects/IfcOpenShell/src/ifcblenderexport/template.ifc' - self.output_file = '/home/dion/Projects/IfcOpenShell/src/ifcblenderexport/output.ifc' + self.template_file = '{}template.ifc'.format(ifc_export_settings.bim_path) + self.output_file = ifc_export_settings.output_file self.ifc_export_settings = ifc_export_settings self.ifc_schema = ifc_schema self.ifc_parser = ifc_parser @@ -1245,17 +1245,9 @@ class IfcExporter(): class IfcExportSettings: def __init__(self): + self.bim_path = None + self.output_file = None self.has_representations = True self.has_quantities = True self.subcontexts = ['Axis', 'FootPrint', 'Reference', 'Body', 'Clearance', 'CoG'] self.generated_subcontexts = ['Box'] - -print('# Starting export') -start = time.time() -ifc_export_settings = IfcExportSettings() -ifc_parser = IfcParser(ifc_export_settings) -ifc_schema = IfcSchema() -qto_calculator = QtoCalculator() -ifc_exporter = IfcExporter(ifc_export_settings, ifc_schema, ifc_parser, qto_calculator) -ifc_exporter.export() -print('# Export finished in {:.2f} seconds'.format(time.time() - start)) diff --git a/src/ifcblenderexport/schema/IFC4_ADD2.ifc b/src/ifcblenderexport/io_export_ifc/schema/IFC4_ADD2.ifc similarity index 100% rename from src/ifcblenderexport/schema/IFC4_ADD2.ifc rename to src/ifcblenderexport/io_export_ifc/schema/IFC4_ADD2.ifc diff --git a/src/ifcblenderexport/schema/ifc_types_IFC4.json b/src/ifcblenderexport/io_export_ifc/schema/ifc_types_IFC4.json similarity index 100% rename from src/ifcblenderexport/schema/ifc_types_IFC4.json rename to src/ifcblenderexport/io_export_ifc/schema/ifc_types_IFC4.json diff --git a/src/ifcblenderexport/template.ifc b/src/ifcblenderexport/io_export_ifc/template.ifc similarity index 100% rename from src/ifcblenderexport/template.ifc rename to src/ifcblenderexport/io_export_ifc/template.ifc