(self, context)
| 53 | return True |
| 54 | |
| 55 | def execute(self, context): |
| 56 | props = tool.Blender.get_fm_props() |
| 57 | ifc_file = tool.Ifc.get() |
| 58 | filepaths = [] |
| 59 | if ifc_file and props.should_load_from_memory: |
| 60 | ifc_files = [ifc_file] |
| 61 | else: |
| 62 | ifc_files = [ifcopenshell.open(f.name) for f in props.ifc_files.file_list] |
| 63 | |
| 64 | if len(ifc_files) > 1: |
| 65 | filepaths = [f.name for f in props.ifc_files.file_list] |
| 66 | |
| 67 | for i, ifc_file in enumerate(ifc_files): |
| 68 | if filepaths: |
| 69 | dirname = os.path.dirname(self.filepath) |
| 70 | prefix, _ = os.path.splitext(os.path.basename(filepaths[i])) |
| 71 | basename = os.path.basename(self.filepath) |
| 72 | filepath = os.path.join(dirname, f"{prefix}-{basename}") |
| 73 | else: |
| 74 | filepath = self.filepath |
| 75 | parser = ifcfm.Parser(preset=props.engine) |
| 76 | parser.parse(ifc_file) |
| 77 | writer = ifcfm.Writer(parser) |
| 78 | writer.write() |
| 79 | if props.format == "csv": |
| 80 | writer.write_csv("tmp/") |
| 81 | elif props.format == "ods": |
| 82 | writer.write_ods(filepath) |
| 83 | elif props.format == "xlsx": |
| 84 | writer.write_xlsx(filepath) |
| 85 | self.report({"INFO"}, "IfcFM spreadsheet is saved.") |
| 86 | return {"FINISHED"} |
| 87 | |
| 88 | |
| 89 | class SelectFMSpreadsheetFiles(bpy.types.Operator, ImportHelper): |
nothing calls this directly
no test coverage detected