Project Custom Property

I want to define some properties, and these properties can be used in the Project Library, so what ways can I achieve this requirement?

1 Like

Perspective?
Its possible to add custom session properties.
You can access those by pressing image and open the perspective property editor.

Yes, Perspective.
If I add custom session properties, how can I get this properties in Project Library?

What exactly do you mean by “Project Library”?

image

define function in project library, and can get this properties in this function

Does session.custom.myCustomProp work?

If not you can always add session into the function

def doSomethingWithSession(session):
   print session.custom.myCustomProp

doSomethingWithSession(session)
(could also be self.session idk)

As @victordcq said.
Also, know that session props are client scoped; changing a value in one client will not change it in another.

If you want the same values across all clients, then you can use memory tags and then read and write to them using system.tag.writeBlocking/Async

Thank you for your reply.
except using session and memory tag, is there any other way?
For example, can set these properties on the gateway or use the config file to set these properties, so that the functions in the Project Library can get it?

I’m sure you might be able to use the ignition.conf or another file on the gateway such as an ini and use ConfigParser to read the config.

You can get the ignition install directory using: How to get Ignition install directory (OS agnostic)? - #3 by nminchin
Note: this will only work from the gateway scope, so from gateway event scripts, tag change events, etc.
What are you trying to store?

Storing things in config files seems not something one should do to much.
Tags or a database is also always a good option to store things.

1 Like

I take a shot at it.
Thank you for your reply.