Skip to content

Fix disconnect/connect with Undo#46

Merged
mottosso merged 5 commits intomasterfrom
fix45
Dec 6, 2020
Merged

Fix disconnect/connect with Undo#46
mottosso merged 5 commits intomasterfrom
fix45

Conversation

@mottosso
Copy link
Owner

@mottosso mottosso commented Dec 5, 2020

This fixes #45

I've also moved the MYPY statement to below the import statements to make linters happy; but I wonder whether this breaks things for you @benblo?

@mottosso
Copy link
Owner Author

mottosso commented Dec 5, 2020

This is still somewhat fragile; the user can still..

mod.disconnect(a, b)

Which would try and disconnect both source and destination connections to both a and b, even if no connections exists. If that's the case, Maya will happily carry on. Until you undo, which is when it'll tell you "hey, something you did at some point in the past was wrong, so now I will throw an exception. Happy hunting."

We can address this by testing that an attribute is actually connected before attempting to disconnect it.. but that's somewhat of a rabbit hole. As what really matters is what is connected upon calling doIt. A connection could not exist when calling disconnect but then later be made, which would invalidate whatever check we perform during the call to disconnect.

So I'm leaving that as-is for now. Hasn't been a problem so far.

@mottosso
Copy link
Owner Author

mottosso commented Dec 5, 2020

Took another crack at this, and oh man.

tm = cmdx.createNode("transform")
tm["tx"] << tm["ty"]

with cmdx.DagModifier() as mod:
  mod.disconnect(tm["ty"], tm["tx"])

# OK

Except, it's not OK. Maya cares deeply about the order in which you specift the disconnect. Here, it'll try and disconnect tx from ty, except tx is not connected to ty. It's the other way around. So guess what happens? Nothing, ignored. And guess what happens on redo? ty gets a connection to tx. xDDD Lol. That's bad.

@mottosso mottosso merged commit 2781089 into master Dec 6, 2020
@mottosso mottosso deleted the fix45 branch January 22, 2022 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DGModifier.disconnect and Undo

1 participant