# ansys/pymotorcad architecture

> Architecture diagram of the GitHub repository ansys/pymotorcad, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ansys/pymotorcad
- Repository: https://github.com/ansys/pymotorcad

## Overview

PyMotorCAD is a Python JSON-RPC interface for launching or connecting to Ansys Motor-CAD, locally or remotely, and controlling motor models with or without the GUI. Users call the public MotorCAD interface; its method façade dispatches operations through the RPC client to Motor-CAD and returns model, geometry, calculation, or analysis results. Distinct capabilities include model/file operations, variables and materials, geometry editing, FEA, thermal and Motor-LAB workflows, and graphs. The graph preserves documented and indexed subsystems; unsampled implementation details are represented at their known source paths, and edges are limited to relationships evidenced by the excerpts, index, or README.

Main entry points: [`src/ansys/motorcad/core/rpc_methods_core.py`](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/rpc_methods_core.py) (RPC Method Facade), [`src/ansys/motorcad/core/geometry.py`](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/geometry.py) (Geometry Model), [`src/ansys/motorcad/core/rpc_client_core.py`](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/rpc_client_core.py) (RPC Client), [`src/ansys/motorcad/core/methods/adaptive_geometry.py`](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/adaptive_geometry.py) (Adaptive Geometry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Public Interface"]
  node_api["MotorCAD API"]
  node_compat["Legacy API"]
end

subgraph group_transport["RPC Transport"]
  node_client["RPC Client<br/>[rpc_client_core.py]"]
  node_methodcore["RPC Method Facade"]
  node_messageconfig["Message Config"]
end

subgraph group_model["Model Operations"]
  node_general["Model and Files"]
  node_variables["Variables"]
  node_datastore[("Variable Store<br/>[datastore.py]")]
  node_materials["Materials"]
  node_ui["GUI Controls<br/>[rpc_methods_ui.py]"]
end

subgraph group_geometry["Geometry"]
  node_geometryapi["Geometry Model<br/>[geometry.py]"]
  node_geometrytree["Geometry Tree<br/>[geometry_tree.py]"]
  node_adaptive["Adaptive Geometry"]
  node_draw["Geometry Drawing"]
  node_fitting["Geometry Fitting"]
  node_shapes["Geometry Shapes<br/>[geometry_shapes.py]"]
  node_ellipse["Ellipse Geometry"]
  node_extrusion["Geometry Extrusion"]
  node_feageometry["FEA Geometry"]
  node_deprecated["Deprecated Methods"]
end

subgraph group_analysis["Analysis and Results"]
  node_calculations["Calculations"]
  node_graphs["Graphs"]
  node_thermal["Thermal Analysis"]
  node_lab["Motor-LAB<br/>[rpc_methods_lab.py]"]
  node_internal["Internal Methods"]
  node_internal_script["Internal Scripting"]
end

node_user(("Python User"))
node_motorcad["Motor-CAD"]

node_user -->|"calls"| node_api
node_api -->|"connects through"| node_client
node_api -->|"dispatches methods"| node_methodcore
node_compat -->|"delegates to"| node_methodcore
node_client -->|"sends JSON-RPC"| node_motorcad
node_methodcore -->|"initializes"| node_messageconfig
node_methodcore -->|"initializes"| node_general
node_methodcore -->|"initializes"| node_variables
node_methodcore -->|"initializes"| node_materials
node_methodcore -->|"initializes"| node_feageometry
node_methodcore -->|"initializes"| node_graphs
node_methodcore -->|"initializes"| node_thermal
node_methodcore -->|"initializes"| node_lab
node_methodcore -->|"initializes"| node_calculations
node_methodcore -->|"initializes"| node_internal_script
node_methodcore -->|"initializes"| node_ui
node_methodcore -->|"initializes"| node_adaptive
node_methodcore -->|"initializes"| node_deprecated
node_general -->|"sends requests"| node_client
node_graphs -->|"requests graph data"| node_client
node_thermal -->|"sends requests"| node_client
node_adaptive -->|"sends requests"| node_client
node_variables -->|"uses store"| node_datastore
node_adaptive -->|"builds regions"| node_geometryapi
node_adaptive -->|"loads and sets tree"| node_geometrytree
node_draw -->|"renders tree"| node_geometrytree
node_draw -->|"renders geometry"| node_geometryapi
node_geometryapi -->|"uses extrusion"| node_extrusion
node_geometrytree -->|"models regions"| node_geometryapi
node_fitting -->|"uses geometry"| node_geometryapi
node_shapes -->|"uses geometry"| node_geometryapi
node_ellipse -->|"uses geometry"| node_geometryapi
node_internal -->|"supports legacy calls"| node_methodcore

click node_api "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/motorcad_methods.py"
click node_compat "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/rpc_methods_core_old.py"
click node_client "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/rpc_client_core.py"
click node_methodcore "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/rpc_methods_core.py"
click node_messageconfig "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/rpc_message_config.py"
click node_general "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/rpc_methods_general.py"
click node_variables "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/rpc_methods_variables.py"
click node_datastore "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/datastore.py"
click node_materials "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/rpc_methods_materials.py"
click node_geometryapi "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/geometry.py"
click node_geometrytree "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/geometry_tree.py"
click node_adaptive "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/adaptive_geometry.py"
click node_draw "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/geometry_drawing.py"
click node_fitting "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/geometry_fitting.py"
click node_shapes "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/geometry_shapes.py"
click node_ellipse "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/geometry_ellipse.py"
click node_extrusion "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/geometry_extrusion.py"
click node_feageometry "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/rpc_methods_fea_geometry.py"
click node_deprecated "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/deprecated_methods.py"
click node_calculations "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/rpc_methods_calculations.py"
click node_graphs "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/rpc_methods_graphs.py"
click node_thermal "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/rpc_methods_thermal.py"
click node_lab "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/rpc_methods_lab.py"
click node_internal "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/rpc_methods_internal.py"
click node_internal_script "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/rpc_methods_internal_scripting.py"
click node_ui "https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/rpc_methods_ui.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_api,node_compat,node_user toneBlue
class node_client,node_methodcore,node_messageconfig toneAmber
class node_general,node_variables,node_datastore,node_materials,node_ui toneMint
class node_geometryapi,node_geometrytree,node_adaptive,node_draw,node_fitting,node_shapes,node_ellipse,node_extrusion,node_feageometry,node_deprecated toneRose
class node_calculations,node_graphs,node_thermal,node_lab,node_internal,node_internal_script,node_motorcad toneIndigo
```

## Components

### Public Interface

- [MotorCAD API](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/motorcad_methods.py): `src/ansys/motorcad/core/motorcad_methods.py`
- [Legacy API](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/rpc_methods_core_old.py): `src/ansys/motorcad/core/rpc_methods_core_old.py`

### RPC Transport

- [RPC Client](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/rpc_client_core.py): `src/ansys/motorcad/core/rpc_client_core.py`
- [RPC Method Facade](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/rpc_methods_core.py): `src/ansys/motorcad/core/rpc_methods_core.py`
- [Message Config](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/rpc_message_config.py): `src/ansys/motorcad/core/methods/rpc_message_config.py`

### Model Operations

- [Model and Files](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/rpc_methods_general.py): `src/ansys/motorcad/core/methods/rpc_methods_general.py`
- [Variables](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/rpc_methods_variables.py): `src/ansys/motorcad/core/methods/rpc_methods_variables.py`
- [Variable Store](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/datastore.py): `src/ansys/motorcad/core/datastore.py`
- [Materials](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/rpc_methods_materials.py): `src/ansys/motorcad/core/methods/rpc_methods_materials.py`
- [GUI Controls](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/rpc_methods_ui.py): `src/ansys/motorcad/core/methods/rpc_methods_ui.py`

### Geometry

- [Geometry Model](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/geometry.py): `src/ansys/motorcad/core/geometry.py`
- [Geometry Tree](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/geometry_tree.py): `src/ansys/motorcad/core/geometry_tree.py`
- [Adaptive Geometry](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/adaptive_geometry.py): `src/ansys/motorcad/core/methods/adaptive_geometry.py`
- [Geometry Drawing](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/geometry_drawing.py): `src/ansys/motorcad/core/geometry_drawing.py`
- [Geometry Fitting](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/geometry_fitting.py): `src/ansys/motorcad/core/geometry_fitting.py`
- [Geometry Shapes](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/geometry_shapes.py): `src/ansys/motorcad/core/geometry_shapes.py`
- [Ellipse Geometry](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/geometry_ellipse.py): `src/ansys/motorcad/core/geometry_ellipse.py`
- [Geometry Extrusion](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/geometry_extrusion.py): `src/ansys/motorcad/core/geometry_extrusion.py`
- [FEA Geometry](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/rpc_methods_fea_geometry.py): `src/ansys/motorcad/core/methods/rpc_methods_fea_geometry.py`
- [Deprecated Methods](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/deprecated_methods.py): `src/ansys/motorcad/core/methods/deprecated_methods.py`

### Analysis and Results

- [Calculations](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/rpc_methods_calculations.py): `src/ansys/motorcad/core/methods/rpc_methods_calculations.py`
- [Graphs](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/rpc_methods_graphs.py): `src/ansys/motorcad/core/methods/rpc_methods_graphs.py`
- [Thermal Analysis](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/rpc_methods_thermal.py): `src/ansys/motorcad/core/methods/rpc_methods_thermal.py`
- [Motor-LAB](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/rpc_methods_lab.py): `src/ansys/motorcad/core/methods/rpc_methods_lab.py`
- [Internal Methods](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/rpc_methods_internal.py): `src/ansys/motorcad/core/methods/rpc_methods_internal.py`
- [Internal Scripting](https://github.com/ansys/pymotorcad/blob/main/src/ansys/motorcad/core/methods/rpc_methods_internal_scripting.py): `src/ansys/motorcad/core/methods/rpc_methods_internal_scripting.py`

### Other components

- **Python User**
- **Motor-CAD**

## Connections

- Python User → MotorCAD API: calls (evidence: `README.rst`)
- MotorCAD API → RPC Client: connects through (evidence: `src/ansys/motorcad/core/motorcad_methods.py`)
- MotorCAD API → RPC Method Facade: dispatches methods (evidence: `src/ansys/motorcad/core/motorcad_methods.py`)
- Legacy API → RPC Method Facade: delegates to (evidence: `src/ansys/motorcad/core/rpc_methods_core_old.py`)
- RPC Client → Motor-CAD: sends JSON-RPC (evidence: `README.rst`)
- RPC Method Facade → Message Config: initializes (evidence: `src/ansys/motorcad/core/rpc_methods_core.py`)
- RPC Method Facade → Model and Files: initializes (evidence: `src/ansys/motorcad/core/rpc_methods_core.py`)
- RPC Method Facade → Variables: initializes (evidence: `src/ansys/motorcad/core/rpc_methods_core.py`)
- RPC Method Facade → Materials: initializes (evidence: `src/ansys/motorcad/core/rpc_methods_core.py`)
- RPC Method Facade → FEA Geometry: initializes (evidence: `src/ansys/motorcad/core/rpc_methods_core.py`)
- RPC Method Facade → Graphs: initializes (evidence: `src/ansys/motorcad/core/rpc_methods_core.py`)
- RPC Method Facade → Thermal Analysis: initializes (evidence: `src/ansys/motorcad/core/rpc_methods_core.py`)
- RPC Method Facade → Motor-LAB: initializes (evidence: `src/ansys/motorcad/core/rpc_methods_core.py`)
- RPC Method Facade → Calculations: initializes (evidence: `src/ansys/motorcad/core/rpc_methods_core.py`)
- RPC Method Facade → Internal Scripting: initializes (evidence: `src/ansys/motorcad/core/rpc_methods_core.py`)
- RPC Method Facade → GUI Controls: initializes (evidence: `src/ansys/motorcad/core/rpc_methods_core.py`)
- RPC Method Facade → Adaptive Geometry: initializes (evidence: `src/ansys/motorcad/core/rpc_methods_core.py`)
- RPC Method Facade → Deprecated Methods: initializes (evidence: `src/ansys/motorcad/core/rpc_methods_core.py`)
- Model and Files → RPC Client: sends requests (evidence: `src/ansys/motorcad/core/methods/rpc_methods_general.py`)
- Graphs → RPC Client: requests graph data (evidence: `src/ansys/motorcad/core/methods/rpc_methods_graphs.py`)
- Thermal Analysis → RPC Client: sends requests (evidence: `src/ansys/motorcad/core/methods/rpc_methods_thermal.py`)
- Adaptive Geometry → RPC Client: sends requests (evidence: `src/ansys/motorcad/core/methods/adaptive_geometry.py`)
- Variables → Variable Store: uses store (evidence: `src/ansys/motorcad/core/methods/rpc_methods_variables.py`)
- Adaptive Geometry → Geometry Model: builds regions (evidence: `src/ansys/motorcad/core/methods/adaptive_geometry.py`)
- Adaptive Geometry → Geometry Tree: loads and sets tree (evidence: `src/ansys/motorcad/core/methods/adaptive_geometry.py`)
- Geometry Drawing → Geometry Tree: renders tree (evidence: `src/ansys/motorcad/core/geometry_drawing.py`)
- Geometry Drawing → Geometry Model: renders geometry (evidence: `src/ansys/motorcad/core/geometry_drawing.py`)
- Geometry Model → Geometry Extrusion: uses extrusion (evidence: `src/ansys/motorcad/core/geometry.py`)
- Geometry Tree → Geometry Model: models regions (evidence: `src/ansys/motorcad/core/geometry_tree.py`)
- Geometry Fitting → Geometry Model: uses geometry (evidence: `src/ansys/motorcad/core/geometry_fitting.py`)
- Geometry Shapes → Geometry Model: uses geometry (evidence: `src/ansys/motorcad/core/geometry_shapes.py`)
- Ellipse Geometry → Geometry Model: uses geometry (evidence: `src/ansys/motorcad/core/geometry_ellipse.py`)
- Internal Methods → RPC Method Facade: supports legacy calls (evidence: `src/ansys/motorcad/core/rpc_methods_core_old.py`)
