Autocomplete#
The ansys-mechanical-stubs package provides typehints for Mechanical scripting.
This package is automatically installed when you install PyMechanical.
Setting up autocomplete in VS Code#
The ansys-mechanical-ideconfig command updates your VS Code settings.json with the
settings that are necessary for autocomplete to work with the ansys-mechanical-stubs
dependency. This command takes in
three arguments: --ide vscode, --target user or --target workspace,
and --revision <version>. If the revision is not provided, ansys-tools-common
retrieves the Mechanical version from your system.
Usage:
ansys-mechanical-ideconfig --ide vscode --target user --revision 261
Terminal output for Windows user’s settings.json file:
Updated C:\Users\{username}\AppData\Roaming\Code\User\settings.json with the following information:
{
"python.autoComplete.extraPaths": [
"{project_directory}\\.venv\\Lib\\site-packages\\ansys\\mechanical\\stubs\\v261"
],
"python.analysis.extraPaths": [
"{project_directory}\\.venv\\Lib\\site-packages\\ansys\\mechanical\\stubs\\v261"
]
}
The command preserves existing settings and appends the Mechanical stubs path if it is not already present.
Note
After running ansys-mechanical-ideconfig, you may need to reload the VS Code window
for the autocomplete hints to take effect. Open the command palette
(Ctrl+Shift+P) and run Developer: Reload Window.
Limitations#
Autocomplete is only supported in VS Code.
Mechanical scripting autocomplete is only available for phrases starting with
Ansys.Not all Mechanical scripting APIs are currently supported. If some are missing that you need, create an issue here.