Bind layer/element of custom SVG component to Tag event in Perspective View

Hi! I have an SVG (that I made) that I have embedded in a Perspective View coordinate container. There are multiple elements and layers in that SVG. I would like to bind an element’s fill paint to a Tag using a Map Transform.

I know it is possible to do this when the Map’s Output Type is a Color, but I will be applying this transform to many other elements, in several different views, so I would much rather have the Output Type be a Style Class so I can edit them all at once, but it does not seem to work.

Bind_OutputColor

I looked into scripting, but since Tag Event scripting is Gateway scoped, I don’t believe it is possible to change a component in any way like that. Am I mistaken? What are the available options to achieve that?

Thanks in advance!

1 Like

Instead of a Map transform, I would use a script transform which requests a color from a project script. This would allow you to update the colors in one place (the project script) while not needing to go to each element to update any transform.

SvgPackage (project script):

def getFill(tagValue):
    colorMap = {
        0: "#FF0000",
        1: "#00FF00"
    }
    fallback = "#FFFFFF"
    return colorMap.get(tagValue, fallback)

Transform:

def transform(self, value, quality, timestamp):
	return SvgPackage.getFill(value)
2 Likes

You can also just delete the fill prop within the element and use the style prop which can have the classes prop within it.