How to access an object's property by script?

A forum devoted to the discussion of all topics having to do with scripting and other advanced programming using iX Developer.
Post Reply
Artaxs
Posts: 10
Joined: Tue Nov 06, 2012 7:02 am
Location: Switzerland

How to access an object's property by script?

Post 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

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

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

Post 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 16711 times
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

Artaxs
Posts: 10
Joined: Tue Nov 06, 2012 7:02 am
Location: Switzerland

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

Post 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

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

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

Post 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.
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

Artaxs
Posts: 10
Joined: Tue Nov 06, 2012 7:02 am
Location: Switzerland

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

Post by Artaxs »

Ok, thank you very much for your reply. I'll try that out.

Best regards from Switzerland!

Artaxs

Post Reply