> For the complete documentation index, see [llms.txt](https://www.opal-rt.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.opal-rt.com/docs/rt-lab/automation-api-and-scripting/rt-lab-api/python-rtlab-api-reference/introduction-to-functions_143429297/connectbyname-deprecated_143759683.md).

# ConnectByName Deprecated

<table data-header-hidden><thead><tr><th width="199.77777099609375"></th><th></th></tr></thead><tbody><tr><td><strong>Group</strong></td><td>Model selection</td></tr><tr><td><strong>Description</strong></td><td><p>Connect the API to an active model. Subsequent API calls refer to this model. When trying to establish a connection with a model when there are multiple models that correspond to the specified ModelName and ModelPath, a window is displayed prompting you to choose a model. This may occur when:</p><ul><li>modelName is not empty. The window displays a list of active models with the specified ModelName and ModelPath, unless ReturnOnAmbiguity is set to True1.</li><li>modelName is not empty, there is more than one active model with a specified path and name and returnOnAmbiguity is False(0).</li></ul><p>If exactMatch is true, connection is made when the model's original file name and extension are an exact match. If exactMatch is false any extension specified in modelName is ignored. If returnOnAmbiguity is true when the specified model name is found more than once, exception E2BIG is thrown.</p><div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>This function is deprecated. Use OpenProject instead.</p></div></td></tr><tr><td><strong>Required Control</strong></td><td>None</td></tr><tr><td><strong>Usage</strong></td><td>(instanceId, modelState) = <strong>RtlabApi.ConnectByName</strong>(modelName, modelPath, exactMatch, systemControl, returnOnAmbiguity) (instanceId, modelState) = <strong>RtlabApi.ConnectByName</strong>(modelName)</td></tr><tr><td><strong>Input</strong></td><td><p><strong>modelName</strong>: Name of the model to which connection is desired.</p><p><strong>modelPath:</strong> Path where original model resides. May be empty string; used to resolve ambiguity when more than one model of the same name are active.</p><p><strong>exactMatch</strong>: True(1) to request an exact name match.</p><p><strong>systemControl:</strong> True(1) to request control of the model.</p><p><strong>returnOnAmbiguity:</strong> No window is displayed, an error code (E2BIG) is returned.</p></td></tr><tr><td><strong>Output</strong></td><td><p><strong>instanceId:</strong> Current active model’s instance ID. See Glossary.</p><p><strong>modelState:</strong> Current model's state.</p></td></tr><tr><td><strong>Exception</strong></td><td><p><strong>EIO:</strong> Error sending the request or receiving the reply.</p><p><strong>ENOENT</strong>: No active model found.</p><p><strong>OP_API_CMD_CANCELED:</strong> Active model(s) found but no model has been selected.</p><p><strong>ENOSPC</strong>: No active model with the specified name, path, and type.</p><p><strong>E2BIG:</strong> More than 1 active models with specified name and path (only if returnOnAmbiguity is TRUE).</p><p><strong>EPERM:</strong> Control requested, but already given to another client.</p><p><strong>ENOEXEC:</strong> Could not connect to the model. Not all of the subsystems are still active.</p><p><strong>ENOMEM:</strong> Internal memory allocation error.</p><p><strong>OP_API_EBAD_CONFIG:</strong> Node mapping not valid or IP address of the controller machine not specified (environment variable OPAL_META_CTL_IP not set).</p><p><strong>OP_API_EBAD_PHYS_NODE:</strong> Physical node not found.</p><p><strong>OP_API_ECREATE_SHMEM:</strong> Could not create shared memory.</p><p><strong>OP_API_ECREATE_PROCESS</strong>: Error launching OpalChooseModel.exe - Error displaying the dialog box. Process OpalChooseModel.exe is called by this function. This process is placed RTLAB_ROOT\common\bin folder.</p><p><strong>OP_API_ENO_LICENSE:</strong> No license for one or more of RT-LAB components.</p><p><strong>OP_API_ENO_PRODUCT:</strong> No license for RT-LAB and RT-LABx.</p><p><strong>OP_API_MODEL_IO_TIMEOUT</strong>: Timed out waiting for a reply from model.</p><p><strong>OP_API_MODEL_IO_ERROR</strong>: Model is missing some or all processes or subsystems.</p></td></tr><tr><td><strong>Examples</strong></td><td>See the example <strong>basic_example1</strong>.</td></tr><tr><td><strong>Related Items</strong></td><td>Disconnect, SetCurrentModel, GetActiveModel</td></tr><tr><td><strong>Modules</strong></td><td><strong>import RtlabApi</strong></td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.opal-rt.com/docs/rt-lab/automation-api-and-scripting/rt-lab-api/python-rtlab-api-reference/introduction-to-functions_143429297/connectbyname-deprecated_143759683.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
