solidworks_mcp.adapters.solidworks.configurations¶
solidworks_mcp.adapters.solidworks.configurations ¶
Configurations: create, activate and delete one, and read the active one.
Configurations give a part or assembly its variants (a long and a short version, a simplified one) without Excel: design tables don't work through COM on SolidWorks 2026 (queue item 10's live check), so this is the path.
COM calls (argument lists from the installed type library):
IConfigurationManager.AddConfiguration2(Name, Comment, AlternateName, Options, ParentConfigName, Description, Rebuild); the new configuration becomes active, so the previous one is shown again unless asked otherwise;IModelDoc2.ShowConfiguration2(Name)andDeleteConfiguration2(Name);IModelDoc2.GetConfigurationNames()andGetActiveConfiguration().Name.
Classes¶
AdapterResult
dataclass
¶
AdapterResult(status: AdapterResultStatus, data: T | None = None, error: str | None = None, execution_time: float | None = None, metadata: dict[str, Any] | None = None)
Result wrapper for adapter operations.
Attributes:
| Name | Type | Description |
|---|---|---|
data |
T | None
|
The data value. |
error |
str | None
|
The error value. |
execution_time |
float | None
|
The execution time value. |
metadata |
dict[str, Any] | None
|
The metadata value. |
status |
AdapterResultStatus
|
The status value. |
AdapterResultStatus ¶
Bases: StrEnum
Result status for adapter operations.
Attributes:
| Name | Type | Description |
|---|---|---|
ERROR |
Any
|
The error value. |
SUCCESS |
Any
|
The success value. |
TIMEOUT |
Any
|
The timeout value. |
WARNING |
Any
|
The warning value. |
SolidWorksConfigurationsMixin ¶
Create, activate and delete configurations, and read the active one.
Methods:¶
activate_configuration
async
¶
Make name the active configuration and rebuild.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The configuration to show. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
The active configuration and the one before it. |
Source code in src/solidworks_mcp/adapters/solidworks/configurations.py
active_configuration
async
¶
The active configuration's name.
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
The name, or an error when no model is open or it can't be read. |
Source code in src/solidworks_mcp/adapters/solidworks/configurations.py
create_configuration
async
¶
create_configuration(name: str, parent: str | None = None, description: str = '', activate: bool = False) -> AdapterResult[dict[str, Any]]
Add a configuration, optionally derived from parent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The new configuration's name. |
required |
parent
|
str | None
|
A configuration to derive it from, or None. |
None
|
description
|
str
|
Its description. |
''
|
activate
|
bool
|
Leave it active; otherwise the previous one is shown again. |
False
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
The configuration, its parent, the active one and every name. |
Source code in src/solidworks_mcp/adapters/solidworks/configurations.py
delete_configuration
async
¶
Delete a configuration that isn't active and isn't the only one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The configuration to delete. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
The deleted name and the configurations left. |
Source code in src/solidworks_mcp/adapters/solidworks/configurations.py
Functions:¶
_active ¶
The active configuration's name (IConfiguration.Name is a property).
Source code in src/solidworks_mcp/adapters/solidworks/configurations.py
_names ¶
The active model's configuration names.
_require ¶
The names, after checking name is one of them.
Source code in src/solidworks_mcp/adapters/solidworks/configurations.py
as_list ¶
Normalise a COM array/scalar/None return into a list.
configuration_scope ¶
Where a change applies: the COM option, the names, and their array.
"this" is the active configuration, "all" every one, a list those
named (each checked first).
Raises:
| Type | Description |
|---|---|
LookupError
|
For a name the model doesn't have, listing the names. |
Source code in src/solidworks_mcp/adapters/solidworks/configurations.py
string_array ¶
VARIANT(VT_ARRAY | VT_BSTR), e.g. configuration names (tuple when pywin32 is absent).