# propertyChange scripting issues

**URL:** <https://forum.inductiveautomation.com/t/propertychange-scripting-issues/17456>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [March 21, 2018, 11:02pm UTC](https://forum.inductiveautomation.com/t/propertychange-scripting-issues/17456 "2018-03-21T23:02:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jasonhurd](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@jasonhurd](https://forum.inductiveautomation.com/u/jasonhurd)\
**Post date:** [March 21, 2018, 11:02pm UTC](https://forum.inductiveautomation.com/t/propertychange-scripting-issues/17456/1 "2018-03-21T23:02:56Z")

</div>

I’m seeing an unusual issue with scripting. I have the following script on property change that runs as expected under the designers preview mode but when I launch the project the repeater shrinks into nothingness. The Template Repeater layout is set to Relative during the issue and the issue does not occur when the layout it is set to Anchored. This similarly happens with a Label so it is not limited to the Repeater

```auto
system.gui.transform(component=event.source, newWidth=100)
print event.source.width
```

In the projects diagnostics console, the event continually triggers but nothing to tell the repeater to constantly get smaller.

I would appreciate any help that can be offered.

On a side note, I also can’t put the projects diagnostics console into scroll lock mode.  
On another side note, the projects diagnostics console also throws an errors if you lead a print statement with str(), such as:

```auto
print str(event.source) + "Main Object"
```

verses

```auto
print " " + str(event.source) + "Main Object"
```

```auto
Ignition Platform 7.9.6
OPC-UA Module 4.9.6
Reporting Module 4.9.6
Alarm Notification Module 4.9.6
Vision Module 9.9.6
SQL Bridge Module 8.9.6
Java Version: Oracle Corporation 1.8.0_161
```

---

<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:** [March 21, 2018, 11:14pm UTC](https://forum.inductiveautomation.com/t/propertychange-scripting-issues/17456/2 "2018-03-21T23:14:11Z")

</div>

Is that your entire script? No check for a particular propertyName? If you don’t check for specific property names, you will create infinite recursion. Probably not happening in the designer because the designer doesn’t do any component scaling like the client.

---

<div class="post-metadata">

**Author:** ![jasonhurd](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@jasonhurd](https://forum.inductiveautomation.com/u/jasonhurd)\
**Post date:** [March 21, 2018, 11:23pm UTC](https://forum.inductiveautomation.com/t/propertychange-scripting-issues/17456/3 "2018-03-21T23:23:42Z")

</div>

Thank you for a quick reply.

I have simplified it for testing down to the example given in the system.gui.transform documentation.

Here is the full code:

```auto
posX = event.source.parent.ConveyorLength
boxWidth = (100*posX)-31
count = int(round(boxWidth/36))
system.gui.transform(component=event.source, newWidth=boxWidth)
event.source.repeatCount = count
print " " + str(event.source.width) + " Links" 
```

Either way, the issue still occurs as even if I stop the reoccuring trigger the object gets smaller and smaller everytime the window size is adjusted.

Would be easier if every object had a width and height property in order to use an expression 🙂

---

<div class="post-metadata">

**Author:** ![jasonhurd](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@jasonhurd](https://forum.inductiveautomation.com/u/jasonhurd)\
**Post date:** [March 21, 2018, 11:59pm UTC](https://forum.inductiveautomation.com/t/propertychange-scripting-issues/17456/4 "2018-03-21T23:59:07Z")

</div>

I found a work around to what is happening.

I had to specify all positioning and size attributes for some reason as they are changing somehow. This obviously works differently then objects with width and height properties that can get set by expressions as the other elements in my template have no issues.

```auto
system.gui.transform(component=event.source, newWidth=boxWidth, newHeight=10, newX=14, newY=26)
```

as well of course code to stop it from continually triggering.

---

<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:** [March 22, 2018, 12:19am UTC](https://forum.inductiveautomation.com/t/propertychange-scripting-issues/17456/5 "2018-03-22T00:19:21Z")

</div>

> [@pturmel](#):
>
> No check for a particular propertyName?

You **_MUST_** check for a propertyName that triggers your code! Something like:

```auto
if event.propertyName == 'someTriggerProperty':
    system.gui.transform(event.source, .......)

```

Otherwise the transform will change some properties which will recurse back into this event, making this event call itself infinitely. Or put the code in some other event that happens _ **when** _ you want the transform.

---

<div class="post-metadata">

**Author:** ![jasonhurd](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@jasonhurd](https://forum.inductiveautomation.com/u/jasonhurd)\
**Post date:** [March 22, 2018, 12:54am UTC](https://forum.inductiveautomation.com/t/propertychange-scripting-issues/17456/6 "2018-03-22T00:54:21Z")

</div>

Yes, thank you, I have noted your point and have added an IF statement, but that didn’t fix the root issue as I indicated, the object was still changing x position, y position, and height every time the window size was adjusted and the script triggered even though those values were not told to change in the script.

---

<div class="post-metadata">

**Author:** ![Claus\_Nielsen](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@Claus\_Nielsen](https://forum.inductiveautomation.com/u/Claus_Nielsen)\
**Post date:** [March 22, 2018, 6:45am UTC](https://forum.inductiveautomation.com/t/propertychange-scripting-issues/17456/7 "2018-03-22T06:45:27Z")

</div>

What is it you are transforming? Working on a template right now where I need to transform a rectangle. This resulted in strange behavior, however wrapping it in a container and transforming that instead, solved my issue.

As a side note, I’ve had the same issue transforming template instances, much better wrapping it in a container.

---

<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:** [March 22, 2018, 12:18pm UTC](https://forum.inductiveautomation.com/t/propertychange-scripting-issues/17456/8 "2018-03-22T12:18:58Z")

</div>

With relative layout, x, y, width, and height are not the designer sizes but the runtime sizes in the client, so they _ **are** _ changing. The designer sizes are not available in the client (at least, not conveniently, and not supported).
