Call for Submission
NAB 2012 Best of the Best Show Reel
Submit your work today!
Theme color:
  • 1/3
You are here: Homepage /  Blogs /  3D SDK and Scripting Mayhem / .NET Features in 2010
.NET Features in 2010
Posted: Apr 08, 2009
Category:
Social Media:
Bookmark and Share
 
The 3ds Max SDK has shipped since 3ds Max 9 with a number of .NET assemblies which can be useful when writing plug-ins with C++/CIL (previously known as Managed C++). These assemblies are also useful when writing .NET assemblies which are called from MAXScript.
One of the most useful thing that the .NET assemblies do, which they have for the last couple of releases, is allow you to write modeless dialog boxes and textbox controls that handle keyboard events correctly. If you have ever tried writing a .NET control for use with 3ds Max you may find that a keypress event is mapped to shortcut keys in 3ds Max. To fix this you can derive your .NET forms from MaxCustomControls.MaxForm, and use the MaxCustomControls.MaxTextControl in place of the default windows control.

In 2010 IMHO the most interesting new addditions to the .NET assemblies include the following:

  • ManagedServices.MaxscriptSDK - allows users to evaluate MAXScript expressions, and execute MAXScript statements

  • ManagedServices.PathSDK - provides convenience functions for retrieving the 3ds Max default directories

  • MaxNotificationListener - This class allows a developer to handle broadcast notification message

A side project which I hope to post sometime soon (I am just working out the details of licensing code posted to this blog with our legal departement) is a MAXScript script manager tool written entirely in C#. This demonstrates the use of the new PathSDK and MAXScriptSDK classes, along with the usage of MaxForm and MaxTextControl.
In order to post any comments, you must be logged in!
Newest users comments View All 10 Comments
Posted by Yannick Puech on Jun 22, 2009 at 12:37 PM
Hi,

I have a question like Pete about a dll that ship with 3ds Max.
There's a DevExpress.XtraTreeList.v7.1.dll that contains a very interesting and powerful TreeList control. I'm sure it's used by ExplorerControl for example.
I have been able to create and use it in MAXScript but not in C#. I had a popup window saying that I was using a trial version after dropping it in the designer window of Visual Studio.

Is it possible to use the control in C# ? If yes, how ?
Is the TreeList control only registered for use by SceneExplorer, MaterialExplorer etc ? Is it normal that I was able to use it in MAXScript ?
Posted by LoneRobot on May 19, 2009 at 08:46 PM
thanks, that is exactly the info i needed. Chris's post got me investigating the new classes so it just cropped up from there. I will look into the color method and see if i can get it working in a dotnet assembly.
Posted by David Cunningham on May 19, 2009 at 08:31 PM
Regarding your .NET Questions.

First off, a disclaimer - if a class doesn't have specific documentation (in this class, it's excluded) then we don't officially support its usage.

That said, those classes are public (because they need to be used across Assembly boundaries) and we can't really prevent anyone from at least trying. :)

MaxSpinner is a wrapper class that takes the Spinner custom control that we expose in Win32 and provides a managed interface so that it can be used in an interop solution. This means that we take care of instantiating the class, but the client would need to grab the handle, using MaxNativeControl::HostWindowHandle, and embedd it in an interop solution (such as System.Windows.Interop.HwndHost in WPF.)

I'm not sure what you mean by "debugging in VS". The easiest way to debug is to load max with the Debugger set to Mixed (not Auto). See the Project Properties -> Debugging panel in VS.

ExecuteColorMaxscriptQuery - returns a COLORREF struct (Win32 struct). You can create a System::Windows::Media::Color from this using the static method exposed on this class FromRGB. GDI exposes some handy converstion methods to get the channels:

GetRValue(DWORD)
GetGValue(DWORD)
GetBValue(DWORD)

Just cast the COLORREF to a DWORD, pass them to these methods, as parameters to FromRGB, and presto. :)

This does not give you access to the Max Colors interface - it simply returns a maxscript that, when executed, would return a color value, as a COLORREF. So any color info that you can access via scripting should be available to your assembly now.

Hope that answers some of your questions.
Posted by Christopher Diggins on May 19, 2009 at 07:50 PM
Hi Lonerobot,

Sorry about the long delay. I have been sick.

>> i've posted a bit of research on my site here - www.lonerobot.com/DotNetSDK2010.html

Thanks for sharing that!

>> I have a few questions - Is there a way of debugging these methods in VS? at the moment i have to load into max each time and test, and it's a slow way of doing things.

I don't know any better way, sorry.

>> Also, the executemaxscriptcolorquery method returns a system.valuetype. do i have to cast this into a color?

I believe so.

>> how to I use this to get a dotnetcolor from max into my assembly?

I don't know. :-(

>> just another question - im seeing a maxspinner class in managed services that i can instantiate but cant use on a rollout or maxform. Is this a replacement for the numericup down that casts a decimal to integer in max? i notice it has a float type property. any info on this would be great as there isnt anything in the dotnet SDK, cheers, Pete

I don't know about this neither.

Sorry I couldn't be of more help.
Posted by LoneRobot on May 14, 2009 at 11:40 PM
just another question - im seeing a maxspinner class in managed services that i can instantiate but cant use on a rollout or maxform. Is this a replacement for the numericup down that casts a decimal to integer in max? i notice it has a float type property. any info on this would be great as there isnt anything in the dotnet SDK, cheers, Pete