Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHORE: Add template extension - get started #5538

Merged
merged 16 commits into from
Dec 12, 2024
Merged
14 changes: 14 additions & 0 deletions doc/source/User_guide/extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,19 @@ They are small automated workflows with a simple UI.
Convert Twin Builder design to Circuit.


Templates
~~~~~~~~~
Templates to show how to build an extension consisting of a small automated workflow with a simple UI.

.. grid:: 2

.. grid-item-card:: Extension template
:link: pyaedt_extensions_doc/templates/getting_started
:link-type: doc
:margin: 2 2 0 0

Simple extension template to get started.

.. toctree::
:hidden:
:maxdepth: 1
Expand All @@ -189,6 +202,7 @@ They are small automated workflows with a simple UI.
pyaedt_extensions_doc/icepak/index
pyaedt_extensions_doc/circuit/index
pyaedt_extensions_doc/twinbuilder/index
pyaedt_extensions_doc/templates/index


Open source toolkits
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Extension template
==================

Template to help the user create an extension from scratch.

The extension provides a graphical user interface for configuration, or it can be used in batch mode via command line arguments.

The following image shows the extension user interface:

.. image:: ../../../_static/extensions/extension_template.png
:width: 800
:alt: Extension template UI


Features
--------

- Create a sphere providing information such as the origin coordinates and radius.
- Allow users to browse and select an **.aedt** file to load in AEDT.
- Display name of the active project.
- Support of light and dark themes for the GUI.

Run the extension
-----------------

The extension can be run from a Python script in the following way:

.. code:: python

import ansys.aedt.core
import os

from ansys.aedt.core.workflows.templates.template_get_started import main

hfss = ansys.aedt.core.Hfss()

# Specify the AEDT session to connect
os.environ["PYAEDT_SCRIPT_PORT"] = str(hfss.desktop_class.port)
os.environ["PYAEDT_SCRIPT_VERSION"] = hfss.desktop_class.aedt_version_id

main({"origin_x": 2, "radius": 6, "is_test": True})

Command line
------------

The extension can also be run directly via the command line for batch processing.

The script accepts the following arguments:
- ``**origin_x**`` : x origin coordinate.
- ``**origin_y**`` : y origin coordinate.
- ``**origin_z**`` : z origin coordinate.
- ``**radius**`` : radius.
- ``**file_path**`` : file path to the **.aedt** file.

Use the following syntax to run the extension:

.. toctree::
:maxdepth: 2

../commandline
11 changes: 11 additions & 0 deletions doc/source/User_guide/pyaedt_extensions_doc/templates/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Extension templates
===================

.. grid:: 2

.. grid-item-card:: Extension getting started
:link: getting_started
:link-type: doc
:margin: 2 2 0 0

Simple extension template to get started.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions src/ansys/aedt/core/workflows/installer/extension_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,12 @@ def button_is_clicked(
icon = os.path.abspath(os.path.join(product_path, selected_toolkit_info.get("icon")))

valid_name = name is not None and not os.path.isdir(name)
valid_file = file is not None and os.path.isfile(file)

valid_file = False
if not file:
valid_file = True
elif os.path.isfile(file):
valid_file = True

if selected_toolkit_name != "Custom" and selected_toolkit_info.get("pip"):
if is_toolkit_installed(selected_toolkit_name, toolkit_level) and install_action:
Expand Down Expand Up @@ -289,7 +294,7 @@ def button_is_clicked(

if not file:
file = os.path.join(
os.path.dirname(ansys.aedt.core.workflows.templates.__file__), "extension_template.py"
os.path.dirname(ansys.aedt.core.workflows.templates.__file__), "template_get_started.py"
)

if os.path.isfile(executable_interpreter):
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/aedt/core/workflows/project/kernel_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def edit_sols(self):
def browseFiles():
filename = filedialog.askopenfilename(
initialdir="/",
title="Select a Electronics File",
title="Select an Electronics File",
filetypes=(("AEDT", ".aedt *.a3dcomp"), ("all files", "*.*")),
)
text.insert(tkinter.END, filename)
Expand Down
71 changes: 0 additions & 71 deletions src/ansys/aedt/core/workflows/templates/extension_template.py

This file was deleted.

Loading
Loading