diff --git a/_unittest/conftest.py b/_unittest/conftest.py index 183590b6378..cf6e0f24400 100644 --- a/_unittest/conftest.py +++ b/_unittest/conftest.py @@ -166,8 +166,9 @@ def desktop(): d = Desktop(desktop_version, NONGRAPHICAL, new_thread) d.odesktop.SetTempDirectory(tempfile.gettempdir()) d.disable_autosave() - d.odesktop.SetDesktopConfiguration("All") - d.odesktop.SetSchematicEnvironment(0) + if desktop_version > "2022.2": + d.odesktop.SetDesktopConfiguration("All") + d.odesktop.SetSchematicEnvironment(0) yield d d.release_desktop(True, True) time.sleep(1) diff --git a/_unittest/test_01_3dlayout_edb.py b/_unittest/test_01_3dlayout_edb.py index b01d11d8faf..c4de3284c8a 100644 --- a/_unittest/test_01_3dlayout_edb.py +++ b/_unittest/test_01_3dlayout_edb.py @@ -415,5 +415,6 @@ def test_23_dissolve_element(self): assert self.aedtapp.create_ports_on_component_by_nets(comp.name, nets) assert self.aedtapp.create_pec_on_component_by_nets(comp.name, "GND") + @pytest.mark.skipif(config["desktopVersion"] <= "2024.1", reason="Introduced in 2024R1") def test_24_open_ic_mode_design(self): assert self.ic_mode_design.ic_mode diff --git a/_unittest/test_01_Design.py b/_unittest/test_01_Design.py index 47816c8f985..d26f86f05e0 100644 --- a/_unittest/test_01_Design.py +++ b/_unittest/test_01_Design.py @@ -385,7 +385,7 @@ def test_33_aedt_object(self): def test_34_force_project_path_disable(self): settings.force_error_on_missing_project = True - assert settings.force_error_on_missing_project == True + assert settings.force_error_on_missing_project e = None exception_raised = False try: diff --git a/_unittest/test_02_3D_modeler.py b/_unittest/test_02_3D_modeler.py index fab1d449857..9a3c48c6ae4 100644 --- a/_unittest/test_02_3D_modeler.py +++ b/_unittest/test_02_3D_modeler.py @@ -248,7 +248,10 @@ def test_18_chamfer(self): o1 = self.aedtapp.modeler["box_to_split"] assert abs(o1.volume - 4000.0) / 4000.0 < small_number assert o1.top_edge_x.chamfer(1) - assert abs(o1.volume - 3990.0) / 3990.0 < small_number # Volume decreased + if config["desktopVersion"] == "2022.2": + assert abs(o1.volume - 3995.0) / 3995.0 < small_number # Volume decreased + else: + assert abs(o1.volume - 3990.0) / 3990.0 < small_number # Volume decreased def test_19_clone(self): self.restore_model() @@ -521,7 +524,10 @@ def test_40b_create_object_coordinate_system(self): assert cs assert cs.name == "obj_cs" assert cs.entity_id == box.id - assert cs.ref_cs == "Global" + if config["desktopVersion"] == "2022.2": + assert not cs.ref_cs + else: + assert cs.ref_cs == "Global" cs.props["MoveToEnd"] = False assert not cs.props["MoveToEnd"] cs.props["yAxis"]["xDirection"] = 1 @@ -535,7 +541,10 @@ def test_40b_create_object_coordinate_system(self): assert cs assert cs.name == "obj_cs" assert cs.entity_id == box.id - assert cs.ref_cs == "Global" + if config["desktopVersion"] == "2022.2": + assert not cs.ref_cs + else: + assert cs.ref_cs == "Global" cs.props["MoveToEnd"] = False assert not cs.props["MoveToEnd"] cs.props["xAxis"]["xDirection"] = 1 diff --git a/doc/source/Resources/pyaedt_installer_from_aedt.py b/doc/source/Resources/pyaedt_installer_from_aedt.py index 0222384e54d..7ef2a81dce4 100644 --- a/doc/source/Resources/pyaedt_installer_from_aedt.py +++ b/doc/source/Resources/pyaedt_installer_from_aedt.py @@ -84,10 +84,16 @@ def run_pyinstaller_from_c_python(oDesktop): # enable in debug mode # f.write("import sys\n") # f.write('sys.path.insert(0, r"c:\\ansysdev\\git\\repos\\pyaedt")\n') - f.write("from ansys.aedt.core.workflows.installer.pyaedt_installer import add_pyaedt_to_aedt\n") - f.write( - 'add_pyaedt_to_aedt(aedt_version="{}", personal_lib=r"{}")\n'.format( - oDesktop.GetVersion()[:6], oDesktop.GetPersonalLibDirectory())) + if version <= "231": + f.write("from pyaedt.workflows.installer.pyaedt_installer import add_pyaedt_to_aedt\n") + f.write( + 'add_pyaedt_to_aedt(aedt_version="{}", personallib=r"{}")\n'.format( + oDesktop.GetVersion()[:6], oDesktop.GetPersonalLibDirectory())) + else: + f.write("from ansys.aedt.core.workflows.installer.pyaedt_installer import add_pyaedt_to_aedt\n") + f.write( + 'add_pyaedt_to_aedt(aedt_version="{}", personal_lib=r"{}")\n'.format( + oDesktop.GetVersion()[:6], oDesktop.GetPersonalLibDirectory())) command = r'"{}" "{}"'.format(python_exe, python_script) oDesktop.AddMessage("", "", 0, "Configuring PyAEDT panels in automation tab.") @@ -198,7 +204,7 @@ def install_pyaedt(): # run_command( # '"{}" --default-timeout=1000 install git+https://github.com/ansys/pyaedt.git@main'.format(pip_exe)) if args.version <= "231": - run_command('"{}" --default-timeout=1000 install pyaedt[all]=="0.9.3"'.format(pip_exe)) + run_command('"{}" --default-timeout=1000 install pyaedt[all]=="0.9.0"'.format(pip_exe)) run_command('"{}" --default-timeout=1000 install jupyterlab'.format(pip_exe)) run_command('"{}" --default-timeout=1000 install ipython -U'.format(pip_exe)) run_command('"{}" --default-timeout=1000 install ipyvtklink'.format(pip_exe)) @@ -222,14 +228,14 @@ def install_pyaedt(): # Extract all contents to a directory. (You can specify a different extraction path if needed.) zip_ref.extractall(unzipped_path) if args.version <= "231": - run_command('"{}" install --no-cache-dir --no-index --find-links={} pyaedt[all]=="0.9.3"'.format(pip_exe, + run_command('"{}" install --no-cache-dir --no-index --find-links={} pyaedt[all]=="0.9.0"'.format(pip_exe, unzipped_path)) else: run_command('"{}" install --no-cache-dir --no-index --find-links={} pyaedt[installer]'.format(pip_exe, unzipped_path)) else: if args.version <= "231": - run_command('"{}" --default-timeout=1000 install pyaedt[all]=="0.9.3"'.format(pip_exe)) + run_command('"{}" --default-timeout=1000 install pyaedt[all]=="0.9.0"'.format(pip_exe)) run_command('"{}" --default-timeout=1000 install jupyterlab'.format(pip_exe)) run_command('"{}" --default-timeout=1000 install ipython -U'.format(pip_exe)) run_command('"{}" --default-timeout=1000 install ipyvtklink'.format(pip_exe)) diff --git a/src/ansys/aedt/core/workflows/installer/console_setup.py b/src/ansys/aedt/core/workflows/installer/console_setup.py index faef655e0ae..446d0e4c637 100644 --- a/src/ansys/aedt/core/workflows/installer/console_setup.py +++ b/src/ansys/aedt/core/workflows/installer/console_setup.py @@ -37,26 +37,31 @@ import os import sys +aedt_process_id = int(sys.argv[1]) +version = sys.argv[2] +print("Loading the PyAEDT Console.") + try: - import ansys.aedt.core + if version <= "2023.1": + import pyaedt + else: + import ansys.aedt.core as pyaedt except ImportError: # Debug only purpose. If the tool is added to the ribbon from a GitHub clone, then a link # to PyAEDT is created in the personal library. console_setup_dir = os.path.dirname(__file__) if "PersonalLib" in console_setup_dir: sys.path.append(os.path.join(console_setup_dir, "../..", "..", "..")) - import ansys.aedt.core - + if version <= "2023.1": + import pyaedt + else: + import ansys.aedt.core as pyaedt # ansys.aedt.core.settings.use_grpc_api = False -settings = ansys.aedt.core.settings -from ansys.aedt.core import Desktop -from ansys.aedt.core.generic.general_methods import active_sessions -from ansys.aedt.core.generic.general_methods import is_windows - -aedt_process_id = int(sys.argv[1]) -version = sys.argv[2] -print("Loading the PyAEDT Console.") +settings = pyaedt.settings +from pyaedt import Desktop +from pyaedt.generic.general_methods import active_sessions +from pyaedt.generic.general_methods import is_windows def release(d): diff --git a/src/ansys/aedt/core/workflows/installer/jupyter_template.ipynb b/src/ansys/aedt/core/workflows/installer/jupyter_template.ipynb index f135f2e725c..b88ae0900f3 100644 --- a/src/ansys/aedt/core/workflows/installer/jupyter_template.ipynb +++ b/src/ansys/aedt/core/workflows/installer/jupyter_template.ipynb @@ -12,10 +12,7 @@ "outputs": [], "source": [ "import sys\n", - "import atexit\n", - "from ansys.aedt.core import *\n", - "import ansys.aedt.core\n", - "ansys.aedt.core.settings.use_grpc_api=False" + "import atexit" ] }, { @@ -34,6 +31,25 @@ "print(\"Loading the PyAEDT Console.\")" ] }, + { + "cell_type": "code", + "execution_count": null, + "outputs": [], + "source": [ + "if version > \"2023.1\":\n", + " from ansys.aedt.core import *\n", + " import ansys.aedt.core\n", + " ansys.aedt.core.settings.use_grpc_api=False\n", + "else:\n", + " from pyaedt import *\n", + " import pyaedt\n", + " pyaedt.settings.use_grpc_api=False" + ], + "metadata": { + "collapsed": false + }, + "id": "6232be8729ad9638" + }, { "cell_type": "code", "execution_count": null, diff --git a/src/pyaedt/workflows/installer/pyaedt_installer.py b/src/pyaedt/workflows/installer/pyaedt_installer.py index 8148869f681..0178052ab05 100644 --- a/src/pyaedt/workflows/installer/pyaedt_installer.py +++ b/src/pyaedt/workflows/installer/pyaedt_installer.py @@ -1 +1 @@ -from ansys.aedt.core.workflows.installeraedt_installer import * +from ansys.aedt.core.workflows.installer.pyaedt_installer import *