Hi,
I’m trying to bind the liquidColor property of the cylindrical tank to 2 or more parameters in Perspective. For example if the “Hi” parameter is true to use orange, if “HiHi” is true use red, if “Lo” is true use yellow etc.
I tried multiple “If” statements, but adding the second statement causes an error. Case/switch wouldn’t work because it compares the value of a single parameter.
Thank you,
Ali
Assuming your Hi, HiHi and Lo are bool’s, use binEnc() to combine them. It will return an int, that can be used in a case statement.
case(binEnc(tag1,tag2,tag3),
0,"all false",
1,"1,0,0",
2,"0,1,0",
4,"0,0,1",
"default")
I believe you can also use the style to set the color based on the number returned from the binEnc().
You should use the Expression Structure binding. This allows you to bind multiple values into the Expression object. I always recommend including a transform after the Expression structure, like so (you could also use an expression structure if you prefer):
That’s clever. Thank you.[quote=“bpreston, post:2, topic:43327, full:true”]
Assuming your Hi, HiHi and Lo are bool’s, use binEnc() to combine them. It will return an int, that can be used in a case statement.
case(binEnc(tag1,tag2,tag3),
0,"all false",
1,"1,0,0",
2,"0,1,0",
4,"0,0,1",
"default")
I believe you can also use the style to set the color based on the number returned from the binEnc().
[/quote]
So this can be used to assign the values of 2 parameters to 2 variables. How can I use these variables to return a string for the color?
Let's say I bind variable 'a' to the 'Hi' param and 'b' to 'HiHi'. I end up with 2 boolean variables that match the boolean parameters. I need the output to be a string based on the state of the parameters/variables. This string would set the liquidColor property of the cylindrical tank. What is the operator I would need to evaluate these 2 (or more) variables and map to a string?
Thanks,
Ali
That’s what you use the transform for. You can specify any logic and return you’d like in the transform, so you could do something like
color = '#FFFF00'. # default to yellow, or you can wrap this in logic.
if value['a']:
color = '#FFA500' # if "Hi", then use orange
if value['b']:
color = '#FF0000' # if "HiHi" then use red
return color