1
$\begingroup$

I have a variable in a driver that I would like to be able to "switch on and off". To do this, I figured I could give this variable a power, another variable that would link to a custom property. I can then make the custom property 1, for enabled, or 0 for disabled - as a number to the power 0 is 1 and 1 multiplied by another number is just that other number.

I.e. x^y*z .

However Blender doesn't seem to support this. Here is the error from the console: Traceback (most recent call last): File "", line 1, in TypeError: unsupported operand type(s) for ^: 'float' and 'float'

Any ideas as to why this is? It seems like pretty standard math to me. If not, any ideas how to get around it?

$\endgroup$
4
  • 3
    $\begingroup$ simple python syntax error, use ** for power of. $\endgroup$ – David Jun 16 '16 at 5:14
  • $\begingroup$ not strictly a Blender issue either... this would be equally well at home on stackoverflow: stackoverflow.com/questions/34258537/… $\endgroup$ – zeffii Jun 16 '16 at 7:45
  • 1
    $\begingroup$ I'm voting to close this question as off-topic because it pertains to the meaning and effect of default operator symbols in Python. $\endgroup$ – zeffii Jun 16 '16 at 7:48
  • $\begingroup$ Or just use x * z if y else x as your driver expression. $\endgroup$ – batFINGER Jun 16 '16 at 8:53
1
$\begingroup$

As I said in the comments

Raising a value to a power is pretty standard math, something python can defiantly do.

Your trouble comes from a simple python syntax error. You are using ^ when the syntax in python is ** for power of (^ is the bitwise XOR operator ). As you can see here in the python docs ** is the the correct form.

You could alternatively use pow() function.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.