Custom Node AttributeChanged callback not firing when connected

What is the proper way to add a callback on attribute changed on a custom node where I made the attribute connectable? I have a simple integer attribute on a transform that I connect to my custom node. When I change the attribute on the connected transform the callback does not fire. When I change it in the attribute editor manually on the node itself, it does fire. What is the right way to do this?

I still haven’t found an answer, but if I use scriptJob with attributeChange flag then it works… not sure why it doesn’t work when using MNodeMessage::addAttributeChangedCallback

Well now I have found this: Maya Callback Node Example Tutorial

It seems to suggest I should add the callback to the normal Maya node’s attribute that I have connected to my custom node’s attribute, instead of to the attribute on my custom node directly… I guess I can do that if this is the right way. I am kind of confused if this goes against the design philosophy of Maya’s internals. I am a noob when it comes to the OpenMaya API so I have no idea if I went about this the right way to solve my problem.

Basically I created a node that creates instances of a shape. You connect an input shape and it has an attribute on it called instanceCount which creates however many instances you set it to. For example, set it to 25 and it creates 25 instances. The update occurs via a callback on the instanceCount attribute. I do not need this attribute to be keyable but I would like it to be “live”, hence the callback.

It is similar to this plug-in, which is where I got the idea from. GitHub - mmerchante/instanceAlongCurve: Maya API Node for interactive instancing of shapes along curves.</

I want to connect a control on my rig to my custom node’s attribute so it can be controlled by an animator. But the attribute callback doesn’t fire when I drive it through a connection on the rig, only if I manually adjust it on the node itself

Hmm another update now, if I change it addNodeDirtyPlugCallback to my custom attribute on my custom node instead, it fires the callback when I change the value on the connected rig control. So I suppose I could do that, but something about it feels wrong. It also fires much more often because I think the plug is getting set to dirty all the time anything changes with any attribute on the rig control.

I also prefer not to do what I mentioned in the above post and set a callback on the rig control attribute instead. That will also fire quite often no matter which attribute is changing on the control. I’d rather have it on my own node but driven by a connection so that it fires the least amount of times