Callback problems (NotifyPostCollapse & INodeEventCallback)

 
 
 
Posted by:Vincentt
Data created:8 January 2015

Hello,

I’m yet again stuck, I apologize for all the questions I’ve been posting recently, but all of the answers have been very helpful, so I’m trying it again :)

I want to register some callbacks to update my UI accordingly. One of them is a global one I was able to register with the help of the documentation: http://www.ephere.com/autodesk/max/docs/902.html. (SystemNotificationCode.SelNodesPostDelete).

Problem 1:

Now I would like to also have a callback for when the stack of my object(s) is getting collapsed. I found:

void NotifyPostCollapse(IINode node, IObject obj, IIDerivedObject derObj, int index);

in ‘IBaseObject’ however I don’t know how to actually register to it? I thought about inheriting IBaseObject, this didn’t really work because then I’d have to implement all the methods from IBaseObject, I tried to inherit from BaseObject but even then I don’t know what to do with my new class…

 

Problem 2:

I want to register an INodeEvenCallback. I got this so far:

 

var hmm = new NodeEventTest();

m_Global.INodeEventCallback.CreateUnmanagedWrapper(hmm);

   class NodeEventTest : INodeEventCallback

   {

       public override void GeometryChanged(ITab<UIntPtr> nodes)

       {

           DebugMethods.Log("GeomChanged");

 

           base.GeometryChanged(nodes);

       }

 

       public override void LinkChanged(ITab<UIntPtr> nodes)

       {

           DebugMethods.Log("Link Changed");

           base.LinkChanged(nodes);

       }

 

       public override void LayerChanged(ITab<UIntPtr> nodes)

       {

           DebugMethods.Log("Layer Changed");

           base.LayerChanged(nodes);

       }

   }

This doesn’t work though, am I registering it correctly, with CreateUnmanagedWrapper? I’ve also tried .Create() and .InitializeLifetimeService() without luck.

 

Thank you in advance!
Vin

 

Hi Vin,

NotifyPostCollapse should be a method you override in your plugin (Texture/Modifier/GeomObject/etc.). It will be called by Max whenever it collapses your object. You don't "subscribe" to it with a callback, it is something you override.

This is how you register INodeEventCallback:

this.nodeEventCallback = new NodeEventCallback();
this.nodeEventCallbackID = GlobalInterface.Instance.ISceneEventManager.RegisterCallback( this.nodeEventCallback, false, 0, false );

Marsel Khadiyev (Software Developer, EPHERE Inc.)

Hey Marsel,

Thanks for the reply! I have 1 question about the NotifyPostCollapse method. I have this as my base plugin class:

public class basePluginClass : CuiActionCommandAdapter
{
public override string ActionText
{
get { return InternalActionText; }
}

public override string InternalActionText
{
get { return "ExplodeScript"; }
}

public override string Category
{
get { return InternalCategory; }
}

public override string InternalCategory
{
get { return "Vin"; }
}

public override void Execute(object parameter)
{
var global = GlobalInterface.Instance;
var explode = new ExplodeView(global);
}
}

So I don't think I have a "real" plugin. I have a WinForm where I draw all my information on and I use GlobalInterface to get everything. Is it possible then to override NotifyPostCollapse? It sounds like this is not a "global" callback but per Node one.