Hi there,
I’m working on a script which automatically updates properties with values taken from an excel file. I’m using this line
PVMT.set_p_v_value(element_obj, prop_name, new_value)
which uses this code that I saw in previous topics that I manually added in the API file:
def set_p_v_value(elem, PVName, value):
for group in elem.get_java_object().getOwnedPropertyValueGroups():
for pv in group.getOwnedPropertyValues():
if PVName == pv.getName():
pv.setValue(value)
return
It works flawlessy for boolean, integer, float and string properties, as long as new_value
is a variable that is compatible with the property. It doesn’t work with Enumeration Properties. In this case, I read from excel the name of the Enumeration Literal to apply to the property as a string. This is likely the problem, because when set_p_v_value
tries to apply a string to the Enumeration Property, I get this error: py4j.Py4JException: Method setValue([class java.lang.String]) does not exist
. I’m pretty sure that, when the property is an Enumeration Property, I have to ‘process’ new_value
in order to make it a compatible variable with the property (an Enumeration Literal?) instead of a string. I’ve already tried this other version of the command:
def set_p_v_value(elem, PVName, value):
for group in elem.get_java_object().getOwnedPropertyValueGroups():
for pv in group.getOwnedPropertyValues():
if PVName == pv.getName():
if isinstance(java_object, JavaObject):
pv.setValue(value.get_java_object())
else:
pv.setValue(value)
return
but it doesn’t solve the issue.
Thanks in advance.