Hi guys
Hi guys,
I am changing some variables and properties of objects upon switching to another screen. Changing variables is easy, but I am missing something when it comes to editing the box object. Here are screenshots of the error I am getting and my script.
Another thing I dont seem to get right is accessing an object inside a panel through script. That’s no longer part of the script below though due to the same error. If I can resolve the one below, I might have a better chance of succeeding at getting both right.
Please help me out?
Ok, I have managed to get this far without getting any errors…but the colours don’t change. I have been over the API reference dozens of times and I can’t see what is wrong. Is this a bug?
https://lh3.googleusercontent.com/zBwHs1JTcJZxkd22A9BIB0BR9QY-Re6wm0y6jBaCy4i3Ci4RWzyvZciPfewDsZ1GEKwksGDy6Q
You need to commit the changes.
When doing edit, keep a reference before getting the box.
After modify the box, call commit.
TrianguloY I figured it out eventually. Thanks anyway. I am struggling though to reference an object inside a container.
You can access directly the item by id, access its container by id and then the item by name, or recursively by name accessing all its parents.
Remember you can access a container from its parent with item.getContainer()
I refrained from using id, because I read that accessing and item by id isn’t full proof, because the id of an item can change when the template is restored (which makes sense), but then people will experience problems if I share my template. I guess this is something that cannot be avoided unless they completely replace their setup with my template.
Thanks for the info TrianguloY. I’ll give it a shot.
Yes, ids change when importing templates, and also when moving items from a container to another. If you plan to share your setup better use the hierarchical search of names.
desktop.getItemByName(“folder/panel_name”).getContainer().getItemByName(“subfolder/panel_name)…getContainer().getItemByName(“item_name”)
However, according to your screenshots you want to access the items to change the color of the box, right? If so I highly recommend using bindings and variables…which you are already using!
In the item, set the box property to
“cns:0x”+$varScreenColor.toString(16)
Yes yes yes! Excellent! 🤗👏Holy shit bro, you are so damn helpful! The hierarchial search is exactly what I’ve been trying to accomplish.
I couldn’t figure out how the box property is used in bindings and it doesn’t seem to be documented, so thanks a mil for that info. I think I’ll go that route.
If I could +10 that post I would. Lolz!
Long click the ‘add binding’ and you will find the required documentation 😉
Ooooh! Right, i forgot about that🙈🙈🙈
Hai guys