
























http://area.autodesk.com/blogs/chris/25-things-you-probably-didn039t-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 ) loadAutodeskMax ()
#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 );
}
the_listener->edit_stream->wputs("Hello")
the_listener->edit_stream->flush()
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);
}
}
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<MaxNotificationEventArgs>(AfterStartup);
}
public static void AfterStartup(object sender, MaxNotificationEventArgs e) {
if (e.NotificationCode == StartUpNotification) {
// Do whatever
}
}
}
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!
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。