Getting started#

This section explains how to install PySAM SysML2 and set up a project, including loading and initializing it.

Install PySAM SysML2#

python -m pip install ansys-sam-sysml2

Connect to the tool#

To get started, import the connector and project manager classes from the PySAM SysML2 library.

Import the connector and project manager#
from ansys.sam.sysml2 import AnsysSysML2APIConnector, SysML2ProjectManager

Create the connector#

A connector is required to access a SysML2 API server. Currently, the library provides a connector for the Ansys SysML2 server, which is compatible with most SysML2-compliant servers. This connector:

  • gives you access to the main entry points of a SysML2 server

  • allows you to create project managers to access models for a specific organization and user

Connect to the SysML2 API server#
ansyssysml2apiconnector = AnsysSysML2APIConnector(
    server_url="<SAM Server URL>",  # Your SAM server base URL
    organization_id="<Orga ID>",  # The organization ID
    token="<Token>",  # Your authorization token
    use_ssl=False,  # If the server hasn't a valid SSL
)

Create the project manager and load a project#

As mentioned, you can create a project manager with the connector to access projects for a specific organization and user. Once you have a project manager, you can load a project by its ID. The following example uses the Bike project, which is frequently referenced in the Examples section.

Create the project manager and load a project#
project_manager = SysML2ProjectManager(connector=ansyssysml2apiconnector)

my_bike_project = project_manager.get_scripting_project("<Bike Project ID>")
Create the project manager and load a project#
project_manager = SysML2ProjectManager(connector=ansyssysml2apiconnector)

my_bike_project = project_manager.get_sysml_project("<Bike Project ID>")

As you can see, there are 2 approaches to access a model. See Approaches dynamic and static for more information about the differences between these approaches and when to use each of them.

Note

For more comprehensive examples on using PySAM SysML2, see Examples.