New GUI to run IFCCOBie using the BlenderBIM Add-on

This commit is contained in:
Dion Moult
2020-07-23 17:02:48 +10:00
parent 7d4c760332
commit 5fbb324d7d
6 changed files with 123 additions and 22 deletions
@@ -163,6 +163,8 @@ if bpy is not None:
operator.GuessQuantity,
operator.ExecuteBIMTester,
operator.BIMTesterPurge,
operator.SelectCobieIfcFile,
operator.ExecuteIfcCobie,
prop.StrProperty,
prop.Variable,
prop.Role,
@@ -222,6 +224,7 @@ if bpy is not None:
ui.BIM_PT_library,
ui.BIM_PT_gis,
ui.BIM_PT_diff,
ui.BIM_PT_cobie,
ui.BIM_PT_mvd,
ui.BIM_PT_material,
ui.BIM_PT_mesh,
@@ -672,7 +672,7 @@ class OpenBcfBimSnippetReference(bpy.types.Operator):
if bpy.context.scene.BCFProperties.topic_snippet_is_external:
webbrowser.open(bpy.context.scene.BCFProperties.topic_snippet_reference)
return {'FINISHED'}
webbrowser.open('file:///' + os.path.join(
webbrowser.open('file://' + os.path.join(
bcfplugin.util.getBcfDir(),
self.topic_guid,
bpy.context.scene.BCFProperties.topic_snippet_reference
@@ -693,7 +693,7 @@ class OpenBcfDocumentReference(bpy.types.Operator):
if doc.is_external:
webbrowser.open(uri)
return {'FINISHED'}
webbrowser.open('file:///' + os.path.join(
webbrowser.open('file://' + os.path.join(
bcfplugin.util.getBcfDir(),
topic_guid, uri))
return {'FINISHED'}
@@ -1289,6 +1289,55 @@ class SelectExternalMaterialDir(bpy.types.Operator):
context.window_manager.fileselect_add(self)
return {'RUNNING_MODAL'}
class SelectCobieIfcFile(bpy.types.Operator):
bl_idname = "bim.select_cobie_ifc_file"
bl_label = "Select COBie IFC File"
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
def execute(self, context):
bpy.context.scene.BIMProperties.cobie_ifc_file = self.filepath
return {'FINISHED'}
def invoke(self, context, event):
context.window_manager.fileselect_add(self)
return {'RUNNING_MODAL'}
class ExecuteIfcCobie(bpy.types.Operator):
bl_idname = 'bim.execute_ifc_cobie'
bl_label = 'Execute IFCCOBie'
file_format: bpy.props.StringProperty()
def execute(self, context):
from cobie import IfcCobieParser
output_dir = os.path.dirname(bpy.context.scene.BIMProperties.cobie_ifc_file)
output = os.path.join(output_dir, 'output')
log = os.path.join(output_dir, 'cobie.log')
logging.basicConfig(
filename=log, filemode='a', level=logging.DEBUG)
logger = logging.getLogger('IFCtoCOBie')
parser = IfcCobieParser(logger)
parser.parse(bpy.context.scene.BIMProperties.cobie_ifc_file)
if self.file_format == 'xlsx':
from cobie import CobieXlsWriter
writer = CobieXlsWriter(parser, output)
writer.write()
webbrowser.open('file://' + output + '.' + self.file_format)
elif self.file_format == 'ods':
from cobie import CobieOdsWriter
writer = CobieOdsWriter(parser, output)
writer.write()
webbrowser.open('file://' + output + '.' + self.file_format)
else:
from cobie import CobieCsvWriter
writer = CobieCsvWriter(parser, output_dir)
writer.write()
webbrowser.open('file://' + output_dir)
return {'FINISHED'}
class SelectDiffJsonFile(bpy.types.Operator):
bl_idname = "bim.select_diff_json_file"
bl_label = "Select Diff JSON File"
@@ -1947,7 +1996,7 @@ class OpenView(bpy.types.Operator):
bl_label = 'Open View'
def execute(self, context):
webbrowser.open('file:///' + os.path.join(
webbrowser.open('file://' + os.path.join(
bpy.context.scene.BIMProperties.data_dir, 'diagrams',
bpy.context.scene.DocProperties.available_views + '.svg'))
return {'FINISHED'}
@@ -2094,7 +2143,7 @@ class OpenSheet(bpy.types.Operator):
bl_label = 'Open Sheet'
def execute(self, context):
webbrowser.open('file:///' + os.path.join(
webbrowser.open('file://' + os.path.join(
bpy.context.scene.BIMProperties.data_dir, 'sheets',
bpy.context.scene.DocProperties.available_sheets + '.svg'))
return {'FINISHED'}
@@ -2105,7 +2154,7 @@ class OpenCompiledSheet(bpy.types.Operator):
bl_label = 'Open Compiled Sheet'
def execute(self, context):
webbrowser.open('file:///' + os.path.join(
webbrowser.open('file://' + os.path.join(
bpy.context.scene.BIMProperties.data_dir, 'build',
bpy.context.scene.DocProperties.available_sheets,
bpy.context.scene.DocProperties.available_sheets + '.svg'))
@@ -1032,6 +1032,7 @@ class BIMProperties(PropertyGroup):
features_dir: StringProperty(default='', name="Features Directory", update=refreshFeaturesFiles)
features_file: EnumProperty(items=getFeaturesFiles, name="Features File", update=refreshScenarios)
scenario: EnumProperty(items=getScenarios, name="Scenario")
cobie_ifc_file: StringProperty(default='', name="COBie IFC File")
diff_json_file: StringProperty(default='', name="Diff JSON File")
diff_old_file: StringProperty(default='', name="Diff Old IFC File")
diff_new_file: StringProperty(default='', name="Diff New IFC File")
+29
View File
@@ -1403,6 +1403,7 @@ class BIM_PT_library(Panel):
layout.row().prop(scene.BIMLibrary, 'version_date')
layout.row().prop(scene.BIMLibrary, 'description')
class BIM_PT_diff(Panel):
bl_label = "IFC Diff"
bl_idname = "BIM_PT_diff"
@@ -1439,6 +1440,34 @@ class BIM_PT_diff(Panel):
row.operator('bim.execute_ifc_diff')
class BIM_PT_cobie(Panel):
bl_label = "IFC COBie"
bl_idname = "BIM_PT_cobie"
bl_options = {'DEFAULT_CLOSED'}
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
props = scene.BIMProperties
row = layout.row(align=True)
row.prop(props, "cobie_ifc_file")
row.operator("bim.select_cobie_ifc_file", icon="FILE_FOLDER", text="")
row = layout.row()
op = row.operator('bim.execute_ifc_cobie', text='CSV')
op.file_format = 'csv'
op = row.operator('bim.execute_ifc_cobie', text='ODS')
op.file_format = 'ods'
op = row.operator('bim.execute_ifc_cobie', text='XLSX')
op.file_format = 'xlsx'
class BIM_PT_mvd(Panel):
bl_label = "Model View Definitions (MVD)"
bl_idname = "BIM_PT_mvd"