-
Notifications
You must be signed in to change notification settings - Fork 129
Maya: Maintain time connections on Alembic update. #4143
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,7 +217,7 @@ def update(self, container, representation): | |
|
||
# Need to save alembic settings and reapply, cause referencing resets | ||
# them to incoming data. | ||
alembic_attrs = ["speed", "offset", "cycleType"] | ||
alembic_attrs = ["speed", "offset", "cycleType", "time"] | ||
alembic_data = {} | ||
if representation["name"] == "abc": | ||
alembic_nodes = cmds.ls( | ||
|
@@ -226,7 +226,15 @@ def update(self, container, representation): | |
if alembic_nodes: | ||
for attr in alembic_attrs: | ||
node_attr = "{}.{}".format(alembic_nodes[0], attr) | ||
alembic_data[attr] = cmds.getAttr(node_attr) | ||
inputs = cmds.listConnections( | ||
node_attr, plugs=True, destination=False | ||
) | ||
data = { | ||
"input": None if inputs is None else inputs[0], | ||
"value": cmds.getAttr(node_attr) | ||
} | ||
|
||
alembic_data[attr] = data | ||
else: | ||
self.log.debug("No alembic nodes found in {}".format(members)) | ||
|
||
|
@@ -263,8 +271,19 @@ def update(self, container, representation): | |
"{}:*".format(namespace), type="AlembicNode" | ||
) | ||
if alembic_nodes: | ||
for attr, value in alembic_data.items(): | ||
cmds.setAttr("{}.{}".format(alembic_nodes[0], attr), value) | ||
for attr, data in alembic_data.items(): | ||
node_attr = "{}.{}".format(alembic_nodes[0], attr) | ||
if data["input"]: | ||
cmds.connectAttr( | ||
data["input"], node_attr, force=True | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this make sure that the connection to be made doesn't already exist? (is a warning issues when e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note from testing side...it didnt reconnect There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Thank you - so did it just always result in an unconnected attribute, even if you previously had it connected? :) |
||
else: | ||
inputs = cmds.listConnections( | ||
node_attr, plugs=True, destination=False | ||
) | ||
if inputs: | ||
cmds.disconnectAttr(inputs[0], node_attr) | ||
cmds.setAttr(node_attr, data["value"]) | ||
|
||
# Fix PLN-40 for older containers created with Avalon that had the | ||
# `.verticesOnlySet` set to True. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel the code would be more readable if we'd move this to a simple separate function:
The code here could then just be:
And further down would just be:
Anyway, just feels more readable to only me maybe.