Been a hot minute since I used MXS
I was going to point you to an old bookmarked CG talk thread on Struct based UI tool scoping
But it turns out CG Talk shut down this month
All I have is this example
/*
DennisT's example of a Max Script Struct based tool, correctly scoped as global
source CG talk thread:
https://forums.cgsociety.org/t/avoiding-multiple-dialog-copies-in-a-struct-tool/1639975/2
*/
global TheTool
(
struct ToolStruct
(
dialog = rollout dialog "Dialog"
(
local owner = if owner != undefined do owner
label info_lb align:#center
on dialog open do info_lb.text = timestamp() as string
),
fn destroy = try(destroydialog TheTool.dialog) catch(),
fn show =
(
destroy()
createdialog dialog
),
on create do
(
destroy()
dialog.owner = this
)
)
TheTool = ToolStruct()
ok
)
TheTool.show()
I suspect " opening and closing the rollout " isn’t clearing it from the RAM, it still exists in the initialized state; which is what the destroy
fn takes care of in the above case. Perhaps you can mutate this into what you need…