Skip to content

Commit

Permalink
Improved Model export (#672)
Browse files Browse the repository at this point in the history
* Improved Model export

* Update pyaedt/modules/AdvancedPostProcessing.py

* Add arguments documentation.

* Fix python black code style issue.

* Add space before the colon separating the pa.

* Add space before the colon separating the parameter and its type.

* Improved plot model

* Improved plot model

* Improved plot model

* Update pyaedt/modules/AdvancedPostProcessing.py

Co-authored-by: Maxime Rey <87315832+MaxJPRey@users.noreply.github.com>

* Improved plot model.
Added Pyvista, matplotlib and numpy to setup.py

* Fixed Style errors

* black style

* Update pyaedt/modules/AdvancedPostProcessing.py

* Update pyaedt/modules/AdvancedPostProcessing.py

* Update pyaedt/modules/AdvancedPostProcessing.py

* Update pyaedt/modules/AdvancedPostProcessing.py

* Update pyaedt/modules/AdvancedPostProcessing.py

* Update pyaedt/modules/AdvancedPostProcessing.py

* Update pyaedt/modeler/Object3d.py

* Apply suggestions from code review

Committed suggestions

Co-authored-by: Maxime Rey <87315832+MaxJPRey@users.noreply.github.com>

Co-authored-by: Maxime Rey <87315832+MaxJPRey@users.noreply.github.com>
Co-authored-by: Maxime Rey <maxime.rey@ansys.com>
  • Loading branch information
3 people authored Dec 27, 2021
1 parent f6ac9eb commit bd981aa
Show file tree
Hide file tree
Showing 3 changed files with 543 additions and 163 deletions.
54 changes: 54 additions & 0 deletions pyaedt/modeler/Object3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from pyaedt.modeler.GeometryOperators import GeometryOperators
from pyaedt.application.Variables import decompose_variable_value
from pyaedt.generic.constants import AEDT_UNITS, MILS2METER
from pyaedt.generic.general_methods import is_ironpython

clamp = lambda n, minn, maxn: max(min(maxn, n), minn)

Expand Down Expand Up @@ -768,6 +769,59 @@ def _odesign(self):
"""Design."""
return self._primitives._modeler._app._odesign

@aedt_exception_handler
def plot(self):
"""Plot model with PyVista.
.. note::
Works from AEDT 2021.2 in CPython only. PyVista has to be installed.
"""
if not is_ironpython and self._primitives._appp._aedt_version >= "2021.2":
self._primitives._app.post.plot_model_obj(
objects=[self.name],
export_afterplot=False,
plot_separate_objects=True,
air_objects=True,
background_color="grey",
object_selector=False,
color="dodgerblue",
off_screen=False,
)

@aedt_exception_handler
def export_image(self, file_path=None):

"""Export the model to path.
.. note::
Works from AEDT 2021.2 in CPython only. PyVista has to be installed.
Parameters
----------
file_path : str, optional
File name with full path. If `None` Project directory will be used.
Returns
-------
str
File path.
"""
if not is_ironpython and self._primitives._appp._aedt_version >= "2021.2":
files = self._primitives._app.post.plot_model_obj(
objects=[self.name],
export_afterplot=True,
export_path=file_path,
plot_separate_objects=True,
air_objects=True,
background_color="grey",
object_selector=False,
color="dodgerblue",
off_screen=True,
)
if files:
return files[0]
return False

@property
def faces(self):
"""Information for each face in the given part.
Expand Down
Loading

0 comments on commit bd981aa

Please sign in to comment.