From 8e324297b5cbc154d05e641b9122a599aa34c2b0 Mon Sep 17 00:00:00 2001 From: Dominik Gresch Date: Wed, 16 Apr 2025 08:36:07 +0200 Subject: [PATCH] Store composite definitions in UserFiles directory In the PyMechanical integration, store the composite definitions H5 file in the UserFiles directory of the Mechanical project tree. This matches the new behavior of Mechanical standalone (since 25R2), which computes the path of this file relative to the UserFiles directory (i.e., expects it to be inside UserFiles). With the combined changes, projects created with the PyACP / PyMechanical workflow can now be post-processed also within Mechanical directly. --- doc/source/index.rst | 2 -- src/ansys/acp/core/mechanical_integration_helpers.py | 9 ++++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/doc/source/index.rst b/doc/source/index.rst index 36d408fa80..1d7ddc6ccd 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -91,8 +91,6 @@ Limitations * The ``ansys.acp.core.mechanical_integration_helpers`` module may be changed or removed in future versions, when the corresponding features are available in PyMechanical directly. - * Post-processing with the Composite Failure Tool inside Mechanical is not - yet supported. * Visualization and mesh data of imported plies are not supported yet. * Section cuts cannot be visualized. diff --git a/src/ansys/acp/core/mechanical_integration_helpers.py b/src/ansys/acp/core/mechanical_integration_helpers.py index e402a89e2e..9d8e252a28 100644 --- a/src/ansys/acp/core/mechanical_integration_helpers.py +++ b/src/ansys/acp/core/mechanical_integration_helpers.py @@ -137,22 +137,21 @@ def import_acp_composite_definitions(*, mechanical: "pymechanical.Mechanical", p The path of the file to import. The extension must be '.h5'. """ path = pathlib.Path(path) - setup_folder_name = "Setup" if path.suffix != ".h5": raise ValueError( f"The composite definitions file extension must be '.h5', not '{path.suffix}'." ) - setup_folder = pathlib.Path(mechanical.project_directory) / setup_folder_name - setup_folder.mkdir(exist_ok=True) - target_path = setup_folder / path.name + user_files_dir = pathlib.Path(mechanical.project_directory) / "UserFiles" + user_files_dir.mkdir(exist_ok=True) + target_path = user_files_dir / path.name try: shutil.copyfile(path, target_path) except shutil.SameFileError: pass - target_path_str = f"{setup_folder_name}::{target_path.resolve()}".replace("\\", "\\\\") + target_path_str = f"Setup::{str(target_path.resolve())}" mechanical.run_python_script( textwrap.dedent(