Is it possible to change a button objects Icon from code? - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Is it possible to change a button objects Icon from code? (/showthread.php?tid=3260) |
Is it possible to change a button objects Icon from code? - Paddyb - 26.03.2021 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. RE: Is it possible to change a button objects Icon from code? - admin - 27.03.2021 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 |