This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Is it possible to change a button objects Icon from code?
#1
Hi,
Is it possible to change the icon (or icon set) used by an object in the visualization from the Lua code? I have researched this but can't find a good example so far...
I have a use case where I need to show a specific icon on a single object in my visualization, depending on the value of a Lua code variable (which I can link to a bus-object value or level if needed).

I know each object in the graphical editor has an 'Additional Icon' menu, where you can set the icon shown to be 'X_svg' if the value is '1', 'Y_svg' if it's '2', and so on..
I have about 20 objects where I need this functionality on, and each one will have maybe 40 different individual icons to display depending on its value. 
I know it can be done manually, but it's slow and tedious, and not that easy to replicate across different projects and different LMs..

I don't think this is a suitable use case for an animated SVG.. but maybe I'm not thinking about it correctly... 
If it's useful, assume I already have these 40 SVG icons loaded into the "Vis. Graphics / Icons" tab, and I already have a Lua table with all their names...

A simple example of setting two or three icons for given values on one visu object would be fine, once I know where to start and the basic concepts, I can probably work on it from there... 

Thanks in advance,  if anyone could help I'd appreciate it.
Reply
#2
If you change something from Lua you will have to reload the visualization for changes to take effect. It's much easier to use Custom JavaScript for this. Have a look at this example which can be used as a starting point: https://forum.logicmachine.net/showthread.php?tid=2447
Reply


Forum Jump: