MPlug: Can not get a non-networked version of a networked plug
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm currently developing a plugin with the C++ API for Maya 2019 on Windows 10, where I have to rearrange connections on an array attribute.
Therefore I have to list all connections already exist, disconnect them, sort the list and connect them in a new order.
For each array element plug I query the input plug by calling its "MPlug::source()" function, getting a networked plug. I store this input plug via "MPlug::operator=" into a member variable, expecting to get, like the documentation says, a non-networked version of the input plug.
But, when calling the "MPlug::isNetworked()" function for the member variable, it returns "true", telling me it's still a networked plug. And after disconnecting the input plug from the array element plug, the member variable plug is corrupted. Trying to use it for later connection fails or ends up in a fatal error.
So, why do I not get a non-networked plug from the "MPlug::operator=" function, although the documentation implies it. Or is there another way to achieve it? Maybe by using the copy constructor?
Here a little example, showing in rough steps, what I'm trying to achieve and where it fails.
MDGModifier dgMod;
MPlug sourcePlug;// variable for storing the non-networked input plug
if (destinationPlug.isDestination()):
sourcePlug = destinationPlug.source();// Getting the input plug
if (!sourcePlug.isNull()) {
dgMod.disconnect(destinationPlug.source(), destinationPlug);
dgMod.doIt();// works fine and disconnects
dgMod.connect(sourcePlug, destinationPlug);// eventually throws a memory leak exception
dgMod.doIt();// returns MStatus::kFailure
}
Thanks in advance for any suggestions.