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!
- MSC Adams Extension for Visual Studio Code
- Table of Contents
- Features
- Extension Settings
- Requirements
- Known Issues
- Contributing
- Support
- Adams View Command Languange (.cmd)
- Adams Solver Dataset Files (.adm)
- Adams Solver Command Files (.acf) ``
- Adams Function Completion Provider
- Adams Function Documentation Hover Provider
- 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
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.
- 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.
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.
-
Open Adams View in a directory from the Explorer by right clicking and selecting Open View
-
Open a .cmd model file in Adams View from the Explorer by right clicking and selecting Open In View
- Adams View Command Language Snippets
- Adams View Python Interface Snippets
This extension contributes the following settings:
- msc-adams.adams_launch_command: Path to the mdi.bat file in your Adams installation.
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"
}
}
]
}
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
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.
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.
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.
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.
...
Submit issues to https://github.com/bthornton191/adams_vscode/issues