Why wouldn’t one just use python’s setattr()
function? Like so:
def setPropertyValue(comp, prop, val):
setattr(comp, prop, val)
Consider catching AttributeError, though, to fall back on the setPropertyValue() method applicable to custom properties (not always supported by setattr). Like so:
def setPropertyValue(comp, prop, val):
try:
setattr(comp, prop, val)
except AttributeError:
return comp.setPropertyValue(prop, val)