Skip to content

Store composite definitions in UserFiles directory #818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 4 additions & 5 deletions src/ansys/acp/core/mechanical_integration_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,22 +137,21 @@
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

Check warning on line 148 in src/ansys/acp/core/mechanical_integration_helpers.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/acp/core/mechanical_integration_helpers.py#L146-L148

Added lines #L146 - L148 were not covered by tests
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())}"

Check warning on line 154 in src/ansys/acp/core/mechanical_integration_helpers.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/acp/core/mechanical_integration_helpers.py#L154

Added line #L154 was not covered by tests

mechanical.run_python_script(
textwrap.dedent(
Expand Down