Share objects across multiple script operators
#1
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.
  Reply
#2
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.
  Reply
#3
(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!
  Reply


Forum Jump: