Page 1 of 1

How to access an object's property by script?

Posted: Thu Jun 27, 2013 2:08 am
by Artaxs
Hi everybody!
I'm looking for a way to change the property of an object (for example: switch the TrendViewer History On/Off) by script.
The goal is, that when a tag changes (e.g. ProductionStatus = stop), the TrendViewer stops showing the actual trend (History ON). When the production starts running again, the TrendViewer should stop showing the history and should switch back into normal operation (History OFF).
Now: is there in general a way to access objects (buttons/pictures/trendviewers/...) by script?

I really apreciate every help!

Best regards

Chris

Re: How to access an object's property by script?

Posted: Mon Jul 01, 2013 9:25 am
by mark.monroe
There is an autocomplete in the C# scripting editor. Otherwise there are no standard ways to access an objects properties. If you type in "this.NameofObject." then normally a list of the available properties will show up. You can also use the Dynamics menu to change many object properties. If you associate a tag with a property under dynamics, you then then use code to change the value of the tag and trigger the dynamic.
Snap 2013-07-01 at 09.22.04.png
Snap 2013-07-01 at 09.22.04.png (52.74 KiB) Viewed 16713 times

Re: How to access an object's property by script?

Posted: Fri Jul 05, 2013 5:32 am
by Artaxs
Hi Mark

Thank you very much for your reply. I tried it out and it works perfect.
But: the access to the properties of an object can be done with the "this" directive only as long as the script is accociated with the screen the object is in.
But how can I acces an object from a script module? Do you see a possibility for doing so?

Thank you in advance for your reply!

Chris

Re: How to access an object's property by script?

Posted: Mon Jul 08, 2013 10:48 am
by mark.monroe
"this" is a C# object that represents the current class you are within the scope of. You would need to pass a reference to the onscreen object to the script module, which is not really possible in ix Developer. The easest thing to do is call the script module functions from within your screen and either pass in the object reference there, or use tags to trigger different behaviors on your screen.

Re: How to access an object's property by script?

Posted: Thu Jul 11, 2013 2:36 am
by Artaxs
Ok, thank you very much for your reply. I'll try that out.

Best regards from Switzerland!

Artaxs