Expression Property - How to calculate values?


have some troubles using VC_EXPRESSION in Python AddOn:


from vcCommand import *

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

def OnStart():

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

addState( None )


1+4 OK

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


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.