标签:
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 ) loadAutodeskMax ()
1 #define WM_TRIGGER_CALLBACK WM_USER+4764 2 void PostCallback( void (*funcPtr)(UINT_PTR), UINT_PTR param ) 3 { 4 PostMessage( GetAppHWnd(), WM_TRIGGER_CALLBACK, 5 (UINT_PTR)funcPtr, (UINT_PTR)param ); 6 }
1 the_listener->edit_stream->wputs("Hello") 2 the_listener->edit_stream->flush()
1 using IronPython.Hosting; 2 using Microsoft.Scripting.Hosting; 3 public static void RunPythonFile(string filename) { 4 try { 5 var options = new Dictionary<string, object>(); 6 options["Debug"] = true; 7 ScriptEngine se = Python.CreateEngine(options); 8 ScriptSource ss = se.CreateScriptSourceFromFile(filename); 9 CompiledCode cc = ss.Compile(); 10 cc.Execute(); 11 } 12 catch (Exception e){ 13 MessageBox.Show("Error occurred: " + e.Message); 14 } 15 }
1 using ManagedServices; 2 public class My3dsMaxAssembly 3 { 4 public const int StartUpNotification = 0x50; 5 public static void AssemblyMain() 6 { 7 // This causes an event to be raised once the 3ds Max application has been started 8 var m = new MaxNotificationListener(StartUpNotification); 9 m.NotificationRaised += new EventHandler<MaxNotificationEventArgs>(AfterStartup); 10 } 11 public static void AfterStartup(object sender, MaxNotificationEventArgs e) { 12 if (e.NotificationCode == StartUpNotification) { 13 // Do whatever 14 } 15 } 16 }
Special thanks to Michaelson Britt, Stephen Taylor, and David Cunningham for several of theses cool tips. Please share in the comments your favorite undocumented or frequently overlooked tips and tricks for using the 3ds Max SDK!
25 things you probably didn't know about the 3ds Max SDK
标签:
原文地址:http://www.cnblogs.com/sunlery/p/5772660.html