@@ -693,7 +693,14 @@ def aedt_object(self, variable):
693
693
694
694
@pyaedt_function_handler ()
695
695
def set_variable (
696
- self , variable_name , expression = None , readonly = False , hidden = False , description = None , overwrite = True
696
+ self ,
697
+ variable_name ,
698
+ expression = None ,
699
+ readonly = False ,
700
+ hidden = False ,
701
+ description = None ,
702
+ overwrite = True ,
703
+ postprocessing = False ,
697
704
):
698
705
"""Set the value of a design property or project variable.
699
706
@@ -763,9 +770,9 @@ def set_variable(
763
770
test = desktop_object .GetName ()
764
771
proj_name = self ._oproject .GetName ()
765
772
var_type = "Project" if "$" in variable_name [0 ] else "Local"
766
-
767
773
prop_type = "VariableProp"
768
-
774
+ if postprocessing or "post" in variable_name .lower ()[0 :5 ]:
775
+ prop_type = "PostProcessingVariableProp"
769
776
if isinstance (expression , str ):
770
777
# Handle string type variable (including arbitrary expression)# Handle input type variable
771
778
variable = expression
@@ -789,16 +796,13 @@ def set_variable(
789
796
except :
790
797
pass
791
798
else :
792
- raise Exception ("Unhandled input type to the design property or project variable." )
793
-
794
- if "post" in variable_name .lower ()[0 :5 ]:
795
- prop_type = "PostProcessingVariableProp"
799
+ raise Exception ("Unhandled input type to the design property or project variable." ) # pragma: no cover
796
800
797
801
# Get all design and project variables in lower case for a case-sensitive comparison
798
802
if self ._app ._is_object_oriented_enabled ():
799
803
var_list = list (desktop_object .GetChildObject ("Variables" ).GetChildNames ())
800
804
else :
801
- var_list = list (desktop_object .GetVariables ())
805
+ var_list = list (desktop_object .GetVariables ()) # pragma: no cover
802
806
lower_case_vars = [var_name .lower () for var_name in var_list ]
803
807
804
808
if variable_name .lower () not in lower_case_vars :
@@ -880,7 +884,13 @@ def set_variable(
880
884
],
881
885
]
882
886
)
883
-
887
+ if self ._app ._is_object_oriented_enabled ():
888
+ var_list = list (desktop_object .GetChildObject ("Variables" ).GetChildNames ())
889
+ else :
890
+ var_list = list (desktop_object .GetVariables ()) # pragma: no cover
891
+ lower_case_vars = [var_name .lower () for var_name in var_list ]
892
+ if variable_name not in lower_case_vars :
893
+ return False
884
894
return True
885
895
886
896
@pyaedt_function_handler ()
@@ -950,7 +960,7 @@ def delete_variable(self, var_name):
950
960
if self ._app ._is_object_oriented_enabled ():
951
961
var_list = list (desktop_object .GetChildObject ("Variables" ).GetChildNames ())
952
962
else :
953
- var_list = list (desktop_object .GetVariables ())
963
+ var_list = list (desktop_object .GetVariables ()) # pragma: no cover
954
964
lower_case_vars = [var_name .lower () for var_name in var_list ]
955
965
956
966
if var_name .lower () in lower_case_vars :
0 commit comments