MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / execute

Method execute

src/bonsai/bonsai/bim/module/fm/operator.py:55–86  ·  view source on GitHub ↗
(self, context)

Source from the content-addressed store, hash-verified

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
89class SelectFMSpreadsheetFiles(bpy.types.Operator, ImportHelper):

Callers

nothing calls this directly

Calls 10

parseMethod · 0.95
writeMethod · 0.95
write_csvMethod · 0.95
write_odsMethod · 0.95
write_xlsxMethod · 0.95
get_fm_propsMethod · 0.80
openMethod · 0.80
getMethod · 0.45
joinMethod · 0.45
reportMethod · 0.45

Tested by

no test coverage detected