Skip to content

Commit

Permalink
Merge branch 'main' into feat/draft_filtersolutions
Browse files Browse the repository at this point in the history
  • Loading branch information
ramin4667 authored Jun 27, 2024
2 parents 23513f5 + 0d099fb commit 2c223b3
Show file tree
Hide file tree
Showing 13 changed files with 175 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ repos:

# validate GitHub workflow files
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.28.5
rev: 0.28.6
hooks:
- id: check-github-workflows

Expand Down
Binary file added _unittest/example_models/T98/cylinder_mesh.msh
Binary file not shown.
27 changes: 26 additions & 1 deletion _unittest/test_98_Icepak.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,11 @@ def test_12a_AssignMeshOperation(self):
mesh_level_Filter = "2"
component_name = ["RadioBoard1_1"]
mesh_level_RadioPCB = "1"
test = self.aedtapp.mesh.assign_mesh_level_to_group(mesh_level_Filter, group_name)
assert self.aedtapp.mesh.assign_mesh_level_to_group(mesh_level_Filter, group_name)
test = self.aedtapp.mesh.assign_mesh_level_to_group(mesh_level_Filter, group_name, name="Test")
assert test
test2 = self.aedtapp.mesh.assign_mesh_level_to_group(mesh_level_Filter, group_name, name="Test")
assert test.name != test2.name
# assert self.aedtapp.mesh.assignMeshLevel2Component(mesh_level_RadioPCB, component_name)
test = self.aedtapp.mesh.assign_mesh_region(component_name, mesh_level_RadioPCB, is_submodel=True)
assert test
Expand Down Expand Up @@ -1741,3 +1744,25 @@ def test_78_restart_solution(self):
"test_78-1", "{} : SteadyState".format(s1.name), project="FakeFolder123"
)
assert not s2.start_continue_from_previous_setup("test_78-12", "{} : SteadyState".format(s1.name))

def test_79_mesh_reuse(self):
self.aedtapp.insert_design("test_79")
self.aedtapp.set_active_design("test_79")
cylinder = self.aedtapp.modeler.create_cylinder(1, [0, 0, 0], 5, 30)
assert not self.aedtapp.mesh.assign_mesh_reuse(
cylinder.name,
os.path.join(local_path, "../_unittest/example_models", test_subfolder, "nonexistent_cylinder_mesh.msh"),
)
assert self.aedtapp.mesh.assign_mesh_reuse(
cylinder.name, os.path.join(local_path, "../_unittest/example_models", test_subfolder, "cylinder_mesh.msh")
)
assert self.aedtapp.mesh.assign_mesh_reuse(
cylinder.name,
os.path.join(local_path, "../_unittest/example_models", test_subfolder, "cylinder_mesh.msh"),
"name_reuse",
)
assert self.aedtapp.mesh.assign_mesh_reuse(
cylinder.name,
os.path.join(local_path, "../_unittest/example_models", test_subfolder, "cylinder_mesh.msh"),
"name_reuse",
)
3 changes: 3 additions & 0 deletions doc/source/Getting_started/Installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ The user can select the AEDT application to install the specific workflow.
:width: 400
:alt: PyAEDT toolkit manager 2

For additional information about AEDT extensions,
see `Extensions <https://aedt.docs.pyansys.com/version/stable/User_guide/extensions.html>`_.


Install on CPython from PyPI
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
Binary file modified doc/source/Resources/toolkits_ribbon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions doc/source/User_guide/extensions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Extensions
==========

Extensions provide a simplified interface to perform automated workflows in AEDT.
In AEDT, you can use the Extension Manager to add or remove extensions.
For more information, see `Extension Manager <https://aedt.docs.pyansys.com/version/stable/Getting_started/Installation.html#extension-manager>`_.

Extensions are generally tool-specific and are therefore only accessible given the appropriate context. The following sections provide further clarification.

You can launch extensions in standalone mode from the console or a Python script.

Project extensions
==================

Project extension apply to all extensions that are applicable for all AEDT applications.

.. grid:: 2

.. grid-item-card:: Import Nastran
:link: pyaedt_extensions_doc/project
:link-type: doc

Import a Nastran or STL file in any 3D modeler application.

.. toctree::
:hidden:
:maxdepth: 2

pyaedt_extensions_doc/project

HFSS extensions
===============


HFSS 3D Layout extensions

Check warning on line 35 in doc/source/User_guide/extensions.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/User_guide/extensions.rst#L35

[Google.Headings] 'HFSS 3D Layout extensions' should use sentence-style capitalization.
Raw output
{"message": "[Google.Headings] 'HFSS 3D Layout extensions' should use sentence-style capitalization.", "location": {"path": "doc/source/User_guide/extensions.rst", "range": {"start": {"line": 35, "column": 1}}}, "severity": "WARNING"}
=========================
8 changes: 8 additions & 0 deletions doc/source/User_guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ For end-to-end examples, see `Examples <https://aedt.docs.pyansys.com/version/st

How to launch AEDT and create a project.

.. grid-item-card:: Extensions
:link: extensions
:link-type: doc
:margin: 2 2 0 0

How to use PyAEDT extensions.

.. grid-item-card:: Modeler
:link: modeler
:link-type: doc
Expand Down Expand Up @@ -72,6 +79,7 @@ For end-to-end examples, see `Examples <https://aedt.docs.pyansys.com/version/st
:maxdepth: 2

