Interactive Version

The interactive version of SysIDE Automator provides a command-driven interface for engaging directly with SysML v2 models through a terminal.

Such approach enables quick inspection, validation and modification of the model using structured commands, eliminating the need to create and execute Python scripts for simple and quick use-cases.

Learn about:


Example Model: copy this model into your example_model.sysml file to test out the features of SysIDE Interactive, or use your own model:

package 'Part Tree Example' {
    part def Electrical;
    part def Mechanical;

    part Automobile {
        part 'Drive Train' {
            part Battery : Electrical;
            part Motor : Electrical;
        }

        part Chassis {
            part Suspension : Mechanical;
            part Body : Mechanical;
        }
    }
}

Checking for Errors

In First Example, we showcased how to check the model for errors using syside check. One other option is simply to try and load the model, since syside.load_model will automatically check the model for errors and report them.

To demonstrate this, remove the line part def Electrical; from the model, and try loading the model by running the following command:

python -m syside interactive example_model.sysml

This will automatically check the model for any errors. You should get an output similar to the following:

example_model.sysml:7:26: error (reference-error): No Type named 'Electrical' found.
7 |           part Battery : Electrical;
  |                          ^^^^^^^^^^

example_model.sysml:8:24: error (reference-error): No Type named 'Electrical' found.
8 |           part Motor : Electrical;
  |                        ^^^^^^^^^^

Counting Parts

One advantage of the interactive version is the ability to run simple scripts that do not warrant a full Python script. For example, we can count the number of parts in the model by running the following command:

>>> len(list(model.nodes(syside.PartUsage)))
7

We see that it correctly counted the 7 parts in the model. Similarly, we can count the number of part definitions by running a slightly different command:

>>> len(list(model.nodes(syside.PartDefinition)))
2

You could also use the same idea to count ActionUsage, etc.

Complex Commands

Interactive mode works the same way as the Python API, so you can use the same functions and methods. However, sometimes you might need more than a single line of code to do something.

For example, we can list all the part definitions in the model by running the following command:

>>> for element in model.nodes(syside.PartDefinition):
...     print(element.name if element.name else "anonymous")

Electrical
Mechanical

The interactive version will recognize when an extra line of code is needed (in this case - to define the for loop) and will prompt you to continue. To complete this loop, simply press Enter after inputting an empty line.

Once you are done using the interactive mode, you can exit by typing exit and pressing Enter.