Button writing to Custom property

#1

I simply want to write the beginning of a tag path to a custom property using a button.

Based on 3 different buttons on the screen, when pressed, I want it to change the script property to a different tag path
Example:

GasWellSites/SkilletHill/SkilletHill_Meter
GasWellSites/SkilletHill/SkilletHill_Meter2
GasWellSites/SkilletHill/SkilletHill_MeterTotal

image

Or to be done with a dropdown selection. I have this script elsewhere, being used for a dropdown selection, but it swaps windows and passes the custom property in. I do not think it needs to be this complicated to execute what I need.

0 Likes

#2

Why don’t you just write directly to the custom property?

Event.source.parent...GasWells = newValue
Where … Is the path to the root container

1 Like

#3

I was unsure of the correct syntax; but I am still having issues and what part exactly to include from the path and how to enter it. I have tried many ways to try and get it right.

event.source.parent.PopUps.Production.MeterScreeenSkilletHill.Gas Flow Trending.GasWells = “GasWellSites/SkilletHill/SkilletHill_Meter”

PopUps/Production/MeterScreeenSkilletHill is the path to the window and the root container is named “Gas Flow Trending”

0 Likes

#4

You can’t directly access arbitrary nested components as properties (in Vision, at least; Perspective is a different ballgame) - you need to drill down using successive getComponent calls, like this:

event.source.parent.getComponent("PopUps").getComponent("Production").getComponent("MeterScreeenSkilletHill").getComponent("Gas Flow Trending").GasWells = “GasWellSites/SkilletHill/SkilletHill_Meter”

0 Likes

#5

You should just need a string of .parent to get to the root container. You shouldn’t need to use getComponent as the parameters you’re accessing are from the root container.
But you should be able to pick the GasWells property on root container using the component property picker in the script editor (top right icon panel).

E.g. It might be
event.source.parent.parent.parent.GasWells

0 Likes

#6

Also, it would actually be better if you used an expression binding that bound the GasWells value to the drop down selectedLabel property. That way it’s bound to an expression, and not simply written to when an event is fired, which can sometimes mean the value isn’t written to it if the propertyChange event doesn’t fire. For example in the designer when you have it in design mode and you manually write to the dropdown selectedValue or selectedLabel property

0 Likes

#7

Uhm, the button and the target property aren’t in the same window, are they?

If so, you need to get a reference to the target window like so:

w = system.gui.getWindow("path/to/my/window")
w.rootContainer.someProperty = someValue
1 Like

#8

event.source.parent.GasWells = ‘GasWellSites/SkilletHill/SkilletHill_Meter’
event.source.buttonBG = 204,255,204
event.source.parent.getComponent(“ButtonMeterTotal”).buttonBG = 251,250,249
event.source.parent.getComponent(“ButtonMeter2”).buttonBG = 251,250,249

This is what I have working, I understand wanting to bind it rather than just write to it, I may come back to that later. For now this works.
Also, I think I stumbled upon the “buttonBG” to change the background color.
This is coming up again; I want to use a button to write to a components visibility property.
Is there a list of each property and the corresponding string needed?
ie. Background Color = buttonBG

I want the visibility property of an easy chart
so far :: event.source.parent.getComponent(“Easy Chart 1”).visible = 1

0 Likes

#9

Ok I must have been making a mistake before, because .visible is correct. The list, or where to find more information would be very useful though, for other properties that may vary as the background color, or an explanation.

0 Likes

#10

Properties are usually called out in the manual for components. A faster way for many of them as well is to hover over them in the property editor in the designer. It usually will say what the scripting name of the property is.

0 Likes

#11

Great, thank you for the hover method. Very easy.

0 Likes