|
| 1 | +# # Import Ports |
| 2 | +# This example shows how to import operations. In this example, we are going to |
| 3 | +# |
| 4 | +# - Download an example board |
| 5 | +# - Create a configuration file |
| 6 | +# - Add a cutout operation |
| 7 | +# - Import the configuration file |
| 8 | + |
| 9 | +# ## Import the required packages |
| 10 | + |
| 11 | +# + |
| 12 | +import json |
| 13 | +from pathlib import Path |
| 14 | +import tempfile |
| 15 | + |
| 16 | +from ansys.aedt.core.examples.downloads import download_file |
| 17 | + |
| 18 | +from pyedb import Edb |
| 19 | + |
| 20 | +AEDT_VERSION = "2025.1" |
| 21 | +NG_MODE = False |
| 22 | + |
| 23 | +# - |
| 24 | + |
| 25 | +# Download the example PCB data. |
| 26 | + |
| 27 | +temp_folder = tempfile.TemporaryDirectory(suffix=".ansys") |
| 28 | +file_edb = download_file(source="edb/ANSYS-HSD_V1.aedb", local_path=temp_folder.name) |
| 29 | + |
| 30 | +# ## Load example layout and place ports |
| 31 | + |
| 32 | +edbapp = Edb(file_edb, edbversion=AEDT_VERSION) |
| 33 | +ports = [ |
| 34 | + { |
| 35 | + "name": "Port_U1_P", |
| 36 | + "reference_designator": "U1", |
| 37 | + "positive_terminal": { |
| 38 | + "net": "PCIe_Gen4_TX3_CAP_P" |
| 39 | + }, |
| 40 | + "negative_terminal": { |
| 41 | + "net": "GND" |
| 42 | + }, |
| 43 | + "type": "circuit" |
| 44 | + }, |
| 45 | + { |
| 46 | + "name": "Port_U1_N", |
| 47 | + "reference_designator": "U1", |
| 48 | + "positive_terminal": { |
| 49 | + "net": "PCIe_Gen4_TX3_CAP_N" |
| 50 | + }, |
| 51 | + "negative_terminal": { |
| 52 | + "net": "GND" |
| 53 | + }, |
| 54 | + "type": "circuit" |
| 55 | + }, |
| 56 | + { |
| 57 | + "name": "Port_X1_P", |
| 58 | + "reference_designator": "X1", |
| 59 | + "positive_terminal": { |
| 60 | + "net": "PCIe_Gen4_TX3_P" |
| 61 | + }, |
| 62 | + "negative_terminal": { |
| 63 | + "net": "GND" |
| 64 | + }, |
| 65 | + "type": "circuit" |
| 66 | + }, |
| 67 | + { |
| 68 | + "name": "Port_X1_N", |
| 69 | + "reference_designator": "X1", |
| 70 | + "positive_terminal": { |
| 71 | + "net": "PCIe_Gen4_TX3_N" |
| 72 | + }, |
| 73 | + "negative_terminal": { |
| 74 | + "net": "GND" |
| 75 | + }, |
| 76 | + "type": "circuit" |
| 77 | + } |
| 78 | +] |
| 79 | +cfg_1 = {"ports": ports} |
| 80 | + |
| 81 | +edbapp.configuration.load(cfg_1) |
| 82 | +edbapp.configuration.run() |
| 83 | +edbapp.save() |
| 84 | +edb_path = edbapp.edbpath |
| 85 | +edbapp.close() |
| 86 | + |
| 87 | +# ## Cutout by nets |
| 88 | + |
| 89 | +# Keywords |
| 90 | +# |
| 91 | +# - **reference_list**. List of reference nets. |
| 92 | +# - **Extent_type**. Supported types are `Conforming`, `ConvexHull`, and `Bounding`. |
| 93 | +# - **signal_list**. List of signal nets to keep. |
| 94 | +# - **expansion_size**. Expansion size ratio in meters. The default is ``0.002``. |
| 95 | +# - **use_round_corner**. Whether to use round corners. Defaults to `False`. |
| 96 | +# - **number_of_threads**. Number of threads to use. Defaults to `4`. |
| 97 | +# - **extent_defeature**. Simplifies geometry before applying cutout to aid meshing. Only applies to Conforming bounding box. Defaults to `0` (disabled). |
| 98 | +# - **remove_single_pin_components**. Removes all single-pin RLCs after cutout. Defaults to `False`. |
| 99 | +# - **custom_extent**. List of points defining the custom cutout shape. Overrides the `extent_type` setting. |
| 100 | +# - **custom_extent_units**. Units of the custom extent points. Defaults to `"mm"`. Only valid if `custom_extent` is provided. |
| 101 | +# - **include_partial_instances**. Includes padstacks with bounding boxes intersecting the custom shape. May slow down export. Only valid with `custom_extent` and `use_pyaedt_cutout`. |
| 102 | +# - **keep_voids**. Whether to keep voids intersecting the cutout polygon. Defaults to `True`. Valid only if `custom_extent` is provided. |
| 103 | +# - **check_terminals**. Expands extent to include reference terminals of components with associated models. |
| 104 | +# - **include_pingroups**. Includes terminals of pingroups. Requires `check_terminals` to be `True`. |
| 105 | +# - **expansion_factor**. Computes the maximum between dielectric thickness and trace width (for nets with ports) multiplied by this factor. Defaults to `0` (disabled). Works only with `use_pyaedt_cutout`. |
| 106 | +# - **maximum_iterations**. Maximum number of iterations allowed for cutout search. Defaults to `10`. |
| 107 | +# - **preserve_components_with_model**. Preserves all pins of components with associated models (Spice or NPort). Only applicable for PyAEDT cutouts (excluding point list). |
| 108 | +# - **simple_pad_check**. Uses pad center for intersection detection instead of bounding box. Defaults to `True`. Bounding box method is slower and disables multithreading. |
| 109 | +# - **keep_lines_as_path**. Keeps lines as `Path` instead of converting to `PolygonData`. Only works in Electronics Desktop (3D Layout). May cause issues in SiWave. Defaults to `False`. |
| 110 | +# - **include_voids_in_extents**. Includes voids in the computed extent (for Conforming only). May affect performance. Defaults to `False`. |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | +cutout = { |
| 115 | + "reference_list": ["GND"], |
| 116 | + "extent_type": "ConvexHull", |
| 117 | + "signal_list": [ |
| 118 | + "PCIe_Gen4_TX3_CAP_P", |
| 119 | + "PCIe_Gen4_TX3_CAP_N", |
| 120 | + "PCIe_Gen4_TX3_P", |
| 121 | + "PCIe_Gen4_TX3_N" |
| 122 | + ] |
| 123 | +} |
| 124 | +operations = {"cutout": cutout} |
| 125 | +cfg = {"operations": operations} |
| 126 | + |
| 127 | +# Write configuration into as json file |
| 128 | + |
| 129 | +file_json = Path(temp_folder.name) / "cutout_1.json" |
| 130 | +with open(file_json, "w") as f: |
| 131 | + json.dump(cfg, f, indent=4, ensure_ascii=False) |
| 132 | + |
| 133 | +# Apply cutout |
| 134 | + |
| 135 | +edbapp = Edb(edb_path, edbversion=AEDT_VERSION) |
| 136 | +edbapp.configuration.load(config_file=file_json) |
| 137 | +edbapp.configuration.run() |
| 138 | +edbapp.nets.plot() |
| 139 | +edbapp.close() |
| 140 | + |
| 141 | +# ## Cutout with auto net identification |
| 142 | + |
| 143 | +# Keywords |
| 144 | +# |
| 145 | +# - **auto_identify_nets**. Identify nets connected to ports |
| 146 | +# - **enabled**. Resistance threshold. Resistor with value below this threshold is considered as short circuit |
| 147 | +# - **resistor_below**. Resistance threshold. Resistor with value below this threshold is considered as short circuit |
| 148 | +# - **inductor_below**. Inductor threshold. Inductor with value below this threshold is considered as short circuit |
| 149 | +# - **capacitor_above**. Capacitor threshold. Capacitor with value below this threshold is considered as short circuit |
| 150 | + |
| 151 | +cutout = { |
| 152 | + "auto_identify_nets": { |
| 153 | + "enabled": True, |
| 154 | + "resistor_below": 100, |
| 155 | + "inductor_below": 1, |
| 156 | + "capacitor_above": 1 |
| 157 | + }, |
| 158 | + "reference_list": ["GND"], |
| 159 | + "extent_type": "ConvexHull" |
| 160 | +} |
| 161 | +operations = {"cutout": cutout} |
| 162 | +cfg = {"operations": operations} |
| 163 | + |
| 164 | +# Write configuration into as json file |
| 165 | + |
| 166 | +file_json = Path(temp_folder.name) / "cutout_2.json" |
| 167 | +with open(file_json, "w") as f: |
| 168 | + json.dump(cfg, f, indent=4, ensure_ascii=False) |
| 169 | + |
| 170 | +# Apply cutout |
| 171 | + |
| 172 | +edbapp = Edb(edb_path, edbversion=AEDT_VERSION) |
| 173 | +edbapp.configuration.load(config_file=file_json) |
| 174 | +edbapp.configuration.run() |
| 175 | +edbapp.nets.plot() |
| 176 | +edbapp.close() |
0 commit comments