MAXScript: How to create layered .NET window in Windows Forms


I also have not encountered a similar task before, so it became interesting for me to implement animation in WPF. This may come in handy somewhere in the future for other tasks.

By the way, during testing, I found that animation freezes occur only when the splash screen is launched before loading the main script in 3ds max 2021. If you run in 3ds max 2020, then there are no freezes and the splash screen works smoothly and stably. What is the reason for this, I still cannot understand.


Yea! and this is proper way to create Image Sequence Player with WPF (Iā€™m not implemented multithread things)

global wpfWindow
	if wpfWindow != undefined do wpfWindow.close()
	xamlString =
	<Image Source='{Binding SelectedItem}'>
			<EventTrigger RoutedEvent='Loaded'>
							To='{Binding Items.Count}'
	wpfWindow = (dotnetclass "System.Windows.Markup.XamlReader").Parse xamlString
	for image in getfiles "C:/Temp/Gifs/Anim/*.png" do wpfWindow.DataContext.items.add image
	(dotnetobject "System.Windows.Interop.WindowInteropHelper" wpfWindow).owner = dotnetobject "IntPtr" (windows.getMAXHWND())
	(dotnetclass "ManagedServices.AppSDK").ConfigureWindowForMax wpfWindow
-- 	wpfWindow.close()


Found something useful (to me) to do with this, an asynchronous real-time Heap Monitor. (WIP)
So far it works stable from Max 2014 to Max 2022.

Here testing with some loops:

And here testing the Heap usage with 250 scripted controllers:


Have you tried it in 21/22? Working same (second gif)?

Fckn 403!
And I thought it wont accept too short answer!


as I see the memory leak is bad :face_with_raised_eyebrow:


The .gif is from 2021.


The leak is terrible not bad. But I wanted to show an animation consuming the heap. Changing a few lines it uses like 100 times less memory.


I have similar experience with script controllers. Memory usage by the script controller is very sensitive to script syntax. This topic is absolutely not covered in the 3DS MAX docs. But should be!


Here is the optimized version:


a big difference!