Skip to content

Commit

Permalink
new example 010
Browse files Browse the repository at this point in the history
  • Loading branch information
agvarghe committed Oct 19, 2023
1 parent 6fe3b5c commit 1bc483d
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/ansys/meshing/prime/examples/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from .download_utilities import DownloadManager
from .examples import (
download_block_model_fmd,
download_block_model_pmdat,
download_block_model_scdoc,
download_bracket_dsco,
download_bracket_fmd,
download_bracket_scdoc,
Expand Down
119 changes: 115 additions & 4 deletions src/ansys/meshing/prime/examples/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
"download_f1_rw_enclosure_stl",
"download_f1_rw_end_plates_stl",
"download_f1_rw_main_plane_stl",
"download_block_model_scdoc",
"download_block_model_fmd",
"download_block_model_pmdat",
]


Expand Down Expand Up @@ -70,6 +73,9 @@ class Examples(Enum):
F1_RW_END_PLATES_STL = {"filename": "f1_rw_enclosure.stl", "git_folder": "f1_rear_wing"}
F1_RW_ENCLOSURE_STL = {"filename": "f1_rw_end_plates.stl", "git_folder": "f1_rear_wing"}
F1_RW_MAIN_PLANE_STL = {"filename": "f1_rw_main_plane.stl", "git_folder": "f1_rear_wing"}
BLOCK_MODEL_SCDOC = {"filename": "pyprime_block_import.scdoc", "git_folder": "block_model"}
BLOCK_MODEL_FMD = {"filename": "pyprime_block_import.fmd", "git_folder": "block_model"}
BLOCK_MODEL_PMDAT = {"filename": "pyprime_block_import.pmdat", "git_folder": "block_model"}


_DOWNLOADS = []
Expand Down Expand Up @@ -1010,7 +1016,7 @@ def download_f1_rw_drs_stl(
>>> model = session.model
>>> f1_rw_drs = prime_examples.download_f1_rw_drs_stl()
>>> with prime.FileIO(model) as io:
>>> _ = io.read_pmdat(pcb, params=prime.FileReadParams(model))
>>> _ = io.read_cad(f1_rw_drs, params=prime.FileReadParams(model))
>>> print(model)
"""
Expand Down Expand Up @@ -1045,7 +1051,7 @@ def download_f1_rw_enclosure_stl(
>>> model = session.model
>>> f1_rw_enclosure = prime_examples.download_f1_rw_enclosure_stl()
>>> with prime.FileIO(model) as io:
>>> _ = io.read_pmdat(pcb, params=prime.FileReadParams(model))
>>> _ = io.read_cad(f1_rw_enclosure, params=prime.FileReadParams(model))
>>> print(model)
"""
Expand Down Expand Up @@ -1080,7 +1086,7 @@ def download_f1_rw_end_plates_stl(
>>> model = session.model
>>> f1_rw_end_plates = prime_examples.download_f1_rw_end_plates_stl()
>>> with prime.FileIO(model) as io:
>>> _ = io.read_pmdat(pcb, params=prime.FileReadParams(model))
>>> _ = io.read_cad(f1_rw_end_plates, params=prime.FileReadParams(model))
>>> print(model)
"""
Expand Down Expand Up @@ -1115,8 +1121,113 @@ def download_f1_rw_main_plane_stl(
>>> model = session.model
>>> f1_rw_main_plane = prime_examples.download_f1_rw_main_plane_stl()
>>> with prime.FileIO(model) as io:
>>> _ = io.read_pmdat(pcb, params=prime.FileReadParams(model))
>>> _ = io.read_cad(f1_rw_main_plane, params=prime.FileReadParams(model))
>>> print(model)
"""
return get_file(Examples.F1_RW_MAIN_PLANE_STL, destination, force)


def download_block_model_scdoc(
destination: Optional[str] = None, force: bool = False
) -> Union[str, os.PathLike]:
"""Download CAD file for the block model example.
Parameters
----------
destination: Optional[str]
Destination for the file to be downloaded.
If nothing is provided, the default path in app data is used.
force: bool
Option to download the file.
If true, the file is always downloaded.
If false, an existing file in the cache may be reused.
Returns
-------
str
Local path to the downloaded file.
Examples
--------
>>> import ansys.meshing.prime as prime
>>> import ansys.meshing.prime.examples as prime_examples
>>> with prime.launch_prime() as session:
>>> model = session.model
>>> block_model = prime_examples.download_block_model_scdoc()
>>> with prime.FileIO(model) as io:
>>> _ = io.import_cad(block_model, params=prime.FileReadParams(model))
>>> print(model)
"""
return get_file(Examples.BLOCK_MODEL_SCDOC, destination, force)


def download_block_model_fmd(
destination: Optional[str] = None, force: bool = False
) -> Union[str, os.PathLike]:
"""Download CAD file for the block model example.
Parameters
----------
destination: Optional[str]
Destination for the file to be downloaded.
If nothing is provided, the default path in app data is used.
force: bool
Option to download the file.
If true, the file is always downloaded.
If false, an existing file in the cache may be reused.
Returns
-------
str
Local path to the downloaded file.
Examples
--------
>>> import ansys.meshing.prime as prime
>>> import ansys.meshing.prime.examples as prime_examples
>>> with prime.launch_prime() as session:
>>> model = session.model
>>> block_model = prime_examples.download_block_model_fmd()
>>> with prime.FileIO(model) as io:
>>> _ = io.import_cad(block_model, params=prime.FileReadParams(model))
>>> print(model)
"""
return get_file(Examples.BLOCK_MODEL_FMD, destination, force)


def download_block_model_pmdat(
destination: Optional[str] = None, force: bool = False
) -> Union[str, os.PathLike]:
"""Download PMDAT file for the block model example.
Parameters
----------
destination: Optional[str]
Destination for the file to be downloaded.
If nothing is provided, the default path in app data is used.
force: bool
Option to download the file.
If true, the file is always downloaded.
If false, an existing file in the cache may be reused.
Returns
-------
str
Local path to the downloaded file.
Examples
--------
>>> import ansys.meshing.prime as prime
>>> import ansys.meshing.prime.examples as prime_examples
>>> with prime.launch_prime() as session:
>>> model = session.model
>>> block_model = prime_examples.download_block_model_pmdat()
>>> with prime.FileIO(model) as io:
>>> _ = io.read_pmdat(block_model, params=prime.FileReadParams(model))
>>> print(model)
"""
return get_file(Examples.BLOCK_MODEL_PMDAT, destination, force)

0 comments on commit 1bc483d

Please sign in to comment.