Custom Property Change Script Execution

Hi all,

I have a question regarding how the change script on a custom property under a view works and executes. Here is what I have set it up:

  • 15 pieces of pipes using the pipe tool in perspective in a view called “PID”

  • created a custom property called “EM_Scheme” and this custom property is bound to an OPC tag

  • placed a change script on the “EM_scheme” custom property. If it is equal to 1, the scripts will set pipes 0, 1, and 4 to color blue with fill and stroke props. If it is equal to 3, the script will set pipes 5,6, and 8 to yellow with fill and stroke props. These are just examples that I used. The script I tested below might not match but the point remains.

But when I was testing it, the script only executed successfully in the designer view but the session view didn’t update with the correct pipe color.
image
image

Has anyone encountered the same issue? Is there a fix for this?

Is what you’ve posted your entire script?

I’d think you need to be setting/resetting the colors for all pipes for each possible flow path. Just because one state sets the color to noflow doesn’t mean all other states automatically set the color to hasflow.

I did have the reset, and it is when EM_scheme = 0. what I posted was a bad example. I think my question is why the script only works in designer but not client.

Do you see any errors in the gateway logs when you try this? Since the custom property isn’t persistent, I know some users have encountered problems because the first time you try to use currentValue.value you’ll hit an exception because currentValue is None.

Actually I found the problem…My color for no flow is missing a #

I do have another question. Between direct binding and the property change script for pipe color change, is one better than the other? The property change script is definitely better in terms of development time. I’m curious about robustness.

I personally recommend bindings when you can. While you might think that the change script is easier or faster, it’s also less clear later during maintenance when you’re trying to find how a value keeps changing because the process actually changing it is hidden on some other proeprty.

1 Like

But performance-wise, they are not significantly different?

Anything that involves a executing a Jython script is slower than the alternative that doesn’t.

1 Like

The difference is I am using one or two scripts to evaluate all the pipes, whereas there could be 50 pieces of pipes and each of them has binding and transform. Is direct binding still the better performance approach in this case?

Ah, I don’t know for sure :man_shrugging: