Skip to content

Commit 7621fba

Browse files
committed
provide support for import options that are strings
provide support for import options that are strings. Currently only bools are supported. Changes are made keeping in mind the need to preserve backward compatibility
1 parent 31c141d commit 7621fba

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/ansys/geometry/core/misc/options.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,13 @@ class ImportOptions:
5353
import_names: bool = False
5454
import_planes: bool = False
5555
import_points: bool = False
56+
import_named_selections: bool = False
57+
import_named_selections_keys: str = ""
5658

5759
def to_dict(self):
5860
"""Provide the dictionary representation of the ImportOptions class."""
59-
return {k: bool(v) for k, v in asdict(self).items()}
61+
import_options_dict = {k: bool(v) for k, v in asdict(self).items() if isinstance(v, bool)}
62+
import_options_definitions_dict = {
63+
k: v for k, v in asdict(self).items() if isinstance(v, str)
64+
}
65+
return import_options_dict, import_options_definitions_dict

src/ansys/geometry/core/modeler.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,13 @@ def _upload_file(
299299

300300
c_stub = CommandsStub(self.client.channel)
301301

302+
import_options_dict, import_options_definitions_dict = import_options.to_dict()
302303
response = c_stub.UploadFile(
303304
UploadFileRequest(
304305
data=data,
305306
file_name=file_name,
306307
open=open_file,
307-
import_options=import_options.to_dict(),
308+
import_options=import_options_dict,
308309
)
309310
)
310311
return response.file_path
@@ -361,8 +362,9 @@ def open_file(
361362
self._upload_file(full_path)
362363
self._upload_file(file_path, True, import_options)
363364
else:
365+
import_options_dict, import_options_definitions_dict = import_options.to_dict()
364366
DesignsStub(self.client.channel).Open(
365-
OpenRequest(filepath=file_path, import_options=import_options.to_dict())
367+
OpenRequest(filepath=file_path, import_options=import_options_dict)
366368
)
367369

368370
return self.read_existing_design()

0 commit comments

Comments
 (0)