A short while ago, we had a question about using the .NET API to capture mouse clicks to gather points from the viewport. There was some confusion around it because there were some similarly named interfaces that made it appear that if implemented, they could help. Additionally, because we clearly state in the documentation that you should not derive full plug-ins from the base classes in Autodesk.Max.Plugins namespace, and so those classes are often ignored. While this warning is true for a full plug-in type, it turns out some of those supporting classes are still viable and useful to implement.
This is the case for capturing viewport input. After discussing this with our engineering team, I learned the basic steps are:
- Derive a new class from Autodesk.Max.Plugins.MouseCallBack.
- Override the proc method of this class. This is where the mouse clicks and all info will be diverted.
- Derive a new class from Autodesk.Max.Plugins.CommandMode
- Implement all of the abstract methods. Implement the MouseProc method to return a new instance of your Autodesk.Max.Plugins.MouseCallBack derived class (step # 1)
- Use GlobalInterface.Instance.COREInterface.PushCommandMode with new instance of your Autodesk.Max.Plugins.CommandMode derived class (step #3)
I have implemented a simple example of this approach and attached the project here. Currently it is setup to use 3ds Max Design 2014 like the previous samples, but can easily be converted to work with 3ds Max. See this post for how: Some .NET API Samples