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.
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.
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.
Manage projects
Read a model