Copyright (C) 2023 - 2026 ANSYS, Inc. and/or its affiliates. SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Create a transformer model in AEDT using the PyETK API#

This example shows how to use the ToolkitBackend class in the PyEDT API to create a transformer model in AEDT. More specifically, it does the following:

  • Initializes the ToolkitBackend class.

  • Sets common properties like non_graphical and aedt_version.

  • Defines the path to the JSON file with the transformer properties.

  • Reads the transformer properties from the JSON file.

  • Launches AEDT.

  • Creates the transformer model.

[1]:
# ## Perform required imports
from pathlib import Path
import sys
import tempfile
[2]:
from ansys.aedt.core import generate_unique_project_name
from ansys.aedt.toolkits.electronic_transformer.backend.api import ToolkitBackend
[3]:
# ## Create backend instance
toolkit_api = ToolkitBackend()
[4]:
# ## Set common properties
toolkit_api.properties.non_graphical = False
toolkit_api.properties.aedt_version = "2026.1"
[5]:
# ## Define the JSON path
json_file_name = "RM_wound_circular.json"
temp_dir = tempfile.TemporaryDirectory(suffix="_ansys")
project_name = generate_unique_project_name(root_name=temp_dir.name, project_name="ETK_example")
try:
    # Works in standard .py scripts
    json_path = Path(__file__).resolve().parents[3]
except NameError:
    # Fallback for Jupyter / Interactive sessions
    json_path = Path.cwd().parents[2]
json_path = Path(json_path) / "tests" / "backend" / "json_files" / json_file_name
[6]:
# ## Set JSON reading properties
toolkit_api.load_properties_from_json(json_path)
[7]:
# ## Launch AEDT
thread_msg = toolkit_api.launch_thread(toolkit_api.launch_aedt)
idle = toolkit_api.wait_to_be_idle()
if not idle:
    print("AEDT not initialized.")
    sys.exit()
