I find myself put in a position where my higher-ups really, really want me to move as much of my MaxScript as possible into DotNet. (Yes, I’ve had the discussion that I can do a lot of this stuff faster in MaxScript, but it didn’t fly so well.) I’m using Max 2013, and there’s a bunch of things I’ve found that the DotNet wrapper just doesn’t handle; iterating over scene nodes and animatables using the build in functions is one of those.
I’m just trying to see if anyone knows how I might be able to get all the current instances of a class using DotNet(C#) and the Max 2013 SDK.
I’ve been clobbering my head against this problem for too long, and I’m about ready to try literally clobbering my head against a brick wall until I end up either too brain-damaged to care or at least unconscious long enough that, when I wake up, the world will just be a better place.
We’ve been doing a bunch of stuff with dotnet internally (2013 x64, product update 5+).
And while personally I would rather suffer the abysmal dotnet wrapper Autodesk made, you’re most probably right in your assumption that doing things in maxscript will be “faster” if you have no knowledge of the C++ API. However doing things in maxscript comes with its can of worms as well (mostly about language awkward design and quite serious limitations).
Consider using dotnet as you would using the c++ sdk, many things needs to be done the same way actually since Autodek didn’t bother to clean their internal API much and this dotnet sdk is just a conversion from the c++ sdk. So expect to need much much more verbose code as you would need for the equivalent maxscript command. Also, be aware that many things were never ported to the dotnet api (mostly because of c++ pointer issues from what I understood).
I don’t believe things have changed massively in 2015 on the dotnet front, but hey, at least you have a new half finished python API to use now.
As for your question, you’ll need to iterate all scene nodes and yourself match their ClassID to the one(s) you’re looking for. Be mindful that you may also have to navigate the stack modifiers list as you would get a different ClassID from the base object ClassID and all that stuff depending what you’re looking for.
All in all, you need to approach this as working with the C++ SDK in order to get familiar with how to navigate the internals, but that will require some time for ramping up with this. A great resource is David Lanier’s forum and his pdf more specifically.