Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/6961.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Venv console panel
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
[Console]
icon = "console.png"
name = "PyAEDT Console"
script = "console_setup.py"
icon = "console.png"
template = "pyaedt_console"

[VenvConsole]
icon = "console.png"
name = "Venv Console"
script = ""
template = "venv_console"

[Jupyter]
icon = "jupyter.png"
name = "Jupyter Notebook"
script = "jupyter_template.ipynb"
icon = "jupyter.png"
template = "jupyter"

[Run_Script]
icon = "run_script.png"
name = "Run PyAEDT Script"
script = ""
icon = "run_script.png"
template = "run_pyaedt_script"

[ExtensionManager]
icon = "extension_manager.png"
name = "Extension Manager"
script = "extension_manager.py"
icon = "extension_manager.png"
template = "run_extension_manager"

[VersionManager]
icon = "version_manager.png"
name = "Version Manager"
script = "version_manager.py"
icon = "version_manager.png"
template = "run_pyaedt_toolkit_script"
17 changes: 15 additions & 2 deletions src/ansys/aedt/core/extensions/installer/pyaedt_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,22 @@ def add_pyaedt_to_aedt(
def __add_pyaedt_tabs(personal_lib, aedt_version, skip_version_manager, odesktop=None):
"""Add PyAEDT tabs in AEDT."""
if skip_version_manager:
pyaedt_tabs = ["Console", "Jupyter", "Run_Script", "ExtensionManager"]
pyaedt_tabs = [
"Console",
"VenvConsole",
"Jupyter",
"Run_Script",
"ExtensionManager",
]
else:
pyaedt_tabs = ["Console", "Jupyter", "Run_Script", "ExtensionManager", "VersionManager"]
pyaedt_tabs = [
"Console",
"VenvConsole",
"Jupyter",
"Run_Script",
"ExtensionManager",
"VersionManager",
]

extensions_catalog = read_toml(os.path.join(os.path.dirname(__file__), "extensions_catalog.toml"))

Expand Down
4 changes: 3 additions & 1 deletion src/ansys/aedt/core/extensions/templates/jupyter.py_build
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# -*- coding: utf-8 -*-
#
# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# -*- coding: utf-8 -*-
#
# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# -*- coding: utf-8 -*-
#
# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# -*- coding: utf-8 -*-
#
# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# -*- coding: utf-8 -*-
#
# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
Expand Down
111 changes: 111 additions & 0 deletions src/ansys/aedt/core/extensions/templates/venv_console.py_build
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

"""
* * * This script is meant to run in IronPython within AEDT. * * *

This script opens a native terminal with the PyAEDT virtual environment activated.

"""
import os
import sys

is_linux = os.name == "posix"

if is_linux:
import subprocessdotnet as subprocess
else:
import subprocess

sys.path.append(r"##EXTENSION_TEMPLATES##")

import pyaedt_utils


def main():
try:
# Get AEDT version
version_short = oDesktop.GetVersion()[2:6].replace(".", "")
oDesktop.AddMessage("", "", 0, "Opening terminal with PyAEDT environment...")

# Virtual environment path - use default PyAEDT venv location
if is_linux:
venv_path = os.path.join(os.path.expanduser("~"), ".pyaedt_env")
else:
# Windows: C:\Users\<username>\AppData\Roaming\.pyaedt_env
venv_path = os.path.join(os.getenv("APPDATA"), ".pyaedt_env")

if not os.path.exists(venv_path):
pyaedt_utils.show_error(
"PyAEDT virtual environment not found at: {}".format(venv_path),
oDesktop
)
return

# Add environment variables
pyaedt_utils.environment_variables(oDesktop)
pyaedt_utils.set_ansys_em_environment(oDesktop)

# Open terminal with venv activated
if is_linux:
# For Linux systems
command = pyaedt_utils.get_linux_terminal_command()
if not command:
pyaedt_utils.show_error("No terminal found on system.", oDesktop)
return
bash_activate = os.path.normpath(os.path.join(venv_path, "bin", "activate"))
venv_flag = pyaedt_utils.check_file(bash_activate, oDesktop)
if not venv_flag:
return
command.extend(["bash", "-c", "source '{}' && bash".format(bash_activate)])
my_env = os.environ.copy()
subprocess.Popen(command, env=my_env)
else:
# For Windows systems - use cmd.exe to launch PowerShell
venv_activate = os.path.normpath(os.path.join(venv_path, "3_10", "Scripts", "Activate.ps1"))

# Check if venv activation script exists
venv_flag = pyaedt_utils.check_file(venv_activate, oDesktop)
if not venv_flag:
return

my_env = os.environ.copy()

# Create PowerShell command to activate venv and change directory
# Use cmd.exe with /c to properly launch PowerShell
repo_path = os.path.dirname(venv_path)
ps_command = "& '{0}'; Set-Location '{1}'".format(venv_activate, repo_path)

# Use cmd.exe to launch PowerShell (more reliable with IronPython subprocess)
command = 'cmd.exe /c start powershell.exe -NoExit -Command "{0}"'.format(ps_command)
subprocess.Popen(command, env=my_env)

oDesktop.AddMessage("", "", 0, "Terminal opened successfully with virtual environment activated.")

except Exception as e:
pyaedt_utils.show_error(str(e), oDesktop)


if __name__ == "__main__":
main()
4 changes: 3 additions & 1 deletion src/pyaedt/workflows/templates/jupyter.py_build
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# -*- coding: utf-8 -*-
#
# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
Expand Down
4 changes: 3 additions & 1 deletion src/pyaedt/workflows/templates/pyaedt_console.py_build
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# -*- coding: utf-8 -*-
#
# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# -*- coding: utf-8 -*-
#
# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
Expand Down
4 changes: 3 additions & 1 deletion src/pyaedt/workflows/templates/run_pyaedt_script.py_build
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# -*- coding: utf-8 -*-
#
# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# -*- coding: utf-8 -*-
#
# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# -*- coding: utf-8 -*-
#
# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
Expand Down