tyFlow Forum
Share objects across multiple script operators - Printable Version

+- tyFlow Forum (https://forum.tyflow.com)
+-- Forum: tyFlow Discussion (https://forum.tyflow.com/forum-1.html)
+--- Forum: Feature Requests (https://forum.tyflow.com/forum-4.html)
+--- Thread: Share objects across multiple script operators (/thread-3768.html)



Share objects across multiple script operators - wbk - 07-18-2023

There doesn't appear to be an easy way to create data structures that survive and are accessible across different script operators across the whole flow.

You can create static member variables for script nodes that at least survive and retain their values across a script operators evaluation - although I am not sure yet if they are safe between multiple evaluations of the same script operator?  (ie do you recreate/new the script operator C# class every time it is evaluated?).

Being able to root a custom context object at the global and flow level via the tyflow interfaces would be one way of doing this.  Another way could be some sort of global script operator that defines and provides an interface and object that is accessible from all other script operators.


RE: Share objects across multiple script operators - tyFlow - 07-18-2023

Everything you write in a Script operator is couched in a custom, hidden class at compile-time (compilation only occurs when a script changes, so it survives across multiple frames in a sim)....so in that sense it's not possible to write code in one script that is accessible from another.

You could use MAXScript (outside of the Script operator) to instantiate your own C# classes, which you could then access from any Script operator.


RE: Share objects across multiple script operators - wbk - 07-19-2023

(07-18-2023, 01:30 PM)tyFlow Wrote: Everything you write in a Script operator is couched in a custom, hidden class at compile-time (compilation only occurs when a script changes, so it survives across multiple frames in a sim)....so in that sense it's not possible to write code in one script that is accessible from another.

You could use MAXScript (outside of the Script operator) to instantiate your own C# classes, which you could then access from any Script operator.

Ok I see thanks for clarifying!