PyAEDT INFO: Python version 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)].
PyAEDT INFO: PyAEDT version 0.26.3.
PyAEDT INFO: Initializing new Desktop session.
PyAEDT INFO: AEDT version 2026.1.
PyAEDT INFO: New AEDT session is starting on gRPC port 60952.
PyAEDT INFO: Starting new AEDT gRPC session on port 60952.
PyAEDT INFO: Launching AEDT server with gRPC transport mode: wnua
PyAEDT INFO: Electronics Desktop started on gRPC port 60952 after 9.5 seconds.
PyAEDT INFO: AEDT installation Path C:\Program Files\ANSYS Inc\v261\AnsysEM
PyAEDT INFO: Connected to AEDT gRPC session on port 60952.
PyAEDT INFO: Non-graphical mode detected. Disabling Desktop logs.
PyAEDT INFO: Desktop has been released.
INFO - AEDT is released.
[8]:
# ## Create the model
setup = toolkit_api.create_model()
PyAEDT INFO: Python version 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)].
PyAEDT INFO: PyAEDT version 0.26.3.
PyAEDT INFO: Initializing Desktop session.
PyAEDT INFO: AEDT version 2026.1.
PyAEDT INFO: Found active AEDT gRPC session on port 60952.
PyAEDT INFO: AEDT installation Path C:\Program Files\ANSYS Inc\v261\AnsysEM
PyAEDT INFO: Connected to AEDT gRPC session on port 60952.
PyAEDT INFO: Non-graphical mode detected. Disabling Desktop logs.
PyAEDT INFO: Project PyETK Project has been created.
PyAEDT INFO: Added design 'RM_Wound_20260504154134' of type Maxwell 3D.
PyAEDT INFO: AEDT objects correctly read
PyAEDT INFO: Python version 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)].
PyAEDT INFO: PyAEDT version 0.26.3.
PyAEDT INFO: Returning found Desktop session with PID 1820!
PyAEDT INFO: Python version 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)].
PyAEDT INFO: PyAEDT version 0.26.3.
PyAEDT INFO: Returning found Desktop session with PID 1820!
PyAEDT INFO: Project PyETK Project set to active.
PyAEDT INFO: Active Design set to RM_Wound_20260504154134
PyAEDT INFO: AEDT objects correctly read
INFO - Toolkit is connected to AEDT design.
PyAEDT INFO: Parsing C:\Users\ansys\AppData\Local\Temp\pytest-of-ansys\pytest-3821\PyETK Project.aedt.
PyAEDT INFO: File C:\Users\ansys\AppData\Local\Temp\pytest-of-ansys\pytest-3821\PyETK Project.aedt correctly loaded. Elapsed time: 0m 0sec
PyAEDT INFO: aedt file load time 0.01936197280883789
PyAEDT INFO: Modeler class has been initialized! Elapsed time: 0m 0sec
PyAEDT INFO: Materials class has been initialized! Elapsed time: 0m 0sec
PyAEDT INFO: Parsing design objects. This operation can take time
PyAEDT INFO: Refreshing bodies from Object Info
PyAEDT INFO: Bodies Info Refreshed Elapsed time: 0m 0sec
PyAEDT INFO: 3D Modeler objects parsed. Elapsed time: 0m 0sec
PyAEDT INFO: Parsing design objects. This operation can take time
PyAEDT INFO: Refreshing bodies from Object Info
PyAEDT INFO: Bodies Info Refreshed Elapsed time: 0m 0sec
PyAEDT INFO: 3D Modeler objects parsed. Elapsed time: 0m 0sec
PyAEDT INFO: Union of 20 objects has been executed.
PyAEDT INFO: Adding new material to the Project Library: 3C81_pyETK
PyAEDT INFO: Material has been added in Desktop.
PyAEDT INFO: Dataset Mu_3C81_pyETK doesn't exist.
PyAEDT INFO: Dataset $Mu_3C81_pyETK created successfully.
PyAEDT INFO: Parsing design objects. This operation can take time
PyAEDT INFO: Refreshing bodies from Object Info
PyAEDT INFO: Bodies Info Refreshed Elapsed time: 0m 0sec
PyAEDT INFO: 3D Modeler objects parsed. Elapsed time: 0m 0sec
PyAEDT INFO: Adding new material to the Project Library: Copper_pyETK
PyAEDT INFO: Material has been added in Desktop.
PyAEDT INFO: Parsing design objects. This operation can take time
PyAEDT INFO: Refreshing bodies from Object Info
PyAEDT INFO: Bodies Info Refreshed Elapsed time: 0m 0sec
PyAEDT INFO: 3D Modeler objects parsed. Elapsed time: 0m 0sec
PyAEDT INFO: Deleted 1 Objects: Layer1_Section1_Separate1.
PyAEDT INFO: Parsing design objects. This operation can take time
PyAEDT INFO: Refreshing bodies from Object Info
PyAEDT INFO: Bodies Info Refreshed Elapsed time: 0m 0sec
PyAEDT INFO: 3D Modeler objects parsed. Elapsed time: 0m 0sec
PyAEDT INFO: Deleted 1 Objects: Layer1_1_Section1_Separate1.
PyAEDT INFO: Parsing design objects. This operation can take time
PyAEDT INFO: Refreshing bodies from Object Info
PyAEDT INFO: Bodies Info Refreshed Elapsed time: 0m 0sec
PyAEDT INFO: 3D Modeler objects parsed. Elapsed time: 0m 0sec
PyAEDT INFO: Deleted 1 Objects: Layer1_2_Section1_Separate1.
PyAEDT INFO: Parsing design objects. This operation can take time
PyAEDT INFO: Refreshing bodies from Object Info
PyAEDT INFO: Bodies Info Refreshed Elapsed time: 0m 0sec
PyAEDT INFO: 3D Modeler objects parsed. Elapsed time: 0m 0sec
PyAEDT INFO: Deleted 1 Objects: Layer1_3_Section1_Separate1.
PyAEDT INFO: Parsing design objects. This operation can take time
PyAEDT INFO: Refreshing bodies from Object Info
PyAEDT INFO: Bodies Info Refreshed Elapsed time: 0m 0sec
PyAEDT INFO: 3D Modeler objects parsed. Elapsed time: 0m 0sec
PyAEDT INFO: Deleted 1 Objects: Layer1_4_Section1_Separate1.
PyAEDT INFO: Parsing design objects. This operation can take time
PyAEDT INFO: Refreshing bodies from Object Info
PyAEDT INFO: Bodies Info Refreshed Elapsed time: 0m 0sec
PyAEDT INFO: 3D Modeler objects parsed. Elapsed time: 0m 0sec
PyAEDT INFO: Deleted 1 Objects: Layer1_5_Section1_Separate1.
PyAEDT INFO: Boundary Winding Layer_1 has been created.
PyAEDT INFO: Boundary CoilTerminal Layer1_Section1 has been created.
PyAEDT INFO: Boundary CoilTerminal Layer1_1_Section1 has been created.
PyAEDT INFO: Boundary CoilTerminal Layer1_2_Section1 has been created.
PyAEDT INFO: Boundary CoilTerminal Layer1_3_Section1 has been created.
PyAEDT INFO: Boundary CoilTerminal Layer1_4_Section1 has been created.
PyAEDT INFO: Boundary CoilTerminal Layer1_5_Section1 has been created.
PyAEDT INFO: Boundary Matrix Matrix1 has been created.
PyAEDT INFO: Adding new material to the Project Library: material_bobbin_pyETK
PyAEDT INFO: Material has been added in Desktop.
PyAEDT INFO: Mesh class has been initialized! Elapsed time: 0m 0sec
PyAEDT INFO: Mesh class has been initialized! Elapsed time: 0m 0sec
PyAEDT INFO: Python version 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)].
PyAEDT INFO: PyAEDT version 0.26.3.
PyAEDT INFO: Returning found Desktop session with PID 1820!
PyAEDT INFO: No project is defined. Project PyETK Project exists and has been read.
PyAEDT INFO: Added design 'circuit_RM_Wound_20260504154134' of type Maxwell Circuit.
PyAEDT INFO: AEDT objects correctly read
PyAEDT INFO: ModelerCircuit class has been initialized! Elapsed time: 0m 0sec
PyAEDT INFO: ModelerMaxwellCircuit class has been initialized!
PyAEDT WARNING: Property Va has not been edited.Check if readonly
PyAEDT WARNING: Property VFreq has not been edited.Check if readonly
PyAEDT WARNING: Property R has not been edited.Check if readonly
PyAEDT INFO: Active Design set to 1;circuit_RM_Wound_20260504154134
PyAEDT INFO: PostProcessor class has been initialized! Elapsed time: 0m 0sec
PyAEDT INFO: PostProcessor class has been initialized! Elapsed time: 0m 0sec
PyAEDT INFO: Post class has been initialized! Elapsed time: 0m 0sec
PyAEDT INFO: Active Design set to RM_Wound_20260504154134
PyAEDT INFO: Active Design set to RM_Wound_20260504154134
PyAEDT INFO: Active Design set to RM_Wound_20260504154134
PyAEDT INFO: Active Design set to RM_Wound_20260504154134
PyAEDT INFO: Project PyETK Project Saved correctly
PyAEDT WARNING: No report category provided. Automatically identified AC Magnetic
PyAEDT INFO: Desktop has been released.
INFO - AEDT is released.