diff --git a/src/ansys/fluent/core/services/datamodel_se.py b/src/ansys/fluent/core/services/datamodel_se.py index 4003c89fb46..60177cb7e78 100644 --- a/src/ansys/fluent/core/services/datamodel_se.py +++ b/src/ansys/fluent/core/services/datamodel_se.py @@ -1738,7 +1738,9 @@ def _get_file_purpose(self, arg): def before_execute(self, value): """Executes before command execution.""" if hasattr(self, "_do_before_execute"): - self._do_before_execute(value) + return self._do_before_execute(value) + else: + return value def after_execute(self, value): """Executes after command execution.""" @@ -1755,8 +1757,7 @@ def __call__(self, *args, **kwds) -> Any: """ for arg, value in kwds.items(): if self._get_file_purpose(arg): - self.before_execute(value) - kwds[f"{arg}"] = os.path.basename(value) + kwds[arg] = self.before_execute(value) command = self.service.execute_command( self.rules, convert_path_to_se_path(self.path), self.command, kwds ) @@ -1824,15 +1825,22 @@ def create_instance(self) -> "PyCommandArguments": class _InputFile: def _do_before_execute(self, value): try: - self.service.file_transfer_service.upload(file_name=value) + file_names = value if isinstance(value, list) else [value] + base_names = [] + for file_name in file_names: + self.service.file_transfer_service.upload(file_name=file_name) + base_names.append(os.path.basename(file_name)) + return base_names if isinstance(value, list) else base_names[0] except AttributeError: - pass + return value class _OutputFile: def _do_after_execute(self, value): try: - self.service.file_transfer_service.download(file_name=value) + file_names = value if isinstance(value, list) else [value] + for file_name in file_names: + self.service.file_transfer_service.download(file_name=file_name) except AttributeError: pass diff --git a/tests/test_file_transfer_service.py b/tests/test_file_transfer_service.py index c8f90f317d7..7eff9ac8ad1 100644 --- a/tests/test_file_transfer_service.py +++ b/tests/test_file_transfer_service.py @@ -106,3 +106,24 @@ def test_datamodel_execute(): with pytest.raises(RuntimeError): import_geom.Execute() + + +def test_file_list_in_datamodel(fault_tolerant_workflow_session): + meshing = fault_tolerant_workflow_session + fmd_file = examples.download_file("exhaust_system.fmd", "pyfluent/exhaust_system") + meshing.PartManagement.AppendFmdFiles( + AssemblyParentNode=0, + FilePath=[fmd_file], + FileUnit="mm", + IgnoreSolidNamesAppend=False, + JtLOD="1", + Options={ + "Line": False, + "Solid": True, + "Surface": True, + }, + PartPerBody=False, + PrefixParentName=False, + RemoveEmptyParts=True, + Route="Native", + )