Plugin manager overview#

MAPDL plugins extend the solver with additional commands at runtime. The ansPlugin class, accessed via mapdl.plugins, lets you load, inspect, and unload plugins from a running MAPDL session without leaving Python.

警告

Plugin support requires MAPDL 25.2 or later.

注釈

To create your own plugins, visit MAPDL documentation or contact ANSYS support.

Accessing the plugin manager#

The plugin manager is available as a property on every Mapdl instance:

>>> from ansys.mapdl.core import launch_mapdl
>>> mapdl = launch_mapdl()
>>> plugins = mapdl.plugins
>>> plugins
MAPDL Plugins
----------------
  (no plugins loaded)

Loading a plugin#

Use load() with the plugin name and an optional feature string:

>>> mapdl.plugins.load("my_plugin", feature="advanced")

After loading, each command that the plugin registers is injected as an attribute on the mapdl object. Characters that are not valid Python identifiers are transformed: * becomes star and / becomes slash.

Listing loaded plugins#

list() returns the names of all currently loaded plugins:

>>> mapdl.plugins.list()
['my_plugin']

注釈

Plugin tracking is session-scoped. list() first tries *PLUG,LIST on the MAPDL server. When the server returns no output, for example, after reconnecting to an already-running MAPDL instance, it falls back to the internal state that was built up during the current Python session.

Inspecting plugin commands#

commands() returns the attribute names that a plugin registered on the mapdl object:

>>> mapdl.plugins.commands("my_plugin")
['my_command', 'another_command']

Printing a summary#

Printing mapdl.plugins (or calling str() on it) shows a table with each loaded plugin, its feature string, and how many commands it registered:

>>> print(mapdl.plugins)
MAPDL Plugins
----------------
my_plugin                    : advanced  [2 commands]

Unloading a plugin#

Use unload() to remove a plugin and clean up all the commands it added:

>>> mapdl.plugins.unload("my_plugin")
>>> mapdl.plugins.list()
[]

For the full API reference, see Plugin manager.