This section contains a set of useful tips and tricks for working with the 3ds Max SDK.
IParamBlock2* GetParamBlock(ReferenceMaker* obj) { intnRefs = obj->NumRefs(); for ( int i = 0; i < nRefs; ++i ) { ReferenceTarget* ref = obj->GetReference(j); if ( ref && ref->SuperClassID() == PARAMETER_BLOCK2_CLASS_ID ) { returndynamic_cast<IParamBlock2*>( ref ); } } returnNULL; }
#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 ); }
In .NET, the System.Windows.Dispatcher class can be used to achieve the same effect. See MSDN ( ) for more information about this class.
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 } } }