ArticleDirectory
- 25 things you probably didn't know about the 3DS MAX SDK
Http://area.autodesk.com/blogs/chris/25-things-you-probably-didn039t-know-about-the-3ds-max-sdk
25 things you probably didn't know about the 3DS MAX SDK
I 've adventured deep into the darkest corners of the 3DS MAX SDK to bring you a set of largely unknown but useful tips and tricks.
Use the 3DS max sdk from maxscript by loading the Autodesk. Max. dll. Add the following maxscript to your start-up scripts and you can use the maxglobal variable to access the 3DS max sdk.
FN loadautodeskmax = (local assembly = dotnetclass "system. reflection. assembly "Local maxroot = pathconfig. getdir # maxroot assembly. loadFile (maxroot + "\ Autodesk. max. DLL ") Local globalinterface = dotnetclass" Autodesk. max. globalinterface "Global maxglobal = globalinterface. instance) loadautoscaling max ()
-
- Execute Arbitrary maxscript code using the executemaxscriptscript () global function (see the maxscriptmaxscript. h header ).
- Execute Code safely in the main thread in 3DS MAX by either creating a Windows timer object using the main 3DS MAX window as the window handle, or by using the following function to trigger code as soon as 3DS MAX is idle next.
# Define wm_trigger_callback wm_user + 4764 void postcallback (void (* funcptr) (uint_ptr), uint_ptr PARAM) {postmessage (getapphwnd (), wm_trigger_callback,
(Uint_ptr) funcptr, (uint_ptr) PARAM );}
-
- Work with different types of meshes (mesh, mnmesh and patchmesh) using theobjectwrapper class. This can simplify writing plug-in that have to deal with Arbitrary Mesh types such as modifiers.
-
- Collect comprehensions about all nodes in the scene in an efficient way using theisceneeventmanager class. It's ideal to use for UI refresh, when you need to monitor the scene for events to trigger a refresh.
- Output text to the 3DS MAX maxscript listener window (see the maxscriptmaxscript. h header) as follows:
The_listener-> edit_stream-> wputs ("hello") the_listener-> edit_stream-> flush ()
-
- Execute a Python script from A. Net assembly with a few lines of code after downloading and installing ironpython
Using ironpython. hosting; using Microsoft. scripting. hosting; public static void runpythonfile (string filename) {try {var Options = new dictionary <string, Object> (); options ["debug"] = true; scriptengine Se = python. createengine (options); scriptsource Ss = Se. createscriptsourcefromfile (filename); compiledcode cc = ss. compile (); CC. execute ();} catch (exception e) {MessageBox. show ("error occurred:" + E. message );}}
-
- Extend 3DS MAX with new drag and drop functionality by deriving from thedraganddrophandler class.
- Download a file from an arbitrary URL to disk using: idraganddropmgr: downloadurltodisk ().
-
- Compress data using the zlip compression library. Check out the zlibdll. h header file in the 3DS max sdk.
-
- Log messages to the 3DS MAX log file and even print out messages to Visual Studio console using logsys class.
-
- Evaluate mathematical expressions stored as strings using the expr class.
-
- Generate repeatable sequences of random numbers using the random class.
-
- Store objects in one of the following container template types:
- Stack
- Shortlist
- Array
- Tab
-
- Read and Write Unicode files easily and correctly using the filereaderwriter class.
-
- Compute the time it takes to complete a task using the Timer class.
- Automatically delete objects when you are done with them using the autoptrtemplate.
-
- Output unobtrusive status messages to the user using the interface: pushprompt () function.
-
- Retrieve the user define UI colors using icolormanager.
-
- Launch a web browser using ibrowsermgr.
-
- Retrieve. Max file Properties Using interface11: openmaxstoragefile ().
-
- Format a time value as a string using interface10: formatrendertime ()
-
- Open the Windows Explorer using interface8: revealinexplorer ().
-
- Perform a quick render to A Bitmap Using interface8: quickrender ()
- Execute Code when 3DS MAX is fully initialized in C #:
Using managedservices; public class my3dsmaxassembly {public const int startupnotification = 0x50; public static void assemblymain () {// This causes an event to be raised once the 3DS MAX application has been started var M = new maxnotificationlistener (startupnotification); M. notificationraised + = new eventhandler <maxnotifeventargs> (afterstartup);} public static void afterstartup (Object sender, maxicationeventargs e) {If (E. notificationcode = startupnotification) {// do whatever }}}
Special thanks to Michaelson Britt, Stephen Taylor, and David cunnheim for several of theses cool tips. Please share in the comments your unordered ented or frequently overlooked tips and tricks for using the 3DS max sdk!