@@ -540,15 +540,26 @@ class FieldPlot:
540
540
541
541
"""
542
542
543
- def __init__ (self , postprocessor , objlist = [], solutionName = "" , quantityName = "" , intrinsincList = {}):
543
+ def __init__ (
544
+ self ,
545
+ postprocessor ,
546
+ objlist = [],
547
+ surfacelist = [],
548
+ linelist = [],
549
+ cutplanelist = [],
550
+ solutionName = "" ,
551
+ quantityName = "" ,
552
+ intrinsincList = {},
553
+ ):
544
554
self ._postprocessor = postprocessor
545
555
self .oField = postprocessor .ofieldsreporter
546
- self .faceIndexes = objlist
556
+ self .volume_indexes = objlist
557
+ self .surfaces_indexes = surfacelist
558
+ self .line_indexes = linelist
559
+ self .cutplane_indexes = cutplanelist
547
560
self .solutionName = solutionName
548
561
self .quantityName = quantityName
549
562
self .intrinsincList = intrinsincList
550
- self .objtype = "Surface"
551
- self .listtype = "FaceList"
552
563
self .name = "Field_Plot"
553
564
self .plotFolder = "Field_Plot"
554
565
self .Filled = False
@@ -573,10 +584,39 @@ def __init__(self, postprocessor, objlist=[], solutionName="", quantityName="",
573
584
@property
574
585
def plotGeomInfo (self ):
575
586
"""Plot geometry information."""
576
- info = [1 , self .objtype , self .listtype , 0 ]
577
- for index in self .faceIndexes :
578
- info .append (str (index ))
579
- info [3 ] += 1
587
+ id = 0
588
+ if self .volume_indexes :
589
+ id += 1
590
+ if self .surfaces_indexes :
591
+ id += 1
592
+ if self .cutplane_indexes :
593
+ id += 1
594
+ if self .line_indexes :
595
+ id += 1
596
+ info = [id ]
597
+ if self .volume_indexes :
598
+ info .append ("Volume" )
599
+ info .append ("ObjList" )
600
+ info .append (len (self .volume_indexes ))
601
+ for index in self .volume_indexes :
602
+ info .append (str (index ))
603
+ if self .surfaces_indexes :
604
+ info .append ("Surface" )
605
+ info .append ("FacesList" )
606
+ info .append (len (self .surfaces_indexes ))
607
+ for index in self .surfaces_indexes :
608
+ info .append (str (index ))
609
+ if self .cutplane_indexes :
610
+ info .append ("Surface" )
611
+ info .append ("CutPlane" )
612
+ info .append (len (self .cutplane_indexes ))
613
+ for index in self .cutplane_indexes :
614
+ info .append (str (index ))
615
+ if self .line_indexes :
616
+ info .append ("Line" )
617
+ info .append (len (self .line_indexes ))
618
+ for index in self .line_indexes :
619
+ info .append (str (index ))
580
620
return info
581
621
582
622
@property
@@ -612,7 +652,7 @@ def plotsettings(self):
612
652
list
613
653
List of plot settings.
614
654
"""
615
- if self .objtype == "Surface" :
655
+ if self .surfaces_indexes :
616
656
arg = [
617
657
"NAME:PlotOnSurfaceSettings" ,
618
658
"Filled:=" ,
@@ -1672,16 +1712,17 @@ def _get_intrinsic(self, setup):
1672
1712
def _get_volume_objects (self , list_objs ):
1673
1713
if self ._app .solution_type not in ["HFSS3DLayout" , "HFSS 3D Layout Design" ]:
1674
1714
obj_list = []
1675
- for obj in list_objs [4 :]:
1676
- obj_list .append (self ._app ._odesign .SetActiveEditor ("3D Modeler" ).GetObjectNameByID (int (obj )))
1715
+ editor = self ._app ._odesign .SetActiveEditor ("3D Modeler" )
1716
+ for obj in list_objs :
1717
+ obj_list .append (editor .GetObjectNameByID (int (obj )))
1677
1718
if obj_list :
1678
1719
return obj_list
1679
1720
else :
1680
- return list_objs [ 4 :]
1721
+ return list_objs
1681
1722
1682
1723
@aedt_exception_handler
1683
1724
def _get_surface_objects (self , list_objs ):
1684
- faces = [int (i ) for i in list_objs [ 4 :] ]
1725
+ faces = [int (i ) for i in list_objs ]
1685
1726
if self ._app .solution_type not in ["HFSS3DLayout" , "HFSS 3D Layout Design" ]:
1686
1727
planes = self ._get_cs_plane_ids ()
1687
1728
objs = []
@@ -1730,23 +1771,28 @@ def _get_fields_plot(self):
1730
1771
if isinstance (setups_data [setup ], (OrderedDict , dict )) and "PlotDefinition" in setup :
1731
1772
plot_name = setups_data [setup ]["PlotName" ]
1732
1773
plots [plot_name ] = FieldPlot (self )
1733
- plots [plot_name ].faceIndexes = []
1734
1774
plots [plot_name ].solutionName = self ._get_base_name (setup )
1735
1775
plots [plot_name ].quantityName = self .ofieldsreporter .GetFieldPlotQuantityName (
1736
1776
setups_data [setup ]["PlotName" ]
1737
1777
)
1738
1778
plots [plot_name ].intrinsincList = self ._get_intrinsic (setup )
1739
- list_objs = setups_data [setup ]["FieldPlotGeometry" ]
1740
- if list_objs [1 ] == 64 :
1741
- plots [plot_name ].objtype = "Volume"
1742
- plots [plot_name ].listtype = "ObjList"
1743
- plots [plot_name ].faceIndexes = self ._get_volume_objects (list_objs )
1744
-
1745
- else :
1746
- plots [plot_name ].objtype = "Surface"
1747
- plots [plot_name ].listtype , plots [plot_name ].faceIndexes = self ._get_surface_objects (
1748
- list_objs
1749
- )
1779
+ list_objs = setups_data [setup ]["FieldPlotGeometry" ][1 :]
1780
+ while list_objs :
1781
+ id = list_objs [0 ]
1782
+ num_objects = list_objs [2 ]
1783
+ if id == 64 :
1784
+ plots [plot_name ].volume_indexes = self ._get_volume_objects (
1785
+ list_objs [3 : num_objects + 3 ]
1786
+ )
1787
+ elif id == 128 :
1788
+ out , faces = self ._get_surface_objects (list_objs [3 : num_objects + 3 ])
1789
+ if out == "CutPlane" :
1790
+ plots [plot_name ].cutplane_indexes = faces
1791
+ else :
1792
+ plots [plot_name ].surfaces_indexes = faces
1793
+ elif id == 256 :
1794
+ plots [plot_name ].line_indexes = self ._get_volume_objects (list_objs [3 : num_objects + 3 ])
1795
+ list_objs = list_objs [num_objects + 3 :]
1750
1796
plots [plot_name ].name = setups_data [setup ]["PlotName" ]
1751
1797
plots [plot_name ].plotFolder = setups_data [setup ]["PlotFolder" ]
1752
1798
surf_setts = setups_data [setup ]["PlotOnSurfaceSettings" ]
@@ -2293,7 +2339,7 @@ def change_field_plot_scale(self, plot_name, minimum_value, maximum_value, is_lo
2293
2339
return True
2294
2340
2295
2341
@aedt_exception_handler
2296
- def _create_fieldplot (self , objlist , quantityName , setup_name , intrinsincList , objtype , listtype , plot_name = None ):
2342
+ def _create_fieldplot (self , objlist , quantityName , setup_name , intrinsincList , listtype , plot_name = None ):
2297
2343
if isinstance (objlist , (str , int )):
2298
2344
objlist = [objlist ]
2299
2345
if not setup_name :
@@ -2309,12 +2355,37 @@ def _create_fieldplot(self, objlist, quantityName, setup_name, intrinsincList, o
2309
2355
char_set = string .ascii_uppercase + string .digits
2310
2356
if not plot_name :
2311
2357
plot_name = quantityName + "_" + "" .join (random .sample (char_set , 6 ))
2312
- plot = FieldPlot (self , objlist , setup_name , quantityName , intrinsincList )
2358
+ if listtype == "CutPlane" :
2359
+ plot = FieldPlot (
2360
+ self ,
2361
+ cutplanelist = objlist ,
2362
+ solutionName = setup_name ,
2363
+ quantityName = quantityName ,
2364
+ intrinsincList = intrinsincList ,
2365
+ )
2366
+ elif listtype == "FacesList" :
2367
+ plot = FieldPlot (
2368
+ self ,
2369
+ surfacelist = objlist ,
2370
+ solutionName = setup_name ,
2371
+ quantityName = quantityName ,
2372
+ intrinsincList = intrinsincList ,
2373
+ )
2374
+ elif listtype == "ObjList" :
2375
+ plot = FieldPlot (
2376
+ self , objlist = objlist , solutionName = setup_name , quantityName = quantityName , intrinsincList = intrinsincList
2377
+ )
2378
+ elif listtype == "Line" :
2379
+ plot = FieldPlot (
2380
+ self ,
2381
+ linelist = objlist ,
2382
+ solutionName = setup_name ,
2383
+ quantityName = quantityName ,
2384
+ intrinsincList = intrinsincList ,
2385
+ )
2313
2386
plot .name = plot_name
2314
2387
plot .plotFolder = plot_name
2315
2388
2316
- plot .objtype = objtype
2317
- plot .listtype = listtype
2318
2389
plt = plot .create ()
2319
2390
if "Maxwell" in self ._app .design_type and self .post_solution_type == "Transient" :
2320
2391
self .ofieldsreporter .SetPlotsViewSolutionContext ([plot_name ], setup_name , "Time:" + intrinsincList ["Time" ])
@@ -2324,6 +2395,40 @@ def _create_fieldplot(self, objlist, quantityName, setup_name, intrinsincList, o
2324
2395
else :
2325
2396
return False
2326
2397
2398
+ @aedt_exception_handler
2399
+ def create_fieldplot_line (self , objlist , quantityName , setup_name = None , intrinsincDict = {}, plot_name = None ):
2400
+ """Create a field plot of line.
2401
+
2402
+ Parameters
2403
+ ----------
2404
+ objlist : list
2405
+ List of polyline to plot.
2406
+ quantityName : str
2407
+ Name of the quantity to plot.
2408
+ setup_name : str, optional
2409
+ Name of the setup in the format ``"setupName : sweepName"``. The default
2410
+ is ``None``.
2411
+ intrinsincDict : dict, optional
2412
+ Dictionary containing all intrinsic variables. The default
2413
+ is ``{}``.
2414
+ plot_name : str, optional
2415
+ Name of the fieldplot to create.
2416
+
2417
+ Returns
2418
+ -------
2419
+ type
2420
+ Plot object.
2421
+
2422
+ References
2423
+ ----------
2424
+
2425
+ >>> oModule.CreateFieldPlot
2426
+ """
2427
+ if plot_name and plot_name in list (self .field_plots .keys ()):
2428
+ self .logger .info ("Plot {} exists. returning the object." .format (plot_name ))
2429
+ return self .field_plots [plot_name ]
2430
+ return self ._create_fieldplot (objlist , quantityName , setup_name , intrinsincDict , "Line" , plot_name )
2431
+
2327
2432
@aedt_exception_handler
2328
2433
def create_fieldplot_surface (self , objlist , quantityName , setup_name = None , intrinsincDict = {}, plot_name = None ):
2329
2434
"""Create a field plot of surfaces.
@@ -2356,9 +2461,7 @@ def create_fieldplot_surface(self, objlist, quantityName, setup_name=None, intri
2356
2461
if plot_name and plot_name in list (self .field_plots .keys ()):
2357
2462
self .logger .info ("Plot {} exists. returning the object." .format (plot_name ))
2358
2463
return self .field_plots [plot_name ]
2359
- return self ._create_fieldplot (
2360
- objlist , quantityName , setup_name , intrinsincDict , "Surface" , "FacesList" , plot_name
2361
- )
2464
+ return self ._create_fieldplot (objlist , quantityName , setup_name , intrinsincDict , "FacesList" , plot_name )
2362
2465
2363
2466
@aedt_exception_handler
2364
2467
def create_fieldplot_cutplane (self , objlist , quantityName , setup_name = None , intrinsincDict = {}, plot_name = None ):
@@ -2393,9 +2496,7 @@ def create_fieldplot_cutplane(self, objlist, quantityName, setup_name=None, intr
2393
2496
if plot_name and plot_name in list (self .field_plots .keys ()):
2394
2497
self .logger .info ("Plot {} exists. returning the object." .format (plot_name ))
2395
2498
return self .field_plots [plot_name ]
2396
- return self ._create_fieldplot (
2397
- objlist , quantityName , setup_name , intrinsincDict , "Surface" , "CutPlane" , plot_name
2398
- )
2499
+ return self ._create_fieldplot (objlist , quantityName , setup_name , intrinsincDict , "CutPlane" , plot_name )
2399
2500
2400
2501
@aedt_exception_handler
2401
2502
def create_fieldplot_volume (self , objlist , quantityName , setup_name = None , intrinsincDict = {}, plot_name = None ):
@@ -2430,7 +2531,7 @@ def create_fieldplot_volume(self, objlist, quantityName, setup_name=None, intrin
2430
2531
if plot_name and plot_name in list (self .field_plots .keys ()):
2431
2532
self .logger .info ("Plot {} exists. returning the object." .format (plot_name ))
2432
2533
return self .field_plots [plot_name ]
2433
- return self ._create_fieldplot (objlist , quantityName , setup_name , intrinsincDict , "Volume" , " ObjList" , plot_name )
2534
+ return self ._create_fieldplot (objlist , quantityName , setup_name , intrinsincDict , "ObjList" , plot_name )
2434
2535
2435
2536
@aedt_exception_handler
2436
2537
def export_field_jpg (
0 commit comments