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.

Create and load a new project#

You can also create a new project on the server and load it in a single step. The project manager provides create_scripting_project() and create_sysml_project() methods that create the project remotely and return a fully built Python object.

project = project_manager.create_scripting_project(
    name="My New Project",
    description="A project created via PySAM SysML2",
)
project = project_manager.create_sysml_project(
    name="My New Project",
    description="A project created via PySAM SysML2",
)

For more project management operations (update, delete, list), see Manage projects.

Previous step

Manage projects

Manage projects
Next step

Read a model

Read your model