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

Method create_mesh

src/ifc2ca/ifc2ca.py:800–841  ·  view source on GitHub ↗
(self, model, parameters)

Source from the content-addressed store, hash-verified

798 return meshes
799
800 def create_mesh(self, model, parameters):
801 model_id = model.id()
802 if not self.folder_path.exists():
803 self.folder_path.mkdir()
804
805 template = self.env.get_template("salome/scriptSalome.py")
806 mesh_name = f'Model_{model_id}_v{parameters["mesh_size"]}'
807
808 med_path = self.folder_path / f"{mesh_name}.med"
809 json_path = self.folder_path / f"Model_{model_id}.json"
810 with json_path.open("w") as f:
811 json.dump(self.parse_model(model), f, indent=4)
812
813 rendered_script = template.render(
814 mesh_size=parameters["mesh_size"],
815 json_path=str(json_path.resolve()),
816 med_path=str(med_path.resolve()),
817 mesh_name=mesh_name,
818 )
819
820 # Write the rendered script to the new location
821 script_path = self.folder_path / f'ScriptSalome_Model_{model_id}_v{parameters["mesh_size"]}.py'
822 with open(script_path, "w") as f:
823 f.write(rendered_script)
824
825 if self.salome_path is not None:
826 executable = Path(self.salome_path)
827 subprocess.run(["python", executable, "-t", script_path])
828
829 return {
830 "name": mesh_name,
831 "model_id": model.id(),
832 "med_path": med_path,
833 }
834 else:
835 print("Salome path not provided. Mesh operation aborted.")
836 print(f"The salome script file path can be found in the return statement.")
837 return {
838 "name": mesh_name,
839 "model_id": model.id(),
840 "script_path": script_path,
841 }
842
843 def get_run_case_labels(self, data, target):
844 cases = []

Callers

nothing calls this directly

Calls 8

parse_modelMethod · 0.95
printFunction · 0.85
openMethod · 0.80
openFunction · 0.50
idMethod · 0.45
dumpMethod · 0.45
writeMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected