Netlist to Schematic Import

# This example shows how to import Netlist data into a # Circuit design. Supported Netlist files are HSPICE and, # partially, Mentor.

# sphinx_gallery_thumbnail_path = 'Resources/schematic.png'

import os

Import Packages

Set the local path to the path for PyAEDT.

from pyaedt import examples
import tempfile

netlist = examples.download_netlist()
from pyaedt import generate_unique_name

tmpfold = tempfile.gettempdir()
temp_folder = os.path.join(tmpfold, generate_unique_name("Example"))
if not os.path.exists(temp_folder):
    os.makedirs(temp_folder)
myfile = os.path.join(netlist)
print(temp_folder)

Out:

C:\Users\ansys\AppData\Local\Temp\Example_UCS5M2

Import the main classes needed: pyaedt.Desktop and pyaedt.Circuit.

from pyaedt import Circuit
from pyaedt import Desktop

Launch AEDT and Circuit

This example launches AEDT 2021.2 in graphical mode.

# This examples uses SI units.

desktopVersion = "2021.2"

Launch AEDT in Non-Graphical Mode

Change the Boolean parameter NonGraphical to False to launch AEDT in graphical mode.

NonGraphical = False
NewThread = True

Launch AEDT and Circuit

The pyaedt.Desktop class initializes AEDT and starts it on a specified version in a specified graphical mode. The Boolean parameter NewThread defines whether to create a new instance of AEDT or try to connect to existing instance of it.

desktop = Desktop(desktopVersion, NonGraphical, NewThread)
aedtapp = Circuit()

Out:

Launching PyAEDT outside Electronics Desktop with CPython and Pythonnet
Launching AEDT installation C:\Program Files\AnsysEM\AnsysEM21.2\Win64
===================================================================================
pyaedt info: Launching AEDT with module Pythonnet.
pyaedt info: Ansoft.ElectronicsDesktop.2021.2 Started with process ID 6992.
pyaedt info: Logger Started on C:\Users\ansys\Documents\Ansoft\pyaedt20220120_154351.log
pyaedt info: pyaedt v0.5.dev1
pyaedt info: Python version 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
pyaedt info: Project Project2596 has been created.
pyaedt info: No design is present. Inserting a new design.
pyaedt info: Design Loaded
pyaedt info: Successfully loaded project materials !
pyaedt info: Materials Loaded

Save the Project to the Temp Folder

The temp folder can be changed.

aedtapp.save_project(os.path.join(temp_folder, "my_firt_netlist.aedt"))

Out:

pyaedt info: Saving Project2596 Project

True

Define a Design Variable

Using a $ prefix creates a project variable.

aedtapp["Voltage"] = "5"

Create a Schematic from a Netlist File

This method reads the netlist file and parses it. All components will be parsed but only specified categories will be mapped. In particular, R, L, C, Q, U, J, V, and I components will be mapped.

aedtapp.create_schematic_from_netlist(myfile)

Out:

pyaedt error: Method create_symbol Failed:  General or AEDT Error. Please Check again
Method create_symbol Failed:  General or AEDT Error. Please Check again
pyaedt error: (-2147417851, 'The server threw an exception.', None, None)
(-2147417851, 'The server threw an exception.', None, None)
pyaedt error: Arguments Provided:
Arguments Provided:
pyaedt error:     symbol_name = Models_Netlist
    symbol_name = Models_Netlist
pyaedt error:     pin_lists = []
    pin_lists = []
pyaedt error: Error in :   File "C:\actions-runner\_work\PyAEDT\PyAEDT\pyaedt\modeler\PrimitivesCircuit.py", line 821, in create_symbol
Error in :   File "C:\actions-runner\_work\PyAEDT\PyAEDT\pyaedt\modeler\PrimitivesCircuit.py", line 821, in create_symbol
pyaedt error: Check Online documentation on: https://aedtdocs.pyansys.com/search.html?q=create_symbol
Check Online documentation on: https://aedtdocs.pyansys.com/search.html?q=create_symbol
pyaedt error: Method create_symbol Failed:  General or AEDT Error. Please Check again
Method create_symbol Failed:  General or AEDT Error. Please Check again
pyaedt error: (-2147417851, 'The server threw an exception.', None, None)
(-2147417851, 'The server threw an exception.', None, None)
pyaedt error: Arguments Provided:
Arguments Provided:
pyaedt error:     symbol_name = STS6NF20V
    symbol_name = STS6NF20V
