Load a model#

To load a model, you need an instance of a SysML2 Connector. For more information, (see Use a connector).

You can then create an instance of the SysML2ProjectManager class. This class helps you load a model in Python, using the SysML2 standard API.

Create a SysML2 project manager instance#
project_manager = SysML2ProjectManager(connector=ansyssysml2apiconnector)

For more information, see the SysML2ProjectManager class.

With the project manager, and the ID of the project you want, you can load two types of projects:

SysML2 project (static approach)#

SysML2 projects use a Python-based metamodel, enabling static completion for all SysML2 properties.

project = project_manager.get_sysml_project(
    "<Computer Project ID>"
)  # You can find your project ID in the URL of the editor.

Scripting project (dynamic approach)#

Scripting projects use a dynamic class generation approach. This offers flexibility but does not provide autocompletion.

Get the project using the project ID#
project = project_manager.get_scripting_project(
    "<Computer Project ID>"
)  # You can find your project ID in the URL of the editor.

Both of the approaches give you a Python version of your model.

See Approaches dynamic and static for more information about the differences between these approaches and when to use each of them.

Previous step

Dynamic vs static approaches

Dynamic versus static approaches
Next step

Read a model

Read your model