|
5 | 5 |
|
6 | 6 | from pyaedt.application.Analysis import Analysis
|
7 | 7 | from pyaedt.generic.configurations import Configurations
|
| 8 | +from pyaedt.generic.constants import unit_converter |
8 | 9 | from pyaedt.generic.general_methods import generate_unique_name
|
9 | 10 | from pyaedt.generic.general_methods import is_ironpython
|
10 | 11 | from pyaedt.generic.general_methods import open_file
|
@@ -1277,6 +1278,106 @@ def import_dxf(
|
1277 | 1278 | self.oeditor.ImportDXF(vArg1)
|
1278 | 1279 | return True
|
1279 | 1280 |
|
| 1281 | + @pyaedt_function_handler |
| 1282 | + def import_gds_3d(self, gds_file, gds_number, unit="um", import_method=1): # pragma: no cover |
| 1283 | + """Import a GDSII file. |
| 1284 | +
|
| 1285 | + Parameters |
| 1286 | + ---------- |
| 1287 | + gds_file : str |
| 1288 | + Path to the GDS file. |
| 1289 | + gds_number : dict |
| 1290 | + Dictionary keys are GDS layer numbers, and the value is a tuple with the thickness and elevation. |
| 1291 | + unit : string, optional |
| 1292 | + Length unit values. The default is ``"um"``. |
| 1293 | + import_method : integer, optional |
| 1294 | + GDSII import method. The default is ``1``. Options are: |
| 1295 | +
|
| 1296 | + - ``0`` for script. |
| 1297 | + - ``1`` for Parasolid. |
| 1298 | +
|
| 1299 | + Returns |
| 1300 | + ------- |
| 1301 | + bool |
| 1302 | + ``True`` when successful, ``False`` when failed. |
| 1303 | +
|
| 1304 | + References |
| 1305 | + ---------- |
| 1306 | + >>> oEditor.ImportGDSII |
| 1307 | +
|
| 1308 | + Examples |
| 1309 | + -------- |
| 1310 | + Import a GDS file in an HFSS 3D project. |
| 1311 | +
|
| 1312 | + >>> gds_path = r"C:\temp\gds1.gds" |
| 1313 | + >>> from pyaedt import Hfss |
| 1314 | + >>> hfss = Hfss() |
| 1315 | + >>> gds_number = {7: (100, 10), 9: (110, 5)} |
| 1316 | + >>> hfss.import_gds_3d(gds_path, gds_number, unit="um", import_method=1) |
| 1317 | +
|
| 1318 | + """ |
| 1319 | + |
| 1320 | + if self.desktop_class.non_graphical: |
| 1321 | + self.logger.error("Method is supported only in graphical mode.") |
| 1322 | + return False |
| 1323 | + if not os.path.exists(gds_file): |
| 1324 | + self.logger.error("GDSII file does not exist. No layer is imported.") |
| 1325 | + return False |
| 1326 | + if len(gds_number) == 0: |
| 1327 | + self.logger.error("Dictionary for GDSII layer numbers is empty. No layer is imported.") |
| 1328 | + return False |
| 1329 | + |
| 1330 | + layermap = ["NAME:LayerMap"] |
| 1331 | + ordermap = [] |
| 1332 | + for i, k in enumerate(gds_number): |
| 1333 | + layername = "signal" + str(k) |
| 1334 | + layermap.append( |
| 1335 | + [ |
| 1336 | + "NAME:LayerMapInfo", |
| 1337 | + "LayerNum:=", |
| 1338 | + k, |
| 1339 | + "DestLayer:=", |
| 1340 | + layername, |
| 1341 | + "layer_type:=", |
| 1342 | + "signal", |
| 1343 | + ] |
| 1344 | + ) |
| 1345 | + ordermap1 = [ |
| 1346 | + "entry:=", |
| 1347 | + [ |
| 1348 | + "order:=", |
| 1349 | + i, |
| 1350 | + "layer:=", |
| 1351 | + layername, |
| 1352 | + "LayerNumber:=", |
| 1353 | + k, |
| 1354 | + "Thickness:=", |
| 1355 | + unit_converter(gds_number[k][1], unit_system="Length", input_units=unit, output_units="meter"), |
| 1356 | + "Elevation:=", |
| 1357 | + unit_converter(gds_number[k][0], unit_system="Length", input_units=unit, output_units="meter"), |
| 1358 | + "Color:=", |
| 1359 | + "color", |
| 1360 | + ], |
| 1361 | + ] |
| 1362 | + ordermap.extend(ordermap1) |
| 1363 | + |
| 1364 | + self.oeditor.ImportGDSII( |
| 1365 | + [ |
| 1366 | + "NAME:options", |
| 1367 | + "FileName:=", |
| 1368 | + gds_file, |
| 1369 | + "FlattenHierarchy:=", |
| 1370 | + True, |
| 1371 | + "ImportMethod:=", |
| 1372 | + import_method, |
| 1373 | + layermap, |
| 1374 | + "OrderMap:=", |
| 1375 | + ordermap, |
| 1376 | + ] |
| 1377 | + ) |
| 1378 | + self.logger.info("GDS layer imported with elevations and thickness.") |
| 1379 | + return True |
| 1380 | + |
1280 | 1381 | @pyaedt_function_handler()
|
1281 | 1382 | def _find_indices(self, list_to_check, item_to_find):
|
1282 | 1383 | # type: (list, str|int) -> list
|
|
0 commit comments