MSC Adams Extension for Visual Studio Code
This is an early version. If you are interested in using it, please reach out and let me
know which features you are most interested in. Thanks!
Table of Contents
Features
Syntax highlighting
- Adams View Command Languange (.cmd)
- Adams Solver Dataset Files (.adm)
- Adams Solver Command Files (.acf)
``
Adams View Command Language Intellisense
- Adams Function Completion Provider
- Adams Function Documentation Hover Provider
Intellisense support for Adams View Python Interface
- Completion provider
- Function signature help provider
- Type hinting
[!NOTE]
You may need to manually activate the extension using msc_adams.activate
for these features to work
Debugging python scripts in Adams View
You can debug python scripts in Adams View using the Python Extension. This extension provides a convenient button to attach the debugger to an existing Adams View process.
[!NOTE]
Debugging is supported in Adams Car too! See
Debugger not breaking when attached to Adams Car
if you are having trouble getting the debugger to break in Adams Car.
Steps to debug a python script in Adams View
- Open an Adams View session
- Open the python script you want to debug in Visual Studio Code
- Click the Debug Python Script in Adams button in the top right of the editor
- Note: If you have multiple Adams View sessions open, you will be prompted to select one
- Set breakpoints in the python script
- In the Adams View session, import the python script
- The python script will break at the breakpoints.
Run in Adams View
[!IMPORTANT]
The command server must be running for these features to work. The demos below show how to
start the command server.
[!TIP]
Add command_server start
to your startup macro (aviewAS.cmd or aview.cmd) to automatically
start the command server when Adams View is opened. This will allow you to run python scripts in
Adams View without having to manually start the command server.
Run selection in Adams View (works for both CMD and Python files)
Run File in Adams View (This works for both CMD and Python files)
[!NOTE]
For python files, the button is located within the existing python run button stack.
Open Adams View From Explorer
Snippets
- Adams View Command Language Snippets
- Adams View Python Interface Snippets
Extension Settings
This extension contributes the following settings:
- msc-adams.adams_launch_command: Path to the mdi.bat file in your Adams installation.
Customizing Syntax Colors
You may override the extension's default syntax colors using the editor.tokenColorCustomizations
setting. The extension uses the following scopes:
- parameter.reference
- variable
- constant
- arguments
- parameter.definition
- selfParameter
- command.command
- command.control
- command.argument
- command.argument.continued
The example below would change the color and font style of the variable
scope
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "variable",
"settings": {
"foreground": "#02485e",
"fontStyle": "bold"
}
}
]
}
Run In Adams: Substitute Params
When enabled (default), the extension will substitute macro parameters (i.e. variables prefixed
with $
) in the macro/selection before running it in Adams View. This will only work if the
parameter is defined in the the macro with a default value
For example, the following macro will run in Adams View with the parameter $part
substituted with
PART_1
and $mass
substituted with 1
.
!$part:t=part:d=PART_1
!$mass:t=real:d=1
part modify rigid_body mass_properties part=$part mass=$mass
However, the following macro will not run in Adams View because the parameter $part
is not
defined with a default value.
!$part:t=part
!$mass:t=real:d=1
part modify rigid_body mass_properties part=$part mass=$mass
Run In Adams: Substitute $_self
When running a macro or a selection of a macro, the extension will substitute $_self
with the
a user defined value. The default is .mdi
. This is useful when the macro uses local variables.
[!NOTE]
It is common convention to clear out local variables at the end of a macro using
var del var=$_self.*
. If using this convention, you should not use the default .mdi
. Instead,
it is recommended to create an empty library in adams view and set the value of
msc-adams.runInAdams.substituteSelf
to the name of the library.
Requirements
Known Issues
Attaching the Debugger to Adams View does not work in version 2023
The debugger appears to attach but fails to stop at break points.
[!TIP]
A workaround is to simply import the threading module before attaching the debugger. The easiest
way to do this is to open the adams view command line, switch to python, and run
import threading
. You can also automate this by adding
var set var=.mdi.tmp_int int=(eval(run_python_code("import threading")))
to aviewAS.cmd.
Intellisense Adams Command Language functions does not work for every function
It's a work in progress. The help documentation for each function needs to be converted to a
markdown file and I simply haven't had time to do every function.
Equal Sign In A String On A Continuation Line
An equal sign in a string on a continuation line (i.e. a line following &
) breaks syntax
highlighting for the rest of the file.
A workaround is to add !"
after the line with the equal sign. As shown below.
Contributing
...
Support
Submit issues to https://github.com/bthornton191/adams_vscode/issues