From 56a3bc9381b76dbcc1387e81e07d5a45a6ccf682 Mon Sep 17 00:00:00 2001 From: Samuel Lopez <85613111+Samuelopez-ansys@users.noreply.github.com> Date: Fri, 12 Jan 2024 22:15:58 +0100 Subject: [PATCH] Fix Examples documentation (#4070) * Fix logger Fix release example Add release all True for Documentation * Fix pyVista error in example * Add no cover * Fix array example * Fix array example * Fix array example * Fix array example --- doc/source/User_guide/intro.rst | 2 +- .../User_guide/pyaedt_file_data/project.rst | 4 ++-- .../00-EDB/03_5G_antenna_example_parametrics.py | 3 +-- examples/00-EDB/13_edb_create_component.py | 6 +++++- .../00-EDB/14_edb_create_parametrized_design.py | 6 +++--- examples/02-HFSS/Array.py | 15 +++++++-------- examples/02-HFSS/Flex_CPWG.py | 1 + pyaedt/desktop.py | 5 +++++ 8 files changed, 25 insertions(+), 17 deletions(-) diff --git a/doc/source/User_guide/intro.rst b/doc/source/User_guide/intro.rst index 76585ad7647..e3c3cf59b5e 100644 --- a/doc/source/User_guide/intro.rst +++ b/doc/source/User_guide/intro.rst @@ -1,4 +1,4 @@ -Minimal Example +Minimal example =============== You can initiate AEDT in non-graphical mode from Python using this code: diff --git a/doc/source/User_guide/pyaedt_file_data/project.rst b/doc/source/User_guide/pyaedt_file_data/project.rst index a4f538cbf4d..d9b965f0de1 100644 --- a/doc/source/User_guide/pyaedt_file_data/project.rst +++ b/doc/source/User_guide/pyaedt_file_data/project.rst @@ -1,8 +1,8 @@ -Project Configuration file +Project configuration file ========================== The project configuration file is the most comprehensive format that allows to apply a set of variables, materials, -setup, mesh and boundaries to a new project or save an existing one. +setup, mesh, and boundaries to a new project or save an existing one. This code creates the JSON file: .. code:: python diff --git a/examples/00-EDB/03_5G_antenna_example_parametrics.py b/examples/00-EDB/03_5G_antenna_example_parametrics.py index 8c0ac1e847c..771b745f6b8 100644 --- a/examples/00-EDB/03_5G_antenna_example_parametrics.py +++ b/examples/00-EDB/03_5G_antenna_example_parametrics.py @@ -248,8 +248,7 @@ def points(self): # ~~~~~~~~~~~~~~ # Launch HFSS 3D. -h3d = pyaedt.Hfss(specified_version="2023.2",new_desktop_session=True, close_on_exit=True, solution_type="Terminal") - +h3d = pyaedt.Hfss(specified_version="2023.2", new_desktop_session=True, close_on_exit=True, solution_type="Terminal") ############################################################################### # Add the layout component diff --git a/examples/00-EDB/13_edb_create_component.py b/examples/00-EDB/13_edb_create_component.py index 27a3f3b8610..9c3571e4e7a 100644 --- a/examples/00-EDB/13_edb_create_component.py +++ b/examples/00-EDB/13_edb_create_component.py @@ -160,7 +160,11 @@ ########################### # Save EDB and open in AEDT # ~~~~~~~~~~~~~~~~~~~~~~~~~ + edb.save_edb() edb.close_edb() -h3d = pyaedt.Hfss3dLayout(specified_version="2023.2", projectname=aedb_path, non_graphical=False) +h3d = pyaedt.Hfss3dLayout(specified_version="2023.2", + projectname=aedb_path, + non_graphical=False, + new_desktop_session=True) h3d.release_desktop(False, False) diff --git a/examples/00-EDB/14_edb_create_parametrized_design.py b/examples/00-EDB/14_edb_create_parametrized_design.py index 22d48957bcd..d4cf224f299 100644 --- a/examples/00-EDB/14_edb_create_parametrized_design.py +++ b/examples/00-EDB/14_edb_create_parametrized_design.py @@ -55,7 +55,6 @@ ############################# # Generated design parameters # ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# edb.auto_parametrize_design(layers=True, materials=True, via_holes=True, pads=True, antipads=True, traces=True) edb.save_edb() @@ -65,5 +64,6 @@ # Open project in AEDT # ~~~~~~~~~~~~~~~~~~~~ -hfss = pyaedt.Hfss3dLayout(projectname=target_aedb, specified_version=aedt_version) -hfss.release_desktop(False, False) +# Uncomment the following line to open the design in HFSS 3D Layout +# hfss = pyaedt.Hfss3dLayout(projectname=target_aedb, specified_version=aedt_version, new_desktop_session=True) +# hfss.release_desktop() diff --git a/examples/02-HFSS/Array.py b/examples/02-HFSS/Array.py index 51f08c0c9c4..07d3e2a8f90 100644 --- a/examples/02-HFSS/Array.py +++ b/examples/02-HFSS/Array.py @@ -105,6 +105,7 @@ eep_file = ffdata.eep_files frequencies = ffdata.frequencies +working_directory = hfss.working_directory hfss.release_desktop() @@ -148,12 +149,10 @@ ffdata.polar_plot_3d(farfield_quantity='RealizedGain') -########################################################## -# Generate 3D plots in PyVista -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# Generate 3D plots in PyVista. You can define the Theta and Phi -# scan angles. You can change the easy-to-use interactive plot -# that is generated on the fly. +############################################################################### +# Analyze and release +# ~~~~~~~~~~~~~~~~~~~~ +# Uncomment the ``hfss.analyze`` command if you want to analyze the +# model and release AEDT. -ffdata.polar_plot_3d_pyvista(farfield_quantity='RealizedGain', - show=False) +hfss.release_desktop() diff --git a/examples/02-HFSS/Flex_CPWG.py b/examples/02-HFSS/Flex_CPWG.py index 9c16dbb82db..65b473766da 100644 --- a/examples/02-HFSS/Flex_CPWG.py +++ b/examples/02-HFSS/Flex_CPWG.py @@ -215,6 +215,7 @@ def create_bending(radius, extension=0): my_plot.plot( os.path.join(hfss.working_directory, "Image.jpg"), ) + ############################################################################### # Analyze and release # ~~~~~~~~~~~~~~~~~~~~ diff --git a/pyaedt/desktop.py b/pyaedt/desktop.py index 5756085ef26..67970df64b9 100644 --- a/pyaedt/desktop.py +++ b/pyaedt/desktop.py @@ -1437,6 +1437,11 @@ def release_desktop(self, close_projects=True, close_on_exit=True): >>> desktop.release_desktop(close_projects=False, close_on_exit=False) # doctest: +SKIP """ + self.logger.oproject = None + self.logger.odesign = None + if os.getenv("PYAEDT_DOC_GENERATION", "False").lower() in ("true", "1", "t"): # pragma: no cover + close_projects = True + close_on_exit = True if close_projects: projects = self.odesktop.GetProjectList() for project in projects: