dotNetPropertyInspector

Came up with this crazy idea while working on a tool that had a few different dotNet components and I was tired of doing a showProperties on them. Basically this is a utility to allow a user to temporarily modify a dotNet component’s properties in a propertyGrid, you can then take note of what properties there are what values work well, rapidly prototype look of UI’s, etc. Basically the ability that VS gives you, but inside Max. Thought others might benefit so here ya go. Screenshot attached

To get a better idea of what this does, execute the attached script, two windows will pop up, one with a simple MaxForm and button, the other will have two propertyGirds and a dropdown in it. In the dropdown pick the component you want to play around with and the propertyGrid will fill in with data. If the property you change has other properties the 2nd propertyGrid will get info in it.

To get it to work with your dotNet component simply add a watchMe:control(#), for example:
mButton = dotNetObject “System.Windows.Forms.Button”
add a line:
watchMe.control1 = mButton
After adding this line and running your script you will be able to run
dotNetInspectMe()
and have your control be in the dropdown.

Comments\Suggestions\Questions welcomed and if anyone can tell me why I get a “undefined” line when I execute this I would be most grateful as it is making me grumpy.

Nice dave, that looks helpful! Thanks for sharing.

Fannnnntastic! Perfect timing for this, my man. Good stuff.

Thanks for contributing.

Alec

A friend of mind has just complained to me about this issue the other day!
Definitely perfect timing!
Thanks.

This is a really great tool David. Thanks.

But I started getting garbage collection errors every time I used it. I noticed that you’re setting event handlers on controls without changing their lifetime control settings. So I added these two lines at the end of the “dotNetPropertyInspector” function, after the controls are added, and I haven’t gotten any more garbage errors.


dotNet.setLifetimeControl inspector_propertygrid_main #dotnet
dotNet.setLifetimeControl control_comboBox #dotnet

I’ve been wrestling with this myself, trying to weed out random system crashes I’ve been getting since using more and more dotNet in Max, and I think using the proper lifetime control setting is really important.

Much appreciated! Yesterday I was adding more .NET UI goodness to our pass rendering plugin so this would have come handy! I’ll be sure to make use of this from now on.

Hey David,
You could try changing the way you’re adding the event handlers after adding the controls to the form, otherwise the controls lifetime is longer than the mxs values wrapping the controls because if you do a gc() the controls that have event handlers stop working.

Ex:

- Add the controls to the main form
hForm.Controls.Add(txtTextBox)
hForm.Controls.Add(btnOpenFile)
hForm.Controls.Add(btnPrint)

-- set lifetime control of buttons to be controlled by .net
dotnet.setLifetimeControl btnOpenFile #dotnet
dotnet.setLifetimeControl btnPrint #dotnet

Maybe this can help with the garbage collection errors.

Cheers.

Its good to hear that some of you are getting use out of this. :slight_smile:

This was early on in my dotnet journeys and there are definitely a few things I would change.

Is the setLifetimeControl a 2009-10 addition? Adding it to the script in 2008 causes things to cough up a giant fur ball.

Gunna see if I can find some time to play around with a vaild gc option for 2008. Will post if I can get things working better.

Hey David,
I’ve just checked, it’s a 2010 addition:

NEW in 3ds Max 2010: In versions prior to 3ds Max 2010, performing MAXScript garbage collection could cause DotNet event handlers to be deleted too early. With this method, this can be avoided by setting the life time control of the corresponding objects to be handled by DotNet instead of MAXScript.

Cheers.