Access Class instance from different perspective script environments

If I create an instance of a class in a view like this:

That class is given a place in memory i.e. <__builtin__.test instance at 0x8>

If I know that memory address, is there any way that I can recall the instance of test on the second button in this page?

I don’t know if Java would allow me to do this or Python, but it would be convenient for a few use cases.



I guess another way to ask this question based off the problem,

Is there any way for me to instantiate the class in button one, and reference it in button two.

I know that I could make it serializable, store it as an object in a custom property, and then de-serialize it in the second buttons script. However sometimes you just can’t make thing serializable, so I am trying to see if I can get around that.

system.util.getGlobals maybe?

Is this just a Map in the jvm? I see that they persist across gateway lifetime which leads me to believe the instance still needs to be serializable, is this correct?

I think what that line means is that your globals map won’t be emptied every time your scripting restarts from e.g. saving a project. Not that it will be persisted and accessible again if your gateway restarts. The contents of the map do not need to be serializable.

1 Like

Sweet, thanks!

If that’s not actually the case then I have no idea why the documentation team wrote that.

Just tested it with a publish and my example still works!