[Closed] dotNet in 3ds Max
Would it be possible to run a dotNet application inside 3ds Max being able to have 3ds Max exposure from the dotNet application?
I know one can develop it inside 3dsMax with dotNet controls but it’s far more complicated to develop.
Thanks,
Davy
One could make a custom control class in visual studio, then load the assembly in max and go from there. Have a look over at Pete’s (loneRobot.net) site all kinds of stuff he has developed that does exactly that. You can also dissect the outliner tool from Pier Janssen.
Basic workflow:
- Create a empty class in visual studio.
- Add a custom control class
- Build your custom UI and expose/override the methods you need to your custom control, and build the dll
- loadAssembly the dll in max
- In max use a mxs rollout or a dotnet maxform and add the control (either via form.controls.add or dotnetControl “yournamespace.yourcontrol”
- Assign the appropriate eventhandlers
- run the tool!
If you need to have your custom control talk to max via maxscript in visual studio include the ManagedServices.dll in your visual studio project and use the “ManagedServices.MaxscriptSDK” class and the accompanying maxscript methods.
Hope it’s a start,
-Johan
Sounds like a possibility. What would be most interesting is that one can develop completely in Visual Studio instead of 3ds Max.
I’ll investigate to see how this could work.
Thanks a lot,
Davy
You can, as I outlined, but event handling will always need to be assigned in a maxscript.
-Johan
Ello Johan, Davy,
I’m always finding my feet with this myself, but developing an assembly that talks to max entirely in visual studio is definatley a possibility. All of my custom controls and animation systems are set up this way. It came about from needing to be able to deploy tools as quickly as possible, but also because VS is a solid programming environment. Most of my controls have the maxscript calls build in to the control’s logic and just need a tiny rollout/dotnetobject script at max’s end. My RigStudio system is a good example of this, all code is handled entirely within dotnet, including passing layer names and node names from max.
This obviously depends on how complicated the code you want the dotnetcontrol to run, and whether you want it to be passed back into the dotnet object after it had done what it wants. You are limited to strings, floats, integers but you can usually get the interchange of information you want without too much trouble.
I have many examples of how to do this on my tech site. You can also define an MXS fucntion as a string and pass that as a maxscript command on the instantiation of the control. This means you can register more complicated functions and then hardwire the event handlers to that function call. Hitchhiker (on my site) uses this technique extensively. This means you don’t have to add extra startup scripts in max, or eregister the event handlers in MXS – you can set it all up via the assembly.
One thing i have not figured out is being able to test projects that have the managedservices dll referenced. I was told that you need to set the VS debugger to ‘mixed mode’ but haven’t figured out how to do that. It would make testing these types of assemblies easier to debug. I assume managed services needs to be run inside of 3dsmax, but am not sure exactly what it’s doing. perhaps one of the dotnet geeks can shed some light on that.
Pete, if I get it right the maxscript function is also declared in the dotnet assembly as a string and you execute it and grab/get back the result in a appropriate type?
Have you looked at dotNetMxsValue for use in the custom control, to store max object values etc?
Do eventhandlers declared in the dotnet control also suffer the garbage collection (setlifetime) problem?
On a somewhat related note, i’ve been willing to make some dotnet control/assembly that listens to a port to execute mxs commands. You remember Rezn8 com tool to send mxs commands from external editors to max via com? This should be totally possible with dotnet in my shortsighted view… what do you think?
Funnily when you go down this road, the world of idea’s open up on making tools etc. it becomes important to only follow up on good ideas
-Johan
hi johan
yes, that’s right, I normally declare the function on instantiation. If you’re worried about globals hanging around you can always set the function varialbe to undefined on close. managedservices dll has a variety of calls – executemaxscriptcommand can execute a string, and a variety of float/string/integer queries that allow a basic return type from max into the assembly.
Have you looked at dotNetMxsValue for use in the custom control, to store max object values etc?
from what i could see, this is a MXS helper class. It’s not something that dotnet can read, it just preserves the data for max so you can store nodes etc in a tag or something. So in terms of a custom control you cant really do anything except trigger the storage of some maxscript data, which is then handled by a maxscript function. It’s not like you can make a dotNetMxsValue object in an assembly, or am I missing something in the dotnet SDK?
Do eventhandlers declared in the dotnet control also suffer the garbage collection (setlifetime) problem?
they do not, which is what started all this for me i the first place. it was the only way of geting around max 2008’s over zealous spring cleaning.
On a somewhat related note, i’ve been willing to make some dotnet control/assembly that listens to a port to execute mxs commands. You remember Rezn8 com tool to send mxs commands from external editors to max via com? This should be totally possible with dotnet in my shortsighted view… what do you think?
Funnily when you go down this road, the world of idea’s open up on making tools etc. it becomes important to only follow up on good ideas
what a great idea. I remember that com interface.
Hello Pete, looks all interesting. My application would run entirely on it’s own. And for some events I want to execute a simple command in 3ds Max. Or get some info from 3ds Max objects.
Johan, that is what I had in mind, some sort of communication. Simple in design but opens up lots of options to develop in Visual Studio.
Davy
Nice topic, I’m trying to archive exactly that, I will share anything that I find here also.
The port com interface is exactly how Deadline communicates executing py & MXS code in 3dsMax for network rendering/processing. Its rock solid and I have developed a few applications based on this principle
You can download an eval of Deadline and take a peek @ http://www.thinkboxsoftware.com/deadline-downloads/
Hi Mike,
What I remember about the COM interface is that you have to register it to the registry, and it will only work on 1 version of max at the same time. A advantage of a socket server would be that there’s no need to register the com port and you could connect to different ports. But that’s only in theorie
-Johan