diff --git a/example/00-EDB/00_EDB_Create_VIA.py b/example/00-EDB/00_EDB_Create_VIA.py index 83739108a..5c387dfab 100644 --- a/example/00-EDB/00_EDB_Create_VIA.py +++ b/example/00-EDB/00_EDB_Create_VIA.py @@ -8,16 +8,22 @@ # ## Import EDB layout object # Import the EDB layout object and initialize it on version 2023 R2. +# + import os import tempfile -# + +from example.constants import EDB_VERSION import pyaedt temp_dir = tempfile.TemporaryDirectory(suffix=".ansys") aedb_path = os.path.join(temp_dir.name, "create_via.aedb") -print(aedb_path) -edb = pyaedt.Edb(edbpath=aedb_path, edbversion="2023.2") +print(f"AEDB file path: {aedb_path}") + +# Select EDB version (change it manually if needed, e.g. "2023.2") +edb_version = EDB_VERSION +print(f"EDB version: {edb_version}") + +edb = pyaedt.Edb(edbpath=aedb_path, edbversion=edb_version) # - # ## Add stackup layers diff --git a/example/00-EDB/01_edb_example.py b/example/00-EDB/01_edb_example.py index 7df84faa4..fdf99ab95 100644 --- a/example/00-EDB/01_edb_example.py +++ b/example/00-EDB/01_edb_example.py @@ -9,6 +9,7 @@ import tempfile import time +from example.constants import EDB_VERSION import pyaedt temp_dir = tempfile.TemporaryDirectory(suffix=".ansys") @@ -21,13 +22,18 @@ # ## Launch Ansys Electronics Database (EDB) # -# Instantiate an instance of the `pyaedt.Edb` class -# using EDB 2023 R2 and SI units. +# Instantiate an instance of the `pyaedt.Edb` class using SI units. -edb_version = "2023.2" +# + if os.path.exists(aedt_file): os.remove(aedt_file) + +# Select EDB version (change it manually if needed, e.g. "2023.2") +edb_version = EDB_VERSION +print(f"EDB version: {edb_version}") + edb = pyaedt.Edb(edbpath=targetfile, edbversion=edb_version) +# - # ## Identify nets and components # diff --git a/example/00-EDB/02_edb_to_ipc2581.py b/example/00-EDB/02_edb_to_ipc2581.py index b66e93bd7..11ce55c18 100644 --- a/example/00-EDB/02_edb_to_ipc2581.py +++ b/example/00-EDB/02_edb_to_ipc2581.py @@ -4,12 +4,16 @@ # # Perform required imports, which includes importing a section. +# + import os import tempfile +from example.constants import EDB_VERSION import pyaedt -# Download the AEDB file and copy it in the temporary folder. +# - + +# ## Download the AEDB file and copy it in the temporary folder. temp_dir = tempfile.TemporaryDirectory(suffix=".ansys") targetfile = pyaedt.downloads.download_file("edb/ANSYS-HSD_V1.aedb", destination=temp_dir.name) @@ -21,15 +25,21 @@ # Launch the `pyaedt.Edb` class, using EDB 2023. # > Note that length dimensions passed to EDB are in SI units. -edb = pyaedt.Edb(edbpath=targetfile, edbversion="2023.2") +# + +# Select EDB version (change it manually if needed, e.g. "2023.2") +edb_version = EDB_VERSION +print(f"EDB version: {edb_version}") + +edb = pyaedt.Edb(edbpath=targetfile, edbversion=edb_version) +# - -# Parametrize the width of a trace. +# ## Parametrize the width of a trace. edb.modeler.parametrize_trace_width( "A0_N", parameter_name=pyaedt.generate_unique_name("Par"), variable_value="0.4321mm" ) -# Create a cutout and plot it. +# ## Create a cutout and plot it. signal_list = [] for net in edb.nets.netlist: @@ -49,15 +59,15 @@ ) edb.nets.plot(None, None, color_by_net=True) -# Export the EDB to an IPC2581 file. +# ## Export the EDB to an IPC2581 file. edb.export_to_ipc2581(ipc2581_file_name, "inch") print("IPC2581 File has been saved to {}".format(ipc2581_file_name)) -# Close EDB +# ## Close EDB edb.close_edb() -# Clean up the temporary directory +# ## Clean up the temporary directory temp_dir.cleanup() diff --git a/example/00-EDB/03_5G_antenna_example_parametrics.py b/example/00-EDB/03_5G_antenna_example_parametrics.py index a20201264..4bfe79b8d 100644 --- a/example/00-EDB/03_5G_antenna_example_parametrics.py +++ b/example/00-EDB/03_5G_antenna_example_parametrics.py @@ -8,12 +8,16 @@ # Perform required imports, which includes importing the ``Hfss3dlayout`` object # and initializing it on version 2023 R2. +# + import os import tempfile +from example.constants import EDB_VERSION import pyaedt -# Set non-graphical mode +# - + +# ## Set non-graphical mode non_graphical = False @@ -77,9 +81,17 @@ def points(self): # # PyAEDT.Edb allows to open existing Edb project or create a new empty project. +# + temp_dir = tempfile.TemporaryDirectory(suffix=".ansys") aedb_path = os.path.join(temp_dir.name, "linear_array.aedb") -edb = pyaedt.Edb(edbpath=aedb_path, edbversion="2023.2") # Create an instance of the Edb class. + +# Select EDB version (change it manually if needed, e.g. "2023.2") +edb_version = EDB_VERSION +print(f"EDB version: {edb_version}") + +# Create an instance of the Edb class. +edb = pyaedt.Edb(edbpath=aedb_path, edbversion=edb_version) +# - # Add stackup layers diff --git a/example/00-EDB/04_edb_parametrized_design.py b/example/00-EDB/04_edb_parametrized_design.py index 07e8d69a5..f3e804eb9 100644 --- a/example/00-EDB/04_edb_parametrized_design.py +++ b/example/00-EDB/04_edb_parametrized_design.py @@ -10,11 +10,15 @@ # # +# + import os import tempfile +from example.constants import EDB_VERSION import pyaedt +# - + # ## Set non-graphical mode # # Set non-graphical mode. The default is ``False``, which opens @@ -22,11 +26,18 @@ non_graphical = False -# Launch EDB. +# ## Launch EDB. +# + temp_dir = tempfile.TemporaryDirectory(suffix=".ansys") aedb_path = os.path.join(temp_dir.name, "pcb.aedb") -edb = pyaedt.Edb(edbpath=aedb_path, edbversion="2023.2") + +# Select EDB version (change it manually if needed, e.g. "2023.2") +edb_version = EDB_VERSION +print(f"EDB version: {edb_version}") + +edb = pyaedt.Edb(edbpath=aedb_path, edbversion=edb_version) +# - # Define the parameters. diff --git a/example/00-EDB/05_Plot_nets.py b/example/00-EDB/05_Plot_nets.py index 5e622132f..fbd11ab8f 100644 --- a/example/00-EDB/05_Plot_nets.py +++ b/example/00-EDB/05_Plot_nets.py @@ -9,20 +9,30 @@ # # Perform required imports, which includes importing a section. +# + import tempfile +from example.constants import EDB_VERSION import pyaedt -# Download the EDB and copy it into the temporary folder. +# - + +# ## Download the EDB and copy it into the temporary folder. temp_dir = tempfile.TemporaryDirectory(suffix=".ansys") targetfolder = pyaedt.downloads.download_file("edb/ANSYS-HSD_V1.aedb", destination=temp_dir.name) -# Create an instance of the Electronics Database using the `pyaedt.Edb` class. +# ## Create an instance of the Electronics Database using the `pyaedt.Edb` class. # # > Note that units are SI. -edb = pyaedt.Edb(edbpath=targetfolder, edbversion="2023.2") +# + +# Select EDB version (change it manually if needed, e.g. "2023.2") +edb_version = EDB_VERSION +print(f"EDB version: {edb_version}") + +edb = pyaedt.Edb(edbpath=targetfolder, edbversion=edb_version) +# - # Display the nets on a layer. You can display the net geometry directly in Python using # ``matplotlib`` from the ``pyaedt.Edb`` class. diff --git a/example/00-EDB/06_Advanced_EDB.py b/example/00-EDB/06_Advanced_EDB.py index 2dac85df5..b31e6fe8e 100644 --- a/example/00-EDB/06_Advanced_EDB.py +++ b/example/00-EDB/06_Advanced_EDB.py @@ -8,6 +8,7 @@ import os import tempfile +from example.constants import EDB_VERSION import numpy as np import pyaedt @@ -35,7 +36,13 @@ def create_ground_planes(edb, layers): # Create the EDB instance. # If the path doesn't exist, PyAEDT automatically generates a new AEDB folder. -edb = pyaedt.Edb(edbpath=aedb_path, edbversion="2023.2") +# + +# Select EDB version (change it manually if needed, e.g. "2023.2") +edb_version = EDB_VERSION +print(f"EDB version: {edb_version}") + +edb = pyaedt.Edb(edbpath=aedb_path, edbversion=edb_version) +# - # Insert the stackup layers. diff --git a/example/00-EDB/08_CPWG.py b/example/00-EDB/08_CPWG.py index 1bb5ffd33..34918df3f 100644 --- a/example/00-EDB/08_CPWG.py +++ b/example/00-EDB/08_CPWG.py @@ -11,6 +11,7 @@ import os +from example.constants import EDB_VERSION import numpy as np import pyaedt @@ -22,11 +23,18 @@ # ## Launch EDB +# + aedb_path = os.path.join( pyaedt.generate_unique_folder_name(), pyaedt.generate_unique_name("pcb") + ".aedb" ) print(aedb_path) -edbapp = pyaedt.Edb(edbpath=aedb_path, edbversion="2023.2") + +# Select EDB version (change it manually if needed, e.g. "2023.2") +edb_version = EDB_VERSION +print(f"EDB version: {edb_version}") + +edbapp = pyaedt.Edb(edbpath=aedb_path, edbversion=edb_version) +# - # ## Define parameters diff --git a/example/00-EDB/09_Configuration.py b/example/00-EDB/09_Configuration.py index 687f3fa9e..cde7f3575 100644 --- a/example/00-EDB/09_Configuration.py +++ b/example/00-EDB/09_Configuration.py @@ -10,11 +10,15 @@ # the 3D Layout editor in AEDT. # on version 2023 R2. +# + import os import tempfile +from example.constants import EDB_VERSION import pyaedt +# - + # Download the AEDB file and copy it to a temporary folder. temp_dir = tempfile.TemporaryDirectory(suffix=".ansys") @@ -25,7 +29,13 @@ # # Launch the ``pyaedt.Edb`` class using EDB 2023 R2. Length units are SI. -edbapp = pyaedt.Edb(target_aedb, edbversion="2023.2") +# + +# Select EDB version (change it manually if needed, e.g. "2023.2") +edb_version = EDB_VERSION +print(f"EDB version: {edb_version}") + +edbapp = pyaedt.Edb(target_aedb, edbversion=edb_version) +# - # ## Import definitions # diff --git a/example/00-EDB/10_GDS_workflow.py b/example/00-EDB/10_GDS_workflow.py index 3305d91e8..d71714aca 100644 --- a/example/00-EDB/10_GDS_workflow.py +++ b/example/00-EDB/10_GDS_workflow.py @@ -5,13 +5,17 @@ # Perform imports. +# + import os import shutil import tempfile +from example.constants import EDB_VERSION import pyaedt from pyaedt.edb_core.edb_data.control_file import ControlFile +# - + # ## Fetch Example Data # # Download the EDB folder and copy it to a temporary folder. @@ -91,7 +95,13 @@ # + from pyaedt import Edb -edb = Edb(gds_out, edbversion="2023.2", technology_file=os.path.join(temp_dir.name, "output.xml")) +# Select EDB version (change it manually if needed, e.g. "2023.2") +edb_version = EDB_VERSION +print(f"EDB version: {edb_version}") + +edb = Edb( + gds_out, edbversion=edb_version, technology_file=os.path.join(temp_dir.name, "output.xml") +) # - # ## Plot stackup diff --git a/example/00-EDB/11_post_layout_parameterization.py b/example/00-EDB/11_post_layout_parameterization.py index 463a5c44c..5296f40bb 100644 --- a/example/00-EDB/11_post_layout_parameterization.py +++ b/example/00-EDB/11_post_layout_parameterization.py @@ -10,9 +10,11 @@ # Perform required imports. +# + import os import tempfile +from example.constants import EDB_VERSION import pyaedt temp_dir = tempfile.TemporaryDirectory(suffix=".ansys") @@ -20,7 +22,13 @@ # Download and open example layout file in edb format. edb_path = pyaedt.downloads.download_file("edb/ANSYS-HSD_V1.aedb", destination=temp_dir.name) -edb = pyaedt.Edb(edb_path, edbversion="2023.2") + +# Select EDB version (change it manually if needed, e.g. "2023.2") +edb_version = EDB_VERSION +print(f"EDB version: {edb_version}") + +edb = pyaedt.Edb(edb_path, edbversion=edb_version) +# - # ## Create cutout # diff --git a/example/00-EDB/12_edb_sma_connector_on_board.py b/example/00-EDB/12_edb_sma_connector_on_board.py index 91f36d27a..515990d1b 100644 --- a/example/00-EDB/12_edb_sma_connector_on_board.py +++ b/example/00-EDB/12_edb_sma_connector_on_board.py @@ -18,19 +18,24 @@ import os import tempfile +from example.constants import EDB_VERSION import numpy as np import pyaedt # Create the EDB. # + -ansys_version = "2023.2" temp_dir = tempfile.TemporaryDirectory(suffix=".ansys") working_folder = temp_dir.name +# Select EDB version (change it manually if needed, e.g. "2023.2") +edb_version = EDB_VERSION +print(f"EDB version: {edb_version}") + aedb_path = os.path.join(working_folder, "pcb.aedb") -edb = pyaedt.Edb(edbpath=aedb_path, edbversion=ansys_version) print("AEDB file is located in {}".format(aedb_path)) + +edb = pyaedt.Edb(edbpath=aedb_path, edbversion=edb_version) # - # Add the FR4 dielectric for the PCB. diff --git a/example/00-EDB/13_edb_create_component.py b/example/00-EDB/13_edb_create_component.py index 919dd8047..f7603679f 100644 --- a/example/00-EDB/13_edb_create_component.py +++ b/example/00-EDB/13_edb_create_component.py @@ -27,17 +27,24 @@ # Initialize the EDB layout object. +# + import os import tempfile +from example.constants import EDB_VERSION import pyaedt from pyaedt import Edb temp_dir = tempfile.TemporaryDirectory(suffix=".ansys") aedb_path = os.path.join(temp_dir.name, "component_example.aedb") -edb = Edb(edbpath=aedb_path, edbversion="2023.2") +# Select EDB version (change it manually if needed, e.g. "2023.2") +edb_version = EDB_VERSION +print(f"EDB version: {edb_version}") + +edb = Edb(edbpath=aedb_path, edbversion=edb_version) print("EDB is located at {}".format(aedb_path)) +# - # Initialize variables diff --git a/example/00-EDB/14_edb_create_parametrized_design.py b/example/00-EDB/14_edb_create_parametrized_design.py index fb8700c35..f16cfc021 100644 --- a/example/00-EDB/14_edb_create_parametrized_design.py +++ b/example/00-EDB/14_edb_create_parametrized_design.py @@ -13,6 +13,7 @@ import tempfile +from example.constants import EDB_VERSION import pyaedt # ## Create an instance of a pyaedt.Edb object. @@ -22,8 +23,11 @@ target_aedb = pyaedt.downloads.download_file("edb/ANSYS-HSD_V1.aedb", destination=temp_dir.name) print("Project is located in ", target_aedb) -aedt_version = "2023.2" -edb = pyaedt.Edb(edbpath=target_aedb, edbversion=aedt_version) +# Select EDB version (change it manually if needed, e.g. "2023.2") +edb_version = EDB_VERSION +print(f"EDB version: {edb_version}") + +edb = pyaedt.Edb(edbpath=target_aedb, edbversion=edb_version) print("AEDB file is located in {}".format(target_aedb)) # - diff --git a/example/00-EDB/15_ac_analysis.py b/example/00-EDB/15_ac_analysis.py index 5df646c8c..2db9a8660 100644 --- a/example/00-EDB/15_ac_analysis.py +++ b/example/00-EDB/15_ac_analysis.py @@ -14,6 +14,7 @@ import tempfile import time +from example.constants import EDB_VERSION import pyaedt # ### Download file @@ -32,7 +33,13 @@ # # Create an instance of the ``pyaedt.Edb`` class. -edbapp = pyaedt.Edb(edbpath=edb_full_path, edbversion="2023.2") +# + +# Select EDB version (change it manually if needed, e.g. "2023.2") +edb_version = EDB_VERSION +print(f"EDB version: {edb_version}") + +edbapp = pyaedt.Edb(edbpath=edb_full_path, edbversion=edb_version) +# - # ### Generate extended nets # diff --git a/example/constants.py b/example/constants.py new file mode 100644 index 000000000..1f8e60cbb --- /dev/null +++ b/example/constants.py @@ -0,0 +1,2 @@ +AEDT_VERSION = "2023.2" +EDB_VERSION = "2023.2"