You can now specify custom attribute mappings to COBie spreadsheets

This commit is contained in:
Dion Moult
2020-08-21 14:38:41 +10:00
parent 668edbc45e
commit 09dd778f97
5 changed files with 131 additions and 45 deletions
@@ -167,6 +167,7 @@ if bpy is not None:
operator.ExecuteBIMTester,
operator.BIMTesterPurge,
operator.SelectCobieIfcFile,
operator.SelectCobieJsonFile,
operator.ExecuteIfcCobie,
operator.SelectIfcPatchInput,
operator.SelectIfcPatchOutput,
@@ -1319,6 +1319,20 @@ class SelectCobieIfcFile(bpy.types.Operator):
return {'RUNNING_MODAL'}
class SelectCobieJsonFile(bpy.types.Operator):
bl_idname = "bim.select_cobie_json_file"
bl_label = "Select COBie JSON File"
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
def execute(self, context):
bpy.context.scene.BIMProperties.cobie_json_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'
@@ -1335,11 +1349,17 @@ class ExecuteIfcCobie(bpy.types.Operator):
logger = logging.getLogger('IFCtoCOBie')
logger.addHandler(fh)
selector = ifcopenshell.util.selector.Selector()
if bpy.context.scene.BIMProperties.cobie_json_file:
with open(bpy.context.scene.BIMProperties.cobie_json_file, 'r') as f:
custom_data = json.load(f)
else:
custom_data = {}
parser = IfcCobieParser(logger, selector)
parser.parse(
bpy.context.scene.BIMProperties.cobie_ifc_file,
bpy.context.scene.BIMProperties.cobie_types,
bpy.context.scene.BIMProperties.cobie_components)
bpy.context.scene.BIMProperties.cobie_components,
custom_data)
if self.file_format == 'xlsx':
from cobie import CobieXlsWriter
writer = CobieXlsWriter(parser, output)
@@ -1127,6 +1127,7 @@ class BIMProperties(PropertyGroup):
cobie_ifc_file: StringProperty(default='', name="COBie IFC File")
cobie_types: StringProperty(default='.COBieType', name="COBie Types")
cobie_components: StringProperty(default='.COBie', name="COBie Components")
cobie_json_file: StringProperty(default='', name="COBie JSON 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")
@@ -1591,6 +1591,10 @@ class BIM_PT_cobie(Panel):
row = layout.row()
row.prop(props, "cobie_components")
row = layout.row(align=True)
row.prop(props, "cobie_json_file")
row.operator("bim.select_cobie_json_file", icon="FILE_FOLDER", text="")
row = layout.row()
op = row.operator('bim.execute_ifc_cobie', text='CSV')
op.file_format = 'csv'