# Script transform on Vision

**URL:** <https://forum.inductiveautomation.com/t/script-transform-on-vision/82087>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [November 18, 2023, 10:08am UTC](https://forum.inductiveautomation.com/t/script-transform-on-vision/82087 "2023-11-18T10:08:46Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebastien\_ng](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sebastien_ng/32/55297_2.png) [@sebastien\_ng](https://forum.inductiveautomation.com/u/sebastien_ng)\
**Post date:** [November 18, 2023, 10:08am UTC](https://forum.inductiveautomation.com/t/script-transform-on-vision/82087/1 "2023-11-18T10:08:46Z")

</div>

On perspective, when we do a binding, we have option to do ScriptTranform, Why we can do it on VISION ?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [November 18, 2023, 12:39pm UTC](https://forum.inductiveautomation.com/t/script-transform-on-vision/82087/2 "2023-11-18T12:39:30Z")

</div>

Not directly. You have to move your binding to a custom property and perform your transform on a property change script.

**Note:** propertyChange events have to be checked in some way, so they only fire when the correct property change occurs.

**Example:**

```auto
if event.propertyName == 'myCustomProp':
     newValue = event.newValue
     # Do your transform on the new value here.
     # Then, assign the transformed value to the desired property.
     #component.regularProp = transformedProp

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 18, 2023, 1:53pm UTC](https://forum.inductiveautomation.com/t/script-transform-on-vision/82087/3 "2023-11-18T13:53:24Z")

</div>

You can also use `runScript()` with a project library script (or component custom method) if you want it to evaluate on a binding even when the designer is not in preview mode.

---

<div class="post-metadata">

**Author:** ![sebastien\_ng](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sebastien_ng/32/55297_2.png) [@sebastien\_ng](https://forum.inductiveautomation.com/u/sebastien_ng)\
**Post date:** [November 18, 2023, 5:14pm UTC](https://forum.inductiveautomation.com/t/script-transform-on-vision/82087/4 "2023-11-18T17:14:50Z")

</div>

I do it but when I change iduser, it not show anything on the label.  
**My syntaxe is incorrect ?**

```auto
if event.propertyName == 'event.source.iduser':
	user_id = event.newValue
	event.source.getComponent('lbtest').text = "turbine engine " +str(user_id)
	

```

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [November 18, 2023, 5:16pm UTC](https://forum.inductiveautomation.com/t/script-transform-on-vision/82087/5 "2023-11-18T17:16:04Z")

</div>

```python
if event.propertyName == 'iduser':
	user_id = event.newValue
	event.source.getComponent('lbtest').text = "turbine engine " + str(user_id)

```

---

<div class="post-metadata">

**Author:** ![sebastien\_ng](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sebastien_ng/32/55297_2.png) [@sebastien\_ng](https://forum.inductiveautomation.com/u/sebastien_ng)\
**Post date:** [November 18, 2023, 5:24pm UTC](https://forum.inductiveautomation.com/t/script-transform-on-vision/82087/6 "2023-11-18T17:24:17Z")

</div>

merci @pascal.fragnoud

---

<div class="post-metadata">

**Author:** ![sebastien\_ng](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sebastien_ng/32/55297_2.png) [@sebastien\_ng](https://forum.inductiveautomation.com/u/sebastien_ng)\
**Post date:** [November 18, 2023, 5:36pm UTC](https://forum.inductiveautomation.com/t/script-transform-on-vision/82087/7 "2023-11-18T17:36:33Z")

</div>

Est ce que je peux également lire une proprieté Custom **"city"** sur la vue en faisant binding par exemple:

```auto
if event.propertyName == 'iduser':
	user_id = event.newValue
        city = event.source.city # custom
	event.source.getComponent('lbtest').text = ciity + "turbine engine " + str(user_id) 

```

est ce que ceci est correct ?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [November 18, 2023, 5:58pm UTC](https://forum.inductiveautomation.com/t/script-transform-on-vision/82087/8 "2023-11-18T17:58:11Z")

</div>

Other than the typo in `ciity` in the last line, that should allow you to add a custom property value to a label, so long as it is a string.

Note that you could also just do an expression binding on the lbtest.text property and achieve the same thing.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [November 18, 2023, 6:14pm UTC](https://forum.inductiveautomation.com/t/script-transform-on-vision/82087/9 "2023-11-18T18:14:17Z")

</div>

Oui, mais comme le dit @lrose, un simple binding fait l'affaire.  
Ajoute cet expression binding sur ton label `lbtest` (note: I don't remember the actual path you need to use to access custom properties. Just use the property browser to select it):

```auto
{city_property} + 'turbine engine ' + {userid_property}

```

There's no need to use property change scripts just for this.

If you script has other things to do, maybe they can also be replaced by simple bindings.

---

<div class="post-metadata">

**Author:** ![sebastien\_ng](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sebastien_ng/32/55297_2.png) [@sebastien\_ng](https://forum.inductiveautomation.com/u/sebastien_ng)\
**Post date:** [November 18, 2023, 6:15pm UTC](https://forum.inductiveautomation.com/t/script-transform-on-vision/82087/10 "2023-11-18T18:15:32Z")

</div>

D'accord, merci.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [November 18, 2023, 8:00pm UTC](https://forum.inductiveautomation.com/t/script-transform-on-vision/82087/11 "2023-11-18T20:00:04Z")

</div>

I agree with @lrose and @pascal.fragnoud; a transform is overkill for this use case. The expression binding is the correct solution for string casting and concatenation.
