Custom duplicate or post duplicate

Custom duplicate or post duplicate

Sebastian_Wiendl
Enthusiast Enthusiast
867 Views
4 Replies
Message 1 of 5

Custom duplicate or post duplicate

Sebastian_Wiendl
Enthusiast
Enthusiast

Hi all,

 

I am having an issue with the duplicate functionality.

Basically, when certain of my custom nodes are created, they need to be connected to others in a special way that cannot be done via the default duplicate or duplicate special, i.e. if I just duplicate a node, the result is bad because the connections to other nodes are all wrong.

This is why I was wondering if there was a way to override a node's duplicate in c++, or have a post duplicate function.

I tried accessing the node's plugs from c++ in MDGMessage::addNodeAddedCallback and also via the postConstructor function, but it seems that at that stage none of the (wrong) connections have been made yet.

 

Any help would be much appreciated.

 

Cheers,

Sebastian

 

0 Likes
Accepted solutions (1)
868 Views
4 Replies
Replies (4)
Message 3 of 5

Sebastian_Wiendl
Enthusiast
Enthusiast

Hi olarn,

 

Thanks so much for your response.

The issue with this api is that I can't tell what triggered it.

I have scripts, etc that create new nodes and hook them up properly and they would trigger the callbacks as well; not just the duplicate.

In theory, it should be possible to use the api you sent, but it would mean a lot of rework of how I do things currently.

I really would like to avoid that.

 

Cheers,

Sebastian

 

Cheers,

Sebastian

0 Likes
Message 4 of 5

olarn
Advocate
Advocate
Accepted solution

 

 

if I just duplicate a node, the result is bad because the connections to other nodes are all wrong.

This is why I was wondering if there was a way to override a node's duplicate

 

http://help.autodesk.com/cloudhelp/2018/ENU/Maya-SDK/cpp_ref/class_m_px_node.html?_ga=2.110884805.11...

 

You should return kUnknownParameter to specify that maya should handle this connection or if you want maya to process the connection as well.

 

I think simply overriding and then returning anything other than kUnknownParameter will probably stop maya from auto connecting everything in default duplicate. This should give your full control

 

Also all commands in maya are synchronous so in theory you can keep stack of history somewhere static and then pop it when that api gets called and that should tell where it's coming from

 

0 Likes
Message 5 of 5

Sebastian_Wiendl
Enthusiast
Enthusiast

Hi olarn,

 

Thanks so much for getting back to me again.

I will experiement some more.

Your answer is the best possible solution I could find.

Much appreciated.

 

Cheers,

Sebastian