# Perspective large and complex SVG animation tips please

**URL:** <https://forum.inductiveautomation.com/t/perspective-large-and-complex-svg-animation-tips-please/63526>\
**Category:** Ignition\
**Tags:** perspective, ignition81\
**Created:** [August 27, 2022, 8:21am UTC](https://forum.inductiveautomation.com/t/perspective-large-and-complex-svg-animation-tips-please/63526 "2022-08-27T08:21:06Z")\
**Posts on this page:** 12\
**Page:** 3

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [December 16, 2022, 4:17pm UTC](https://forum.inductiveautomation.com/t/perspective-large-and-complex-svg-animation-tips-please/63526/41 "2022-12-16T16:17:09Z")

</div>

Yes I use IDs and also groups. For example put all gas lines in one group one oil lines in other group then loop thought and assign them correct colour base on their ids

---

<div class="post-metadata">

**Author:** ![tcrucet](https://avatars.discourse-cdn.com/v4/letter/t/76d3ee/32.png) [@tcrucet](https://forum.inductiveautomation.com/u/tcrucet)\
**Post date:** [December 17, 2022, 2:11pm UTC](https://forum.inductiveautomation.com/t/perspective-large-and-complex-svg-animation-tips-please/63526/42 "2022-12-17T14:11:56Z")

</div>

Thanks! Im trying this and its pretty good as long as you keep the nesting really flat. But I have a question: what if you want to use style classes? The svg import doesnt have style:classes attributes. There isnt a function i know of to add them everywhere with script inside ignition directly if you're using an iterator, though apparently if you do a getsibling reference it does... How do you add the atttributes and get rid of fills that conflict with them? Do you process the svg externally first before importing?

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [December 17, 2022, 8:01pm UTC](https://forum.inductiveautomation.com/t/perspective-large-and-complex-svg-animation-tips-please/63526/43 "2022-12-17T20:01:41Z")

</div>

The SVG elements are just json/(dicts/lists), so you can add and remove keys at your own discretion, including any fill.paint and style.classes keys

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [January 21, 2025, 11:42pm UTC](https://forum.inductiveautomation.com/t/perspective-large-and-complex-svg-animation-tips-please/63526/44 "2025-01-21T23:42:35Z")

</div>

What is the `value` here in your transform? I'm assuming a stroke dictionary? The dictionary didn't work.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [January 22, 2025, 12:05am UTC](https://forum.inductiveautomation.com/t/perspective-large-and-complex-svg-animation-tips-please/63526/45 "2025-01-22T00:05:22Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/1/816997655bf34205a477a2e2ccc1408432bffd13.png)  
The colour as a string

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [January 22, 2025, 2:07am UTC](https://forum.inductiveautomation.com/t/perspective-large-and-complex-svg-animation-tips-please/63526/46 "2025-01-22T02:07:59Z")

</div>

Gotcha, it does not seem to like Hex color strings, even though the SVG XML specifies the color like this: `stroke:#eb1818`

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [January 22, 2025, 8:58am UTC](https://forum.inductiveautomation.com/t/perspective-large-and-complex-svg-animation-tips-please/63526/47 "2025-01-22T08:58:38Z")

</div>

Hex string should work too, did you notice the `''` ?  
`stroke='"+value+"'`

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [January 22, 2025, 5:18pm UTC](https://forum.inductiveautomation.com/t/perspective-large-and-complex-svg-animation-tips-please/63526/48 "2025-01-22T17:18:57Z")

</div>

Si, Senor.

```python
data:image/svg+xml, <svg xmlns='http://www.w3.org/2000/svg' viewBox='20 0 96 96'><rect width='10%' height='100%' stroke='red'/></svg>

```

This works.

`stroke='#ff0000'` this does not:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/a/6a19cca4a54d072054ff5d716dcfcc65e1d74bd4.png)  
I don't know why this does not work, since in the SVG XML the `#` exists.

Neither does this: `stroke='"#ff0000"'`.  
Nor this: `stroke='"+#ff0000+"'`. This should not work because the Hex value is not a variable.  
Nor this: `stroke='ff0000'`. The rendered color is `black`, same result I get when using this: `stroke='"+value+"'`, probably because the Designer does not have a real color value to use (render?) and `black` is the fallback? The color should be `red`.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/9/793460a7de02e9021d0bce845b31a0b864b7c6c6.png)

Not sure what I'm missing Victor.

**EDIT** : I changed the size btw, just playing around with it.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [January 23, 2025, 7:43am UTC](https://forum.inductiveautomation.com/t/perspective-large-and-complex-svg-animation-tips-please/63526/49 "2025-01-23T07:43:34Z")

</div>

Oke i found the issue, its a string to url parsing issue...

replace `#` with `%23` (its the url code for #)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/4/74a129f74abcb015b74b2c527826bcd3361ac5ac.png)  
`

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [January 23, 2025, 5:02pm UTC](https://forum.inductiveautomation.com/t/perspective-large-and-complex-svg-animation-tips-please/63526/50 "2025-01-23T17:02:43Z")

</div>

Yeah, never would have guessed that, lol. Thanks!

---

<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:** [January 23, 2025, 6:01pm UTC](https://forum.inductiveautomation.com/t/perspective-large-and-complex-svg-animation-tips-please/63526/51 "2025-01-23T18:01:53Z")

</div>

I would do the encoding in the script transform:

```python
from java.net import URLEncoder

return "data:image/svg+xml, <svg xmlns='http://www.w3.org/2000/svg' viewBox='20 0 96 96'><rect width='10%' height='100%' stroke='" + URLEncoder.encode(value) + "'/></svg>

```

Then you can set the expression to `#ff0000` which is probably more obviously a color to others you may look at this in the future.

For reference this:

```python
from java.net import URLEncoder

value = '#ff0000'
print URLEncoder.encode(value)

```

Outputs:

```python
>>>
%23ff0000
>>>

```

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [January 24, 2025, 8:20am UTC](https://forum.inductiveautomation.com/t/perspective-large-and-complex-svg-animation-tips-please/63526/52 "2025-01-24T08:20:37Z")

</div>

Hm i actaully think "#" might be one of the few unique url encoded cases, and not everything has to (or even is allowed) to be encoded. a replace ('#') might be safer (untill you come across other examples).

but i havent rly looked into it much... but its clear that spaces do work, while it might break those after encoding them too %20 (no idea if it does)

[Previous page](https://forum.inductiveautomation.com/t/perspective-large-and-complex-svg-animation-tips-please/63526.md?page=2)
