Skip to content

Commit cdd848d

Browse files
authored
[FIX] VTK export appends .vtk (#78)
* Introducing check_folder_path helper function for vtk export * Localise folder path message * copilot review fixes * Updating helper function name
1 parent 925c33d commit cdd848d

17 files changed

Lines changed: 181 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525
### Security
2626
- N/A
2727

28+
## [27.0.1] - 2026-04-18
29+
30+
### Added
31+
- N/A
32+
33+
### Changed
34+
- N/A
35+
36+
### Deprecated
37+
- N/A
38+
39+
### Removed
40+
- N/A
41+
42+
### Fixed
43+
- `PlotManager.export_to_vtk()` no longer appends a `.vtk` suffix to the export path; the path is treated as a VTK export **folder** root, matching Synergy UI behavior. Uses `prepare_folder_path()` in `helper.py` to validate the path and create parent directories only.
44+
45+
### Security
46+
- N/A
47+
2848
## [27.0.0] - 2026-01-21
2949

3050
### Added
@@ -170,7 +190,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
170190
- Initial version aligned with Moldflow Synergy 2026.0.1
171191
- Python 3.10-3.13 compatibility
172192

173-
[Unreleased]: https://github.com/Autodesk/moldflow-api/compare/v26.0.5...HEAD
193+
[Unreleased]: https://github.com/Autodesk/moldflow-api/compare/v27.0.1...HEAD
194+
[27.0.1]: https://github.com/Autodesk/moldflow-api/releases/tag/v27.0.1
195+
[27.0.0]: https://github.com/Autodesk/moldflow-api/releases/tag/v27.0.0
174196
[26.0.5]: https://github.com/Autodesk/moldflow-api/releases/tag/v26.0.5
175197
[26.0.4]: https://github.com/Autodesk/moldflow-api/releases/tag/v26.0.4
176198
[26.0.3]: https://github.com/Autodesk/moldflow-api/releases/tag/v26.0.3

src/moldflow/common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ class LogMessage(Enum):
175175
CHECK_NEGATIVE = ("Checking {value} is negative", logging.DEBUG)
176176
CHECK_INDEX_IN_RANGE = ("Checking index {index} is in range", logging.DEBUG)
177177
CHECK_FILE_EXTENSION = ("Checking file extension {file_name}", logging.DEBUG)
178+
CHECK_FOLDER_PATH = ("Checking folder path {folder_path}", logging.DEBUG)
178179
CHECK_EXPECTED_VALUES = ("Checking {value} is in expected values", logging.DEBUG)
179180
FAIL_INIT_WITH_ENV = (
180181
"Could not initialize with Instance ID: {value}",

src/moldflow/helper.py

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,22 @@ def check_index(index: int, min_value: int, max_value: int):
237237
process_log(__name__, LogMessage.VALID_INPUT)
238238

239239

240+
def _create_required_parent_directories(path: str):
241+
"""
242+
Create parent directories for a given path.
243+
244+
Trailing separators are normalized first so ``dirname`` resolves to the
245+
parent of the final path component (never the export root / file leaf).
246+
247+
Args:
248+
path (str): The path to create parent directories for.
249+
"""
250+
directory = os.path.dirname(os.path.normpath(path))
251+
if not directory:
252+
return
253+
os.makedirs(directory, exist_ok=True)
254+
255+
240256
def check_file_extension(file_name: str, extensions: tuple | str):
241257
"""
242258
Check if the file name has a valid extension.
@@ -247,9 +263,7 @@ def check_file_extension(file_name: str, extensions: tuple | str):
247263
process_log(__name__, LogMessage.CHECK_FILE_EXTENSION, locals(), file_name=file_name)
248264
check_type(file_name, str)
249265
check_type(extensions, (str, tuple))
250-
directory = os.path.dirname(file_name)
251-
if directory:
252-
os.makedirs(directory, exist_ok=True)
266+
_create_required_parent_directories(file_name)
253267
default = extensions if isinstance(extensions, str) else extensions[0]
254268
if not file_name.endswith(extensions):
255269
process_log(
@@ -263,6 +277,25 @@ def check_file_extension(file_name: str, extensions: tuple | str):
263277
return file_name
264278

265279

280+
def prepare_folder_path(folder_path: str) -> str:
281+
"""
282+
Validate and prepare a folder-style export path.
283+
284+
Ensures parent directories exist. Does not modify the path or append a file extension.
285+
286+
Args:
287+
folder_path (str): Full path to the export root folder (bare name, relative path,
288+
or absolute path).
289+
290+
Returns:
291+
str: The same path, unchanged.
292+
"""
293+
process_log(__name__, LogMessage.CHECK_FOLDER_PATH, locals(), folder_path=folder_path)
294+
check_type(folder_path, str)
295+
_create_required_parent_directories(folder_path)
296+
return folder_path
297+
298+
266299
def check_expected_values(value, expected_values: tuple):
267300
"""
268301
Check if the value is in the expected values.

src/moldflow/locale/de-DE/LC_MESSAGES/locale.de-DE.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ msgstr "Abbrechen"
99
msgid "Checking file extension {file_name}"
1010
msgstr "Überprüfen der Dateierweiterung {file_name}"
1111

12+
msgid "Checking folder path {folder_path}"
13+
msgstr "Überprüfen des Ordnerpfads {folder_path}"
14+
1215
msgid "Checking index {index} is in range"
1316
msgstr "Überprüfen, ob der Index {index} im Bereich liegt"
1417

src/moldflow/locale/en-US/LC_MESSAGES/locale.en-US.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ msgstr "Cancel"
99
msgid "Checking file extension {file_name}"
1010
msgstr "Checking file extension {file_name}"
1111

12+
msgid "Checking folder path {folder_path}"
13+
msgstr "Checking folder path {folder_path}"
14+
1215
msgid "Checking index {index} is in range"
1316
msgstr "Checking index {index} is in range"
1417

src/moldflow/locale/es-ES/LC_MESSAGES/locale.es-ES.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ msgstr "Cancelar"
99
msgid "Checking file extension {file_name}"
1010
msgstr "Comprobando la extensión del archivo {file_name}"
1111

12+
msgid "Checking folder path {folder_path}"
13+
msgstr "Comprobando la ruta de la carpeta {folder_path}"
14+
1215
msgid "Checking index {index} is in range"
1316
msgstr "Comprobando que el índice {index} está dentro del rango"
1417

src/moldflow/locale/fr-FR/LC_MESSAGES/locale.fr-FR.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ msgstr "Annuler"
99
msgid "Checking file extension {file_name}"
1010
msgstr "Vérification de l'extension du fichier {file_name}"
1111

12+
msgid "Checking folder path {folder_path}"
13+
msgstr "Vérification du chemin du dossier {folder_path}"
14+
1215
msgid "Checking index {index} is in range"
1316
msgstr "Vérification que l'indice {index} est dans l'intervalle"
1417

src/moldflow/locale/it-IT/LC_MESSAGES/locale.it-IT.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ msgstr "Annulla"
99
msgid "Checking file extension {file_name}"
1010
msgstr "Verifica dell'estensione del file {file_name}"
1111

12+
msgid "Checking folder path {folder_path}"
13+
msgstr "Verifica del percorso della cartella {folder_path}"
14+
1215
msgid "Checking index {index} is in range"
1316
msgstr "Verifica che l'indice {index} sia nell'intervallo"
1417

src/moldflow/locale/ja-JP/LC_MESSAGES/locale.ja-JP.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ msgstr "キャンセル"
99
msgid "Checking file extension {file_name}"
1010
msgstr "ファイル拡張子 {file_name} を確認しています"
1111

12+
msgid "Checking folder path {folder_path}"
13+
msgstr "フォルダー パス {folder_path} を確認しています"
14+
1215
msgid "Checking index {index} is in range"
1316
msgstr "インデックス {index} が範囲内であることを確認しています"
1417

src/moldflow/locale/ko-KR/LC_MESSAGES/locale.ko-KR.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ msgstr "취소"
99
msgid "Checking file extension {file_name}"
1010
msgstr "파일 확장자 {file_name} 확인 중"
1111

12+
msgid "Checking folder path {folder_path}"
13+
msgstr "폴더 경로 {folder_path} 확인 중"
14+
1215
msgid "Checking index {index} is in range"
1316
msgstr "인덱스 {index}가 범위 내에 있는지 확인 중"
1417

0 commit comments

Comments
 (0)