Expression Property - How to calculate values?

Hi

have some troubles using VC_EXPRESSION in Python AddOn:

AddOn

from vcCommand import *

prop = createProperty(VC_EXPRESSION, ‘Ergebnis’)
prop.Value = ‘1+4’

def OnStart():
executeInActionPanel()

print prop.Value
print ‘-----’
print prop.CalculatedValue

addState( None )

RESULTS

1+4 OK

1+4 NOK ??? shouldn’t that be 5


thanks

This looks like a bug. As workaround you could use the python in-build exec statement to evaluate the value of the expression property.

That’s really strange. I tested this issue and it seems like it does only occur when you want to get the CalculatedValue in an addon. If you use it inside a components python script, it works just as expected.

Howsoever, using

calculated = eval(prop.Value)

works just fine as a workarround.