blurstudio / Simplex

The Simplex Blendshape UI from Blur Studio
GNU Lesser General Public License v3.0
120 stars 41 forks source link

[Bug]: simplexDelete attr already has an incoming connection #136

Closed cemccabe77 closed 1 month ago

cemccabe77 commented 3 months ago

Summary

When using 'Connect From Scene Selection', _reparentDeltaShapes() tries to connect the message attr to the simplexDelete attr on the parent transform node. This connection already exists and throws a RuntimeError that kills the process.

# Traceback (most recent call last):
#   File "D:\Working\dev\git\simplex\simplexPy3\scripts\simplexui\simplexDialog.py", line 846, in shapeConnectScene
#     c.connectShape(pair.shape, delete=True)
#   File "D:\Working\dev\git\simplex\simplexPy3\scripts\simplexui\items\combo.py", line 686, in connectShape
#     self.DCC.connectComboShape(self, shape, mesh, live, delete)
#   File "D:\Working\dev\git\simplex\simplexPy3\scripts\simplexui\interface\mayaInterface.py", line 115, in stacker
#     return f(*args, **kwargs)
#   File "D:\Working\dev\git\simplex\simplexPy3\scripts\simplexui\interface\mayaInterface.py", line 2517, in connectComboShape
#     delta = self._createComboDelta(combo, mesh, tVal)
#   File "D:\Working\dev\git\simplex\simplexPy3\scripts\simplexui\interface\mayaInterface.py", line 2442, in _createComboDelta
#     repDict = self._reparentDeltaShapes(target, nodeDict, bs, [rest, base])
#   File "D:\Working\dev\git\simplex\simplexPy3\scripts\simplexui\interface\mayaInterface.py", line 2196, in _reparentDeltaShapes
#     cmds.connectAttr(bsNode + ".message", sdNode)
# RuntimeError: 'jawOpen_mouthCornerPull_X_Extract.simplexDelete' already has an incoming connection from 'jawOpen_mouthCornerPull_X_DeltaBS.message'.

Expected Behavior

Check to see if the connection already exists before trying to make the connection.

Steps to Reproduce Behavior

Extract Shape from simplexUI. Connect from Scene Selection from simplexUI

Solution

To resolve, I check to see if the connection exists on line 2196 in mayaInterface.py

Going from this:

# Use the simplexDelete message attribute to keep track of what nodes
# will need to be delete-linked when the file is reopened
sdNode = par + ".simplexDelete"
if not cmds.ls(sdNode):
    cmds.addAttr(par, longName="simplexDelete", attributeType="message")
cmds.connectAttr(bsNode + ".message", sdNode)

To this:

# Use the simplexDelete message attribute to keep track of what nodes
# will need to be delete-linked when the file is reopened
sdNode = par + ".simplexDelete"
if not cmds.ls(sdNode):
    cmds.addAttr(par, longName="simplexDelete", attributeType="message")
if cmds.listConnections(sdNode, s=True, p=True) == None:
    cmds.connectAttr(bsNode + ".message", sdNode)

Environment

SimplexUI: 3.0 OS: Windows 10 Python: 3.7.7

Additional Context

I have used this solution in previous versions. I recently upgraded Simplex to the latest version, and had to apply the fix again. I thought I would report the issue. Please let me know if there is a better solution.

tbttfox commented 2 months ago

You've got a solution, Make a PR

tbttfox commented 1 month ago

Closed by https://github.com/blurstudio/Simplex/pull/142