intro
extensions
modeler
mesh
setup
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions doc/source/User_guide/pyaedt_extensions_doc/project.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Import Nastran
==============

You can import a Nastran or STL file in any 3D modeler. You can also preview the imported file and decimate it prior to import.

You can access the extension from the icon created on the **Automation** tab using the Extension Manager.

The following image shows the extension user interface:

.. image:: import_nastran_ui.png
:width: 800
:alt: Import Nastran UI

You can also launch the extension user interface from the terminal:

.. code::
SET PYAEDT_SCRIPT_PORT=50051
SET PYAEDT_SCRIPT_VERSION=2024.1
python.exe path/to/pyaedt/workflows/project/import_nastran.py
The available arguments are: ``file_path``, ``planar``, ``lightweight``, and ``decimate``.
You can obtain these arguments from the help with this command:

.. code::
python.exe path/to/pyaedt/workflows/project/import_nastran.py --help
This code shows how to pass the input file as an argument, which doesn't launch the user interface:

.. code::
export PYAEDT_SCRIPT_PORT=50051
export PYAEDT_SCRIPT_VERSION=2024.1
python.exe path/to/pyaedt/workflows/project/import_nastran.py --file_path="my_file.stl"
Finally, this code shows how you can run the extension directly from a Python script:

.. code:: python
import pyaedt
import os
from pyaedt.workflows.project.import_nastran import main
file_path = "my_file.stl"
hfss = pyaedt.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
# Launch extension
main({"file_path": file_path, "lightweight": True, "decimate": 0.0, "planar": True, "is_test": False})
2 changes: 0 additions & 2 deletions doc/source/create_documentation.bat

This file was deleted.

2 changes: 2 additions & 0 deletions doc/styles/Vocab/ANSYS/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ efields
EMIT
FEBI
FE-BI
file_path
getters
globals
[Gg]gRPC
Expand All @@ -47,6 +48,7 @@ Maxwell Circuit
multiphysics
multiplot
namespaces
Nastran
netlist
Nexxim
numpy
Expand Down
45 changes: 44 additions & 1 deletion pyaedt/modules/MeshIcepak.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
# 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.

from abc import abstractmethod
from collections import OrderedDict
import os.path
import warnings

from pyaedt.generic.DataHandlers import _dict2arg
Expand Down Expand Up @@ -1638,6 +1638,7 @@ def assign_mesh_level_to_group(
for el in self.meshoperations:
if el.name == name:
name = generate_unique_name(name)
break
else:
name = generate_unique_name("MeshLevel")
props = OrderedDict(
Expand All @@ -1653,3 +1654,45 @@ def assign_mesh_level_to_group(
mop.create()
self.meshoperations.append(mop)
return mop

def assign_mesh_reuse(self, assignment, mesh_file, name=None):
"""Assign a mesh file to objects.
Parameters
----------
assignment : str or list
Names of objects to which the mesh file is assignment.
mesh_file : str
Path to the mesh file.
name : str, optional
Name of the mesh operation. The default is ``None``, in which case it will be
generated automatically.
Returns
-------
:class:`pyaedt.modules.Mesh.MeshOperation`
References
----------
>>> oModule.AssignMeshOperation
"""
if not os.path.exists(mesh_file):
self._app.logger.error("Mesh file does not exist.")
return False
if name:
for el in self.meshoperations:
if el.name == name:
name = generate_unique_name(name)
break
else:
name = generate_unique_name("MeshReuse")
if not isinstance(assignment, list):
assignment = [assignment]
props = OrderedDict(
{"Enable": True, "Mesh Reuse Enabled": True, "Mesh Reuse File": mesh_file, "Objects": assignment}
)
mop = MeshOperation(self, name, props, "Icepak")
mop.create()
self.meshoperations.append(mop)
return mop
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ tests = [
"pyvista>=0.38.0,<0.44",
# Never directly imported but required when loading ML related file see #4713
"scikit-learn>=1.0.0,<1.6",
"scikit-rf>=0.30.0,<1.1",
"scikit-rf>=0.30.0,<1.2",
"SRTM.py",
"utm",
"vtk==9.2.6; python_version < '3.12'",
Expand Down Expand Up @@ -89,7 +89,7 @@ doc = [
#"pytest-sphinx",
"pyvista>=0.38.0,<0.44",
"recommonmark",
"scikit-rf>=0.30.0,<1.1",
"scikit-rf>=0.30.0,<1.2",
"Sphinx==5.3.0; python_version == '3.7'",
"Sphinx>=7.1.0,<7.4; python_version > '3.7'",
"sphinx-autobuild==2021.3.14; python_version == '3.7'",
Expand Down Expand Up @@ -134,7 +134,7 @@ all = [
"fast-simplification>=0.1.7",
# Never directly imported but required when loading ML related file see #4713
"scikit-learn>=1.0.0,<1.6",
"scikit-rf>=0.30.0,<1.1",
"scikit-rf>=0.30.0,<1.2",
"SRTM.py",
"utm",
"vtk==9.2.6; python_version < '3.12'",
Expand All @@ -149,7 +149,7 @@ installer = [
"pyvista>=0.38.0,<0.44",
# Never directly imported but required when loading ML related file see #4713
"scikit-learn>=1.0.0,<1.6",
"scikit-rf>=0.30.0,<1.1",
"scikit-rf>=0.30.0,<1.2",
"SRTM.py",
"utm",
"vtk==9.2.6; python_version < '3.12'",
Expand Down

0 comments on commit 2c223b3

Please sign in to comment.