# Moving an object based on a tag value

**URL:** <https://forum.inductiveautomation.com/t/moving-an-object-based-on-a-tag-value/8498>\
**Category:** Ignition\
**Created:** [May 28, 2014, 8:37pm UTC](https://forum.inductiveautomation.com/t/moving-an-object-based-on-a-tag-value/8498 "2014-05-28T20:37:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![oxanemi](https://avatars.discourse-cdn.com/v4/letter/o/0ea827/32.png) [@oxanemi](https://forum.inductiveautomation.com/u/oxanemi)\
**Post date:** [May 28, 2014, 8:37pm UTC](https://forum.inductiveautomation.com/t/moving-an-object-based-on-a-tag-value/8498/1 "2014-05-28T20:37:52Z")

</div>

I have a Spray nozzle component and a tag that dictates the Spray nozzle position.  
I want the Spray nozzle to move down (relY) for every change in the tag

As I change the value of the tag from 0 to 60, I want it to change the position of Y from 420 to 480.

For example, if the value of tag=20, then the position of Y= 440

Is there an expression for this? Or do I have to write a script with a block of if statements?

---

<div class="post-metadata">

**Author:** ![jpark](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jpark](https://forum.inductiveautomation.com/u/jpark)\
**Post date:** [May 28, 2014, 9:08pm UTC](https://forum.inductiveautomation.com/t/moving-an-object-based-on-a-tag-value/8498/2 "2014-05-28T21:08:20Z")

</div>

Should be able to bind the Y property of the object to an expression.

{Tag} + 440

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [May 28, 2014, 9:49pm UTC](https://forum.inductiveautomation.com/t/moving-an-object-based-on-a-tag-value/8498/3 "2014-05-28T21:49:06Z")

</div>

It looks like you are going to have to do this with a custom property and scripting. The x and y positions aren’t in the binding (at least not for 7.5.11).

You could try something like this:

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/6/1661fb9fc40e5f80fc2926cc5f8628ba3d4a9a1b.jpeg)

The custom property is an integer and it is bound to the tag YourTag.

```auto
if event.propertyName == "relY":
	system.gui.moveComponent(event.source, event.source.getX(), event.newValue + 420)
	
```

NOTE: The use of the “getX()” method here is unsupported by Inductive Automation and it may disappear in the future.

---

<div class="post-metadata">

**Author:** ![oxanemi](https://avatars.discourse-cdn.com/v4/letter/o/0ea827/32.png) [@oxanemi](https://forum.inductiveautomation.com/u/oxanemi)\
**Post date:** [June 2, 2014, 8:50pm UTC](https://forum.inductiveautomation.com/t/moving-an-object-based-on-a-tag-value/8498/4 "2014-06-02T20:50:31Z")

</div>

[quote]Should be able to bind the Y property of the object to an expression.

{Tag} + 440[/quote]

It was as simple as this! Thank You!

---

<div class="post-metadata">

**Author:** ![oxanemi](https://avatars.discourse-cdn.com/v4/letter/o/0ea827/32.png) [@oxanemi](https://forum.inductiveautomation.com/u/oxanemi)\
**Post date:** [June 2, 2014, 8:52pm UTC](https://forum.inductiveautomation.com/t/moving-an-object-based-on-a-tag-value/8498/5 "2014-06-02T20:52:37Z")

</div>

[quote=“adamaustin”]It looks like you are going to have to do this with a custom property and scripting. The x and y positions aren’t in the binding (at least not for 7.5.11).

You could try something like this:

The custom property is an integer and it is bound to the tag YourTag.

```auto
if event.propertyName == "relY":
	system.gui.moveComponent(event.source, event.source.getX(), event.newValue + 420)
	
```

NOTE: The use of the “getX()” method here is unsupported by Inductive Automation and it may disappear in the future.[/quote]

I tried this too and it worked! My object already had an X and a Y property so I basically used an expression and incremented the tag by 420!

Thank you!
