From 7651d891a897c73a8d28408fcc09e98470b82e7f Mon Sep 17 00:00:00 2001 From: ansys-satyajeet Date: Wed, 28 Aug 2024 21:09:11 -0400 Subject: [PATCH 1/5] New Icepak ECAD import example with Ansys board --- examples/05-Icepak/icepak_ecad_import_v2.py | 130 ++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 examples/05-Icepak/icepak_ecad_import_v2.py diff --git a/examples/05-Icepak/icepak_ecad_import_v2.py b/examples/05-Icepak/icepak_ecad_import_v2.py new file mode 100644 index 00000000..b11d5286 --- /dev/null +++ b/examples/05-Icepak/icepak_ecad_import_v2.py @@ -0,0 +1,130 @@ +# # Import an ECAD into Icepak and modify stackup properties + +# This example shows how to import an ECAD as a PCB component into Icepak. +# It will also demonstrate how to change the materials of the PCB layers and +# update the PCB in Icepak. +# +# Keywords: **Icepak**, **PCB** + +# ## Perform required imports +# +# Perform required imports including the operating system, Ansys PyAEDT packages. + +import os +import time +import tempfile + +import ansys.aedt.core +from ansys.aedt.core import Edb +from ansys.aedt.core import Hfss3dLayout, Icepak + +# Set constant values + +AEDT_VERSION = "2024.2" +NG_MODE = False # Open AEDT interface when False +# +# ## Open project +# +# Open an empty project in graphical mode, using a temporary folder. + +# + +temp_folder = tempfile.TemporaryDirectory(suffix=".ansys") +project_name = "Icepak_ECAD_Import" +project_path = os.path.join(temp_folder.name, f"{project_name}.aedt") + +# Add an Icepak design +ipk = Icepak( + project=project_name, + version=AEDT_VERSION, + new_desktop=True, + non_graphical=NG_MODE, +) + +# Disable autosave +ipk.autosave_disable() + +# Save Icepak project +ipk.save_project() +# - + +# Download the ECAD file + +ecad_path = ansys.aedt.core.downloads.download_file( + source="edb/ANSYS-HSD_V1.aedb", + name="edb.def", + destination=temp_folder.name, +) + +# ## Import ECAD +# Add an HFSS 3D Layout design with the layout information of the PCB +h3d_design_name = "PCB_TEMP" +h3d = Hfss3dLayout( + project=project_name, + design=h3d_design_name, + version=AEDT_VERSION, +) +h3d.import_edb(ecad_path) +h3d.save_project() + +# Delete the empty placeholder HFSS 3D layout design +ipk.delete_design(name=h3d_design_name, fallback_design=None) + +# Set component name and ECAD source name and ECAD project path to be linked to Icepak +component_name = "PCB_ECAD" +layout_name = h3d.design_name +ecad_source = os.path.join(h3d.project_path, f"{h3d.project_name}.aedt") + +# Create a PCB component in Icepak linked to the 3D Layout project. +# Polygon ``"poly_5949"`` is used as the outline of the PCB and +# a dissipation of ``"1W"`` is applied to the PCB. + +# Create PCB component in Icepak +pcb_comp = ipk.create_pcb_from_3dlayout( + component_name=component_name, + project_name=ecad_source, + design_name=layout_name, + resolution=3, + extent_type="Polygon", + outline_polygon="poly_5949", + power_in=1, +) + +# Save project +ipk.save_project() + +# Initialize PyEDB object to modify ECAD +edb = Edb(edbpath=ecad_path, edbversion=AEDT_VERSION) + +# Change dielectric fill in signal layers +for name, layer in edb.stackup.signal_layers.items(): + layer.dielectric_fill = "FR_epoxy" + +# Change material of dielectric layers +for name, layer in edb.stackup.dielectric_layers.items(): + layer.material = "FR_epoxy" + +# Save EDB +edb.save_edb() + +# Close edb session +edb.close_edb() + +# Update layers of PCB with new materials in PCB component +pcb_comp.update() + +# Save project and release desktop +ipk.save_project() +ipk.release_desktop() + +# Wait 3 seconds to allow Electronics Desktop to shut down +# before cleaning the temporary directory. +time.sleep(3) + +# ## Cleanup +# +# All project files are saved in the folder ``temp_dir.name``. +# If you've run this example as a Jupyter notebook you +# can retrieve those project files. The following cell +# removes all temporary files, including the project folder. + +temp_folder.cleanup() From 998378526ce517e60b686079a5ae1f718115a248 Mon Sep 17 00:00:00 2001 From: ansys-satyajeet Date: Fri, 30 Aug 2024 11:34:30 -0400 Subject: [PATCH 2/5] Added PCB component property changes examples. --- examples/05-Icepak/icepak_ecad_import.py | 147 ++++++++++-------- .../icepak_ecad_import_deprecated.py | 121 ++++++++++++++ 2 files changed, 204 insertions(+), 64 deletions(-) create mode 100644 examples/05-Icepak/icepak_ecad_import_deprecated.py diff --git a/examples/05-Icepak/icepak_ecad_import.py b/examples/05-Icepak/icepak_ecad_import.py index 702c7370..d6369767 100644 --- a/examples/05-Icepak/icepak_ecad_import.py +++ b/examples/05-Icepak/icepak_ecad_import.py @@ -1,119 +1,138 @@ -# # Importing a PCB and its components via IDF and EDB +# # Import an ECAD into Icepak and modify stackup properties -# This example shows how to import a PCB and its components using IDF files (*.ldb/*.bdf). -# The *.emn/*.emp combination can also be used in a similar way. +# This example shows how to import an ECAD as a PCB component into Icepak. +# It will also demonstrate how to change the materials of the PCB layers and +# update the PCB in Icepak. # -# Keywords: **Icepak**, **PCB**, **IDF**. +# Keywords: **Icepak**, **PCB** # ## Perform required imports # # Perform required imports including the operating system, Ansys PyAEDT packages. import os -import tempfile import time +import tempfile import ansys.aedt.core -from ansys.aedt.core import Hfss3dLayout, Icepak +from ansys.aedt.core import Edb +from ansys.aedt.core import Hfss3dLayout, Icepak, downloads # Set constant values AEDT_VERSION = "2024.2" -NG_MODE = False # Open Electronics UI when the application is launched. - +NG_MODE = False # Open AEDT interface when False +# # ## Open project # -# Open an empty project in non-graphical mode, using a temporary folder. +# Open an empty project in graphical mode, using a temporary folder. # + temp_folder = tempfile.TemporaryDirectory(suffix=".ansys") +project_name = "Icepak_ECAD_Import" +project_path = os.path.join(temp_folder.name, f"{project_name}.aedt") +# Add an Icepak design ipk = Icepak( - project=os.path.join(temp_folder.name, "Icepak_ECAD_Import.aedt"), + project=project_name, version=AEDT_VERSION, new_desktop=True, non_graphical=NG_MODE, ) -# - -# ## Import the IDF files -# -# Sample *.bdf and *.ldf files are presented here. -# -# -# -# -# -# Imports the idf files with several filtering options including caps, resistors, -# inductors, power, specific power, size... -# There are also options for the PCB creation (number o flayers, copper percentages, layer sizes). -# In this example, the default values are used for the PCB. -# The imported PCB (from IDF) here will be deleted later and replaced by a PCB that has the trace -# information (from ECAD) for higher accuracy. +# Disable autosave +ipk.autosave_disable() + +# Save Icepak project +ipk.save_project() +# - -# Download ECAD and IDF files +# Download the ECAD file -def_path = ansys.aedt.core.downloads.download_file( - source="icepak/Icepak_ECAD_Import/A1_uprev.aedb", +ecad_path = downloads.download_file( + source="edb/ANSYS-HSD_V1.aedb", name="edb.def", destination=temp_folder.name, ) -board_path = ansys.aedt.core.downloads.download_file( - source="icepak/Icepak_ECAD_Import/", name="A1.bdf", destination=temp_folder.name + +# ## Import ECAD +# Add an HFSS 3D Layout design with the layout information of the PCB +h3d_design_name = "PCB_TEMP" +h3d = Hfss3dLayout( + project=project_name, + design=h3d_design_name, + version=AEDT_VERSION, ) -library_path = ansys.aedt.core.downloads.download_file( - source="icepak/Icepak_ECAD_Import/", name="A1.ldf", destination=temp_folder.name +h3d.import_edb(ecad_path) +h3d.save_project() + +# Delete the empty placeholder HFSS 3D layout design +ipk.delete_design(name=h3d_design_name, fallback_design=None) + +# Set component name and ECAD source name and ECAD project path to be linked to Icepak +component_name = "PCB_ECAD" +layout_name = h3d.design_name +ecad_source = os.path.join(h3d.project_path, f"{h3d.project_name}.aedt") + +# Create a PCB component in Icepak linked to the 3D Layout project. +# Polygon ``"poly_5949"`` is used as the outline of the PCB and +# a dissipation of ``"1W"`` is applied to the PCB. + +# Create PCB component in Icepak +pcb_comp = ipk.create_pcb_from_3dlayout( + component_name=component_name, + project_name=ecad_source, + design_name=layout_name, + resolution=3, + extent_type="Polygon", + outline_polygon="poly_5949", + power_in=1, ) -# Import IDF - -ipk.import_idf(board_path=board_path) - -# Save the project - +# Save project ipk.save_project() -# ## Import ECAD -# Add an HFSS 3D Layout design with the layout information of the PCB +# Initialize PyEDB object to modify ECAD +edb = Edb(edbpath=ecad_path, edbversion=AEDT_VERSION) -hfss3d_lo = Hfss3dLayout(project=def_path, version=AEDT_VERSION) -hfss3d_lo.save_project() +# Change dielectric fill in signal layers +for name, layer in edb.stackup.signal_layers.items(): + layer.dielectric_fill = "FR4_epoxy" -# Create a PCB component in Icepak linked to the 3D Layout project. The polygon ``"poly_0"`` -# is used as the outline of the PCB and a dissipation of ``"1W"`` is applied to the PCB. +# Change material of dielectric layers +for name, layer in edb.stackup.dielectric_layers.items(): + layer.material = "FR4_epoxy" -ipk.create_pcb_from_3dlayout( - component_name="PCB_pyAEDT", - project_name=hfss3d_lo.project_file, - design_name=hfss3d_lo.design_name, - extenttype="Polygon", - outlinepolygon="poly_0", - power_in=1, -) +# Save EDB +edb.save_edb() -# Delete the simplified PCB object coming from IDF import. +# Close edb session +edb.close_edb() -ipk.modeler["IDF_BoardOutline"].delete() +# Update layers of PCB with new materials in PCB component +pcb_comp.update() -# ## Plot model +# Change properties of PCB component such as board cutout material and via fill material +pcb_comp.board_cutout_material = "FR4_epoxy" +pcb_comp.via_holes_material = "FR4_epoxy" -ipk.plot( - show=False, - export_path=os.path.join(temp_folder.name, "ECAD_import.jpg"), - plot_air_objects=False, - force_opacity_value=1, -) +# Modify the power specified on PCB +pcb_comp.power = "2W" -# ## Release AEDT +# Print path of the linked ECAD source defintion +print(pcb_comp.native_properties["DefnLink"]["Project"]) +# Save project and release desktop ipk.save_project() ipk.release_desktop() -# Wait 3 seconds to allow Electronics Desktop to shut down before cleaning the temporary directory. + +# Wait 3 seconds to allow Electronics Desktop to shut down +# before cleaning the temporary directory. time.sleep(3) # ## Cleanup # -# All project files are saved in the folder ``temp_dir.name``. +# All project files are saved in the folder ``temp_folder.name``. # If you've run this example as a Jupyter notebook you # can retrieve those project files. The following cell # removes all temporary files, including the project folder. diff --git a/examples/05-Icepak/icepak_ecad_import_deprecated.py b/examples/05-Icepak/icepak_ecad_import_deprecated.py new file mode 100644 index 00000000..702c7370 --- /dev/null +++ b/examples/05-Icepak/icepak_ecad_import_deprecated.py @@ -0,0 +1,121 @@ +# # Importing a PCB and its components via IDF and EDB + +# This example shows how to import a PCB and its components using IDF files (*.ldb/*.bdf). +# The *.emn/*.emp combination can also be used in a similar way. +# +# Keywords: **Icepak**, **PCB**, **IDF**. + +# ## Perform required imports +# +# Perform required imports including the operating system, Ansys PyAEDT packages. + +import os +import tempfile +import time + +import ansys.aedt.core +from ansys.aedt.core import Hfss3dLayout, Icepak + +# Set constant values + +AEDT_VERSION = "2024.2" +NG_MODE = False # Open Electronics UI when the application is launched. + +# ## Open project +# +# Open an empty project in non-graphical mode, using a temporary folder. + +# + +temp_folder = tempfile.TemporaryDirectory(suffix=".ansys") + +ipk = Icepak( + project=os.path.join(temp_folder.name, "Icepak_ECAD_Import.aedt"), + version=AEDT_VERSION, + new_desktop=True, + non_graphical=NG_MODE, +) +# - + +# ## Import the IDF files +# +# Sample *.bdf and *.ldf files are presented here. +# +# +# +# +# +# Imports the idf files with several filtering options including caps, resistors, +# inductors, power, specific power, size... +# There are also options for the PCB creation (number o flayers, copper percentages, layer sizes). +# In this example, the default values are used for the PCB. +# The imported PCB (from IDF) here will be deleted later and replaced by a PCB that has the trace +# information (from ECAD) for higher accuracy. + +# Download ECAD and IDF files + +def_path = ansys.aedt.core.downloads.download_file( + source="icepak/Icepak_ECAD_Import/A1_uprev.aedb", + name="edb.def", + destination=temp_folder.name, +) +board_path = ansys.aedt.core.downloads.download_file( + source="icepak/Icepak_ECAD_Import/", name="A1.bdf", destination=temp_folder.name +) +library_path = ansys.aedt.core.downloads.download_file( + source="icepak/Icepak_ECAD_Import/", name="A1.ldf", destination=temp_folder.name +) + +# Import IDF + +ipk.import_idf(board_path=board_path) + +# Save the project + +ipk.save_project() + +# ## Import ECAD +# Add an HFSS 3D Layout design with the layout information of the PCB + +hfss3d_lo = Hfss3dLayout(project=def_path, version=AEDT_VERSION) +hfss3d_lo.save_project() + +# Create a PCB component in Icepak linked to the 3D Layout project. The polygon ``"poly_0"`` +# is used as the outline of the PCB and a dissipation of ``"1W"`` is applied to the PCB. + +ipk.create_pcb_from_3dlayout( + component_name="PCB_pyAEDT", + project_name=hfss3d_lo.project_file, + design_name=hfss3d_lo.design_name, + extenttype="Polygon", + outlinepolygon="poly_0", + power_in=1, +) + +# Delete the simplified PCB object coming from IDF import. + +ipk.modeler["IDF_BoardOutline"].delete() + +# ## Plot model + +ipk.plot( + show=False, + export_path=os.path.join(temp_folder.name, "ECAD_import.jpg"), + plot_air_objects=False, + force_opacity_value=1, +) + +# ## Release AEDT + +ipk.save_project() +ipk.release_desktop() +# Wait 3 seconds to allow Electronics Desktop to shut down before cleaning the temporary directory. +time.sleep(3) + +# ## Cleanup +# +# All project files are saved in the folder ``temp_dir.name``. +# If you've run this example as a Jupyter notebook you +# can retrieve those project files. The following cell +# removes all temporary files, including the project folder. + +temp_folder.cleanup() From ef53716fea1c9a620d5a8a5d6499405b010d3909 Mon Sep 17 00:00:00 2001 From: ansys-satyajeet Date: Fri, 30 Aug 2024 11:35:51 -0400 Subject: [PATCH 3/5] Renamed ecad_import file --- examples/05-Icepak/icepak_ecad_import_v2.py | 130 -------------------- 1 file changed, 130 deletions(-) delete mode 100644 examples/05-Icepak/icepak_ecad_import_v2.py diff --git a/examples/05-Icepak/icepak_ecad_import_v2.py b/examples/05-Icepak/icepak_ecad_import_v2.py deleted file mode 100644 index b11d5286..00000000 --- a/examples/05-Icepak/icepak_ecad_import_v2.py +++ /dev/null @@ -1,130 +0,0 @@ -# # Import an ECAD into Icepak and modify stackup properties - -# This example shows how to import an ECAD as a PCB component into Icepak. -# It will also demonstrate how to change the materials of the PCB layers and -# update the PCB in Icepak. -# -# Keywords: **Icepak**, **PCB** - -# ## Perform required imports -# -# Perform required imports including the operating system, Ansys PyAEDT packages. - -import os -import time -import tempfile - -import ansys.aedt.core -from ansys.aedt.core import Edb -from ansys.aedt.core import Hfss3dLayout, Icepak - -# Set constant values - -AEDT_VERSION = "2024.2" -NG_MODE = False # Open AEDT interface when False -# -# ## Open project -# -# Open an empty project in graphical mode, using a temporary folder. - -# + -temp_folder = tempfile.TemporaryDirectory(suffix=".ansys") -project_name = "Icepak_ECAD_Import" -project_path = os.path.join(temp_folder.name, f"{project_name}.aedt") - -# Add an Icepak design -ipk = Icepak( - project=project_name, - version=AEDT_VERSION, - new_desktop=True, - non_graphical=NG_MODE, -) - -# Disable autosave -ipk.autosave_disable() - -# Save Icepak project -ipk.save_project() -# - - -# Download the ECAD file - -ecad_path = ansys.aedt.core.downloads.download_file( - source="edb/ANSYS-HSD_V1.aedb", - name="edb.def", - destination=temp_folder.name, -) - -# ## Import ECAD -# Add an HFSS 3D Layout design with the layout information of the PCB -h3d_design_name = "PCB_TEMP" -h3d = Hfss3dLayout( - project=project_name, - design=h3d_design_name, - version=AEDT_VERSION, -) -h3d.import_edb(ecad_path) -h3d.save_project() - -# Delete the empty placeholder HFSS 3D layout design -ipk.delete_design(name=h3d_design_name, fallback_design=None) - -# Set component name and ECAD source name and ECAD project path to be linked to Icepak -component_name = "PCB_ECAD" -layout_name = h3d.design_name -ecad_source = os.path.join(h3d.project_path, f"{h3d.project_name}.aedt") - -# Create a PCB component in Icepak linked to the 3D Layout project. -# Polygon ``"poly_5949"`` is used as the outline of the PCB and -# a dissipation of ``"1W"`` is applied to the PCB. - -# Create PCB component in Icepak -pcb_comp = ipk.create_pcb_from_3dlayout( - component_name=component_name, - project_name=ecad_source, - design_name=layout_name, - resolution=3, - extent_type="Polygon", - outline_polygon="poly_5949", - power_in=1, -) - -# Save project -ipk.save_project() - -# Initialize PyEDB object to modify ECAD -edb = Edb(edbpath=ecad_path, edbversion=AEDT_VERSION) - -# Change dielectric fill in signal layers -for name, layer in edb.stackup.signal_layers.items(): - layer.dielectric_fill = "FR_epoxy" - -# Change material of dielectric layers -for name, layer in edb.stackup.dielectric_layers.items(): - layer.material = "FR_epoxy" - -# Save EDB -edb.save_edb() - -# Close edb session -edb.close_edb() - -# Update layers of PCB with new materials in PCB component -pcb_comp.update() - -# Save project and release desktop -ipk.save_project() -ipk.release_desktop() - -# Wait 3 seconds to allow Electronics Desktop to shut down -# before cleaning the temporary directory. -time.sleep(3) - -# ## Cleanup -# -# All project files are saved in the folder ``temp_dir.name``. -# If you've run this example as a Jupyter notebook you -# can retrieve those project files. The following cell -# removes all temporary files, including the project folder. - -temp_folder.cleanup() From d21cab8f3bff1b968de458e1b576a6eef5fbc413 Mon Sep 17 00:00:00 2001 From: Lorenzo Vecchietti Date: Wed, 11 Sep 2024 17:53:01 +0200 Subject: [PATCH 4/5] Remove deprecated example --- .../icepak_ecad_import_deprecated.py | 121 ------------------ 1 file changed, 121 deletions(-) delete mode 100644 examples/05-Icepak/icepak_ecad_import_deprecated.py diff --git a/examples/05-Icepak/icepak_ecad_import_deprecated.py b/examples/05-Icepak/icepak_ecad_import_deprecated.py deleted file mode 100644 index 702c7370..00000000 --- a/examples/05-Icepak/icepak_ecad_import_deprecated.py +++ /dev/null @@ -1,121 +0,0 @@ -# # Importing a PCB and its components via IDF and EDB - -# This example shows how to import a PCB and its components using IDF files (*.ldb/*.bdf). -# The *.emn/*.emp combination can also be used in a similar way. -# -# Keywords: **Icepak**, **PCB**, **IDF**. - -# ## Perform required imports -# -# Perform required imports including the operating system, Ansys PyAEDT packages. - -import os -import tempfile -import time - -import ansys.aedt.core -from ansys.aedt.core import Hfss3dLayout, Icepak - -# Set constant values - -AEDT_VERSION = "2024.2" -NG_MODE = False # Open Electronics UI when the application is launched. - -# ## Open project -# -# Open an empty project in non-graphical mode, using a temporary folder. - -# + -temp_folder = tempfile.TemporaryDirectory(suffix=".ansys") - -ipk = Icepak( - project=os.path.join(temp_folder.name, "Icepak_ECAD_Import.aedt"), - version=AEDT_VERSION, - new_desktop=True, - non_graphical=NG_MODE, -) -# - - -# ## Import the IDF files -# -# Sample *.bdf and *.ldf files are presented here. -# -# -# -# -# -# Imports the idf files with several filtering options including caps, resistors, -# inductors, power, specific power, size... -# There are also options for the PCB creation (number o flayers, copper percentages, layer sizes). -# In this example, the default values are used for the PCB. -# The imported PCB (from IDF) here will be deleted later and replaced by a PCB that has the trace -# information (from ECAD) for higher accuracy. - -# Download ECAD and IDF files - -def_path = ansys.aedt.core.downloads.download_file( - source="icepak/Icepak_ECAD_Import/A1_uprev.aedb", - name="edb.def", - destination=temp_folder.name, -) -board_path = ansys.aedt.core.downloads.download_file( - source="icepak/Icepak_ECAD_Import/", name="A1.bdf", destination=temp_folder.name -) -library_path = ansys.aedt.core.downloads.download_file( - source="icepak/Icepak_ECAD_Import/", name="A1.ldf", destination=temp_folder.name -) - -# Import IDF - -ipk.import_idf(board_path=board_path) - -# Save the project - -ipk.save_project() - -# ## Import ECAD -# Add an HFSS 3D Layout design with the layout information of the PCB - -hfss3d_lo = Hfss3dLayout(project=def_path, version=AEDT_VERSION) -hfss3d_lo.save_project() - -# Create a PCB component in Icepak linked to the 3D Layout project. The polygon ``"poly_0"`` -# is used as the outline of the PCB and a dissipation of ``"1W"`` is applied to the PCB. - -ipk.create_pcb_from_3dlayout( - component_name="PCB_pyAEDT", - project_name=hfss3d_lo.project_file, - design_name=hfss3d_lo.design_name, - extenttype="Polygon", - outlinepolygon="poly_0", - power_in=1, -) - -# Delete the simplified PCB object coming from IDF import. - -ipk.modeler["IDF_BoardOutline"].delete() - -# ## Plot model - -ipk.plot( - show=False, - export_path=os.path.join(temp_folder.name, "ECAD_import.jpg"), - plot_air_objects=False, - force_opacity_value=1, -) - -# ## Release AEDT - -ipk.save_project() -ipk.release_desktop() -# Wait 3 seconds to allow Electronics Desktop to shut down before cleaning the temporary directory. -time.sleep(3) - -# ## Cleanup -# -# All project files are saved in the folder ``temp_dir.name``. -# If you've run this example as a Jupyter notebook you -# can retrieve those project files. The following cell -# removes all temporary files, including the project folder. - -temp_folder.cleanup() From 8f83fb0d6dd69c82d0f1727a94de06b35731be67 Mon Sep 17 00:00:00 2001 From: ansys-satyajeet Date: Tue, 17 Sep 2024 09:46:57 -0400 Subject: [PATCH 5/5] Fixed structure of the code --- examples/05-electrothermal/ecad_import.py | 49 ++++++++++++++--------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/examples/05-electrothermal/ecad_import.py b/examples/05-electrothermal/ecad_import.py index 215bff51..ad6dc09d 100644 --- a/examples/05-electrothermal/ecad_import.py +++ b/examples/05-electrothermal/ecad_import.py @@ -7,7 +7,6 @@ # Keywords: **Icepak**, **PCB** # ## Perform required imports -# # Perform required imports including the operating system, Ansys PyAEDT packages. import os @@ -15,31 +14,37 @@ import tempfile import ansys.aedt.core -from ansys.aedt.core import Edb -from ansys.aedt.core import Hfss3dLayout, Icepak, downloads -# ## Define constants +# Define constants AEDT_VERSION = "2024.2" -NG_MODE = False # Open AEDT interface when False +NG_MODE = False # Open AEDT user interface when False + +# ## Create temporary directory # -# ## Open project +# Open an empty project in graphical mode, using a temporary directory. +# If you'd like to retrieve the project data for subsequent use, +# the temporary folder name is given by ``temp_folder.name``. + +temp_folder = tempfile.TemporaryDirectory(suffix=".ansys") + + +# ## Launch Icepak and open project # -# Open an empty project in graphical mode, using a temporary folder. +# Launch HFSS and open the project # + -temp_folder = tempfile.TemporaryDirectory(suffix=".ansys") project_name = "Icepak_ECAD_Import" project_path = os.path.join(temp_folder.name, f"{project_name}.aedt") - -# Add an Icepak design -ipk = Icepak( +ipk = ansys.aedt.core.Icepak( project=project_name, version=AEDT_VERSION, new_desktop=True, non_graphical=NG_MODE, ) +print(f"Project name: {project_name}") + # Disable autosave ipk.autosave_disable() @@ -47,38 +52,42 @@ ipk.save_project() # - -# Download the ECAD file +# ## Download the ECAD file +# Download the ECAD file needed to run the example. -ecad_path = downloads.download_file( +ecad_path = ansys.aedt.core.downloads.download_file( source="edb/ANSYS-HSD_V1.aedb", name="edb.def", destination=temp_folder.name, ) # ## Import ECAD -# Add an HFSS 3D Layout design with the layout information of the PCB +# Add an HFSS 3D Layout design with the layout information of the PCB. h3d_design_name = "PCB_TEMP" -h3d = Hfss3dLayout( +h3d = ansys.aedt.core.Hfss3dLayout( project=project_name, design=h3d_design_name, version=AEDT_VERSION, ) +# Import EDB file h3d.import_edb(ecad_path) + +# Save 3D Layout project h3d.save_project() # Delete the empty placeholder HFSS 3D layout design ipk.delete_design(name=h3d_design_name, fallback_design=None) -# Set component name and ECAD source name and ECAD project path to be linked to Icepak +# Set component name, ECAD source name and ECAD project path to be linked to Icepak component_name = "PCB_ECAD" layout_name = h3d.design_name ecad_source = os.path.join(h3d.project_path, f"{h3d.project_name}.aedt") +# ## Create PCB component in Icepak # Create a PCB component in Icepak linked to the 3D Layout project. # Polygon ``"poly_5949"`` is used as the outline of the PCB and # a dissipation of ``"1W"`` is applied to the PCB. -# Create PCB component in Icepak pcb_comp = ipk.create_pcb_from_3dlayout( component_name=component_name, project_name=ecad_source, @@ -92,8 +101,9 @@ # Save project ipk.save_project() +# ## Modify PCB stackup # Initialize PyEDB object to modify ECAD -edb = Edb(edbpath=ecad_path, edbversion=AEDT_VERSION) +edb = ansys.aedt.core.Edb(edbpath=ecad_path, edbversion=AEDT_VERSION) # Change dielectric fill in signal layers for name, layer in edb.stackup.signal_layers.items(): @@ -112,6 +122,7 @@ # Update layers of PCB with new materials in PCB component pcb_comp.update() +# ## Modify PCB materials in Icepak # Change properties of PCB component such as board cutout material and via fill material pcb_comp.board_cutout_material = "FR4_epoxy" pcb_comp.via_holes_material = "FR4_epoxy" @@ -122,7 +133,7 @@ # Print path of the linked ECAD source defintion print(pcb_comp.native_properties["DefnLink"]["Project"]) -# Save project and release desktop +# ## Save project and release desktop ipk.save_project() ipk.release_desktop()