pyaedt error:     pin_lists = ['Pin1', 'Pin2', 'Pin3', 'Pin4', 'Pin5', 'Pin6', 'Pin7', 'Pin8']
    pin_lists = ['Pin1', 'Pin2', 'Pin3', 'Pin4', 'Pin5', 'Pin6', 'Pin7', 'Pin8']
pyaedt error: Error in :   File "C:\actions-runner\_work\PyAEDT\PyAEDT\pyaedt\modeler\PrimitivesCircuit.py", line 821, in create_symbol
Error in :   File "C:\actions-runner\_work\PyAEDT\PyAEDT\pyaedt\modeler\PrimitivesCircuit.py", line 821, in create_symbol
pyaedt error: Check Online documentation on: https://aedtdocs.pyansys.com/search.html?q=create_symbol
Check Online documentation on: https://aedtdocs.pyansys.com/search.html?q=create_symbol
pyaedt error: Method create_symbol Failed:  General or AEDT Error. Please Check again
Method create_symbol Failed:  General or AEDT Error. Please Check again
pyaedt error: (-2147417851, 'The server threw an exception.', None, None)
(-2147417851, 'The server threw an exception.', None, None)
pyaedt error: Arguments Provided:
Arguments Provided:
pyaedt error:     symbol_name = CON4
    symbol_name = CON4
pyaedt error:     pin_lists = ['Pin1', 'Pin2', 'Pin3', 'Pin4', 'Pin5']
    pin_lists = ['Pin1', 'Pin2', 'Pin3', 'Pin4', 'Pin5']
pyaedt error: Error in :   File "C:\actions-runner\_work\PyAEDT\PyAEDT\pyaedt\modeler\PrimitivesCircuit.py", line 821, in create_symbol
Error in :   File "C:\actions-runner\_work\PyAEDT\PyAEDT\pyaedt\modeler\PrimitivesCircuit.py", line 821, in create_symbol
pyaedt error: Check Online documentation on: https://aedtdocs.pyansys.com/search.html?q=create_symbol
Check Online documentation on: https://aedtdocs.pyansys.com/search.html?q=create_symbol
pyaedt error: Method create_symbol Failed:  General or AEDT Error. Please Check again
Method create_symbol Failed:  General or AEDT Error. Please Check again
pyaedt error: (-2147417851, 'The server threw an exception.', None, None)
(-2147417851, 'The server threw an exception.', None, None)
pyaedt error: Arguments Provided:
Arguments Provided:
pyaedt error:     symbol_name = DCH010505SN7
    symbol_name = DCH010505SN7
pyaedt error:     pin_lists = ['Pin1', 'Pin2', 'Pin3', 'Pin4']
    pin_lists = ['Pin1', 'Pin2', 'Pin3', 'Pin4']
pyaedt error: Error in :   File "C:\actions-runner\_work\PyAEDT\PyAEDT\pyaedt\modeler\PrimitivesCircuit.py", line 821, in create_symbol
Error in :   File "C:\actions-runner\_work\PyAEDT\PyAEDT\pyaedt\modeler\PrimitivesCircuit.py", line 821, in create_symbol
pyaedt error: Check Online documentation on: https://aedtdocs.pyansys.com/search.html?q=create_symbol
Check Online documentation on: https://aedtdocs.pyansys.com/search.html?q=create_symbol
pyaedt info: Netlist correctly imported into Circuit Design_F8Z

True

Close the Project

After adding any other desired functionalities, close the project.

if os.name != "posix":
    desktop.release_desktop()

Total running time of the script: ( 0 minutes 9.865 seconds)

Gallery generated by Sphinx-Gallery