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: update documentation #939

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
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/935.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`ansys-mechanical-ideconfig` command
1 change: 1 addition & 0 deletions doc/changelog.d/939.maintenance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
update documentation
11 changes: 6 additions & 5 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from ansys.mechanical.core.embedding.initializer import SUPPORTED_MECHANICAL_EMBEDDING_VERSIONS

# necessary when building the sphinx gallery
pymechanical.BUILDING_GALLERY = True
pymechanical.BUILDING_GALLERY = False

# suppress annoying matplotlib bug
warnings.filterwarnings(
Expand Down Expand Up @@ -49,6 +49,7 @@
"notfound.extension",
"numpydoc",
"sphinx.ext.autodoc",
"sphinx.ext.autosectionlabel",
"sphinx.ext.autosummary",
"sphinx.ext.coverage",
"sphinx.ext.doctest",
Expand Down Expand Up @@ -207,10 +208,10 @@
"icon": "fa fa-comment fa-fw",
},
],
"cheatsheet": {
"file": "cheatsheet/cheat_sheet.qmd",
"title": "PyMechanical cheat sheet",
},
# "cheatsheet": {
# "file": "cheatsheet/cheat_sheet.qmd",
# "title": "PyMechanical cheat sheet",
# },
"ansys_sphinx_theme_autoapi": {"project": project, "templates": "_templates/autoapi"},
"navigation_depth": 10,
}
Expand Down
4 changes: 2 additions & 2 deletions doc/source/user_guide_embedding/configuration.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _ref_embedding_user_guide_addin_configuration:

Addin configuration
===================
Customize addin configuration
=============================

There are some configuration options that are respected when loading an embedded instance
of Mechanical into python.
Expand Down
4 changes: 2 additions & 2 deletions doc/source/user_guide_embedding/globals.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _ref_embedding_user_guide_globals:

Globals
=======
Add global variables
====================

When using Mechanical scripting APIs (in either Mechanical's graphical user interface or when
sending scripts to a remote session of Mechanical), there are many global variables that are
Expand Down
110 changes: 18 additions & 92 deletions doc/source/user_guide_embedding/index.rst
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
.. _ref_user_guide_embedding:

Embedded instance
=================
-----------------

This section provides an overview of how you use PyMechanical to embed
an instance of Mechanical in Python.

..
This toctree must be a top-level index to get it to show up in
pydata_sphinx_theme.
This section provides an overview of how you use PyMechanical to embed an instance of Mechanical in Python.

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

self
configuration
globals
logging
libraries
new_features
globals
libraries
configuration
logging

Overview
--------
^^^^^^^^

The `App <../api/ansys/mechanical/core/embedding/app/App.html>`_ class provides
a Mechanical instance:
Create an instance of Mechanical with the `App <../api/ansys/mechanical/core/embedding/app/App.html>`_ class:

.. code:: python

Expand All @@ -42,79 +36,11 @@ available from built-in Mechanical scripting:
* Tree: ``Application.DataModel.Tree``
* Graphics: ``Application.ExtAPI.Graphics``

Besides scripting entry points, many other types and objects are available from
built-in Mechanical scripting. To learn how to import scripting entry points,
namespaces, and types, see :ref:`ref_embedding_user_guide_globals`.

Additional configuration
------------------------

By default, an instance of the `App`_ class
uses the same Addin configuration as standalone Mechanical. To customize Addins, see
:ref:`ref_embedding_user_guide_addin_configuration`.

Diagnosing problems with embedding
----------------------------------

In some cases, debugging the embedded Mechanical instance may require additional logging.
For information on how to configure logging, see :ref:`ref_embedding_user_guide_logging`.

Running PyMechanical embedding scripts inside Mechanical with IronPython
------------------------------------------------------------------------

If your PyMechanical embedding script does not use any other third-party Python package, such as `NumPy`,
it is possible to adapt it so that it can run inside of Mechanical with IronPython.
The scripting occurs inside Mechanical's command line interface. For instance, consider the following PyMechanical code:

.. code:: python

from ansys.mechanical.core import App

app = App()
app.update_globals(globals())
ns = DataModel.Project.Model.AddNamedSelection()
ns.Name = "Jarvis"

The above code can be written as a Python file, such as ``file.py`` with only the following content:

.. code:: python

ns = DataModel.Project.Model.AddNamedSelection()
ns.Name = "Jarvis"

Because the file does not contain the PyMechanical import statements, you can run
``file.py`` using the command line inside Mechanical.

**Using command line interface (CLI)**

This can be achieved on both the Windows and Linux platforms using
``ansys-mechanical`` cli from the virtual environment where ``ansys-mechanical-core``
has been installed. Activate the virtual environment and then use CLI to run the scripts.
If multiple Mechanical versions are installed in the same system,
versions can be specified using ``-r`` flag. Use ``-h`` for more information.

.. code::

ansys-mechanical -i file.py

.. note::

Alternately user can use the following commands in the command prompt of Windows and the terminal
for Linux systems.

**On Windows**

.. code::

"C:/Program Files/ANSYS Inc/v242/aisol/bin/winx64/AnsysWBU.exe -DSApplet -AppModeMech -script file.py"

PowerShell users can run the preceding command without including the opening and
closing quotation marks.

**On Linux**

.. code::

/usr/ansys_inc/v242/aisol/.workbench -DSApplet -AppModeMech -script file.py
Additional information
^^^^^^^^^^^^^^^^^^^^^^

On either Windows or Linux, add the command line argument ``-b`` to run the script in batch mode.
* :ref:`ref_embedding_user_guide_new_features`: See new features of the embedding instance for PyMechanical.
* :ref:`ref_embedding_user_guide_globals`: See how to import scripting entry points, namespaces, and types with globals.
* :ref:`ref_embedding_user_guide_addin_configuration`: See additional addin configuration options. By default, an instance of the `App`_ class uses the same Addin configuration as standalone Mechanical.
* :ref:`ref_embedding_user_guide_logging`: See information on how to configure logging in Mechanical for help with debugging the Mechanical instance.
* :ref:`ref_embedding_user_guide_scripts_inside_mechanical`: See information about how to run embedding scripts inside Mechanical with IronPython with the ``ansys-mechanical`` command.
4 changes: 2 additions & 2 deletions doc/source/user_guide_embedding/libraries.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _ref_embedding_user_guide_libraries:

Libraries
=========
Add Mechanical Python libraries

Check warning on line 3 in doc/source/user_guide_embedding/libraries.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/user_guide_embedding/libraries.rst#L3

[Google.Headings] 'Add Mechanical Python libraries' should use sentence-style capitalization.
Raw output
{"message": "[Google.Headings] 'Add Mechanical Python libraries' should use sentence-style capitalization.", "location": {"path": "doc/source/user_guide_embedding/libraries.rst", "range": {"start": {"line": 3, "column": 1}}}, "severity": "WARNING"}
===============================

.. note::

Expand Down
6 changes: 3 additions & 3 deletions doc/source/user_guide_embedding/logging.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _ref_embedding_user_guide_logging:

Logging
=======
Diagnose problems with logging
==============================

Mechanical has a logging system that is useful when debugging issues. Normally, it is
enabled by setting environment variables before starting Mechanical. With PyMechanical,
Expand All @@ -22,7 +22,7 @@ For example:
_ = mech.App()

After the embedded application has been created, you can write messages to the same
log using the `Logger <../api/ansys/mechanical/core/embedding/logger/Logger.html>` class like this:
log using the `Logger <../api/ansys/mechanical/core/embedding/logger/Logger.html>`_ class like this:

.. code:: python

Expand Down
Loading
Loading