Creating Translation based on command

viewon

#1

Hi,

I’m using viewON version 4.0.1. I’m trying to make an object move from x1 to x2 every time I click on a button. The problem is that viewON only allow translation to happen when the analog value change from 0 to 100 . I’m trying to use " Execute viewON script" so when I click on the button it sends a value from 0-100 to a viewON analog tag. So basically every time I click the button it will start incrementing the analog tag from 0 to 100 within 5 seconds for example so my object moves smoothly from x1 to x2 . How can I script that?

Thanks in advance,

Tamer


#2

Hi @Tamer

I don’t have too much experience with Javascript but I can think of a way to do this with the BASIC IDE. But it would look a little choppy because it would be dependent on a timer and we have a minimum timer of 1 second. So it would end up being increments of 20. I’m talking with a colleague in Sweden to see if he has a better reference for this though.

Thanks,
-Tim


#4

@Tim_hms I already tried it using BASIC IDE and got exactly same results you mentioned of its being choppy. That’s why I realized it would be smoother transition if its done within ViewON. Thanks for response and I’ll be waiting for the your colleague suggestion.


#5

Hi @Tamer,

here’s what we made for a reference for you

For the button (Rectangle)
var temp = getViewOnTagVal(‘ramp key’);

if (temp == 1)
setViewOnTagVal(‘ramp key’, 0);
else
setViewOnTagVal(‘ramp key’, 1);

For the translation object example

For the ViewON tags

image

For the Script

var key = getViewOnTagVal(‘ramp key’);
var ramp_val = getViewOnTagVal(‘ramp’);

if (key == 1)
ramp_val++;

if (ramp_val > 100)
ramp_val = 0;

setViewOnTagVal (‘ramp’,ramp_val);

if (ramp_val > 100)
{
setViewOnTagVal (‘ramp key’,0);
}


#6

@Tim_hms, That did it . I only had to change the last IF statement from (ramp_val > 100) to (ramp_val == 100) so it does the animation only once.

Your help is highly appreciated . Thank you


#7

Hi @Tamer,

Glad to hear we could get it working! Is it alright for me to close out this case for now?


#8

@Tim_hms Yes Sir!