javapythonapimagic-draw

Does MagicDraw have a Python interface or API wrapper?


I use MagicDraw for Model Based System Engineering (MBSE) using UML and SysML. I know there is an API based in Java, which the tool is primarily written in, but I'd like to interface to my models using Python.

Is there an API wrapper or other method of accessing MagicDraw using Python?


Solution

  • The MagicDraw Developers Guide (currently for v19.0-SP2) has information on their OpenAPI, which supports Jython, which is a Java implementation of Python.

    The OpenAPI implementation allows writing scripts for MagicDraw that can be called from any MagicDraw Query (for example, expressions in table scopes, table custom column definitions, and queries in Legend Adornments).

    There is information on Jython scripting here in the OpenAPI documentation.

    Notes on Jython:

    The core Python development is CPython, which is primarily in C and compiles to given targets like C. The Jython port is compatible with Java and targets the Java JVM rather than compiling for a particular platform.

    This allows running a Jython interpreter for Python as a class object directly in Java, and writing Jython scripts that run on the JVM directly.

    Jython currently only supports Python 2.7. There has been development of Jython for Python 3.5 under development in the past, though it is "resting" at the moment, as stated in this SO answer