@@ -229,7 +229,10 @@ def available_quantities_categories(
229229 context = ""
230230
231231 if solution and report_category and display_type :
232- return list (self .oreportsetup .GetAllCategories (report_category , display_type , solution , context ))
232+ try :
233+ return list (self .oreportsetup .GetAllCategories (report_category , display_type , solution , context ))
234+ except Exception : # pragma: no cover
235+ return []
233236 return [] # pragma: no cover
234237
235238 @pyaedt_function_handler ()
@@ -466,16 +469,31 @@ def get_all_report_quantities(
466469 third key the report categories.
467470 """
468471 rep_quantities = {}
472+ if not context and self ._app .design_type in [
473+ "HFSS" ,
474+ "Maxwell 3D" ,
475+ "Maxwell 2D" ,
476+ "Q3D Extractor" ,
477+ "2D Extractor" ,
478+ "Icepak" ,
479+ "Mechanical" ,
480+ ]:
481+ if not context and "2D" in self ._app .modeler .design_type :
482+ if self ._app .modeler .point_names :
483+ context = self ._app .modeler .point_names [0 ]
484+ elif not context :
485+ if self ._app .modeler .line_names :
486+ context = self ._app .modeler .line_names [0 ]
469487 for rep in self .available_report_types :
470488 rep_quantities [rep ] = {}
471489 solutions = [solution ] if isinstance (solution , str ) else self .available_report_solutions (rep )
472- for solution in solutions :
473- rep_quantities [rep ][solution ] = {}
490+ for sol in solutions :
491+ rep_quantities [rep ][sol ] = {}
474492 for quant in self .available_quantities_categories (
475- rep , context = context , solution = solution , is_siwave_dc = is_siwave_dc
493+ rep , context = context , solution = sol , is_siwave_dc = is_siwave_dc
476494 ):
477- rep_quantities [rep ][solution ][quant ] = self .available_report_quantities (
478- rep , quantities_category = quant , context = context , solution = solution , is_siwave_dc = is_siwave_dc
495+ rep_quantities [rep ][sol ][quant ] = self .available_report_quantities (
496+ rep , quantities_category = quant , context = context , solution = sol , is_siwave_dc = is_siwave_dc
479497 )
480498
481499 return rep_quantities
@@ -1122,6 +1140,56 @@ def _get_report_inputs(
11221140 ]
11231141 return [plot_name , modal_data , plot_type , setup_sweep_name , ctxt , families_input , arg ]
11241142
1143+ @pyaedt_function_handler ()
1144+ def _check_category_context (self , expression , report_category , context ):
1145+ field_ctx = context
1146+ if self ._app .design_type in [
1147+ "HFSS" ,
1148+ "Maxwell 3D" ,
1149+ "Maxwell 2D" ,
1150+ "Q3D Extractor" ,
1151+ "2D Extractor" ,
1152+ "Icepak" ,
1153+ "Mechanical" ,
1154+ ]:
1155+ if not field_ctx and "2D" in self ._app .modeler .design_type :
1156+ if self ._app .modeler .point_names :
1157+ field_ctx = self ._app .modeler .point_names [0 ]
1158+ elif not field_ctx :
1159+ if self ._app .modeler .line_names :
1160+ field_ctx = self ._app .modeler .line_names [0 ]
1161+ if not report_category :
1162+ sols = self .get_all_report_quantities (context = field_ctx )
1163+ for cat , sol in sols .items ():
1164+ for s , q in sol .items ():
1165+ for _ , v in q .items ():
1166+ if any ([i in expression for i in v ]):
1167+ report_category = cat
1168+ self ._app .logger .warning (f"No report category provided. Automatically identified { cat } " )
1169+ break
1170+ if report_category :
1171+ break
1172+ if report_category :
1173+ break
1174+ if not context :
1175+ if report_category == "Far Fields" and not context :
1176+ for setup in self ._app .field_setups :
1177+ if setup .type == "FarFieldSphere" :
1178+ context = setup .name
1179+ self ._app .logger .warning (f"No Far Fields infinite sphere provided. Assigned setup: { context } " )
1180+
1181+ break
1182+ elif report_category == "Near Fields" and not context :
1183+ for setup in self ._app .field_setups :
1184+ if setup .type .startswith ("NearField" ):
1185+ context = setup .name
1186+ self ._app .logger .warning (f"No Near Fields setup provided. Assigned setup: { context } " )
1187+ break
1188+ elif report_category == "Fields" and not context :
1189+ context = field_ctx
1190+ self ._app .logger .warning (f"No context provided for Fields. Assigned object: { context } " )
1191+ return report_category , context
1192+
11251193 @pyaedt_function_handler ()
11261194 def _get_report_object (
11271195 self ,
@@ -1177,6 +1245,7 @@ def _get_report_object(
11771245 ]
11781246 elif isinstance (expressions , str ):
11791247 expressions = [expressions ]
1248+ report_category , context = self ._check_category_context (expressions [0 ], report_category , context )
11801249
11811250 # Report Category
11821251 if domain in ["Spectral" , "Spectrum" ]:
@@ -1826,7 +1895,7 @@ def _report_plotter(self, report):
18261895 props ["symbol_style" ] = markers [pp ["symbol_style" ]]
18271896 except KeyError :
18281897 pass
1829- report_plotter .add_trace ([sw , sols .data_real (curve )], 0 , properties = props , name = curve )
1898+ report_plotter .add_trace ([sw , sols .get_expression_data (curve )[ 1 ] ], 0 , properties = props , name = curve )
18301899 for name , line in report ._legacy_props .get ("limitLines" , {}).items ():
18311900 props = {}
18321901 try :
0 commit comments