@Krzym
All the joints connection and many other parts are using this kind of connections in mGear. Is kind of the default way to go in mGear
Here is one function from rigbits for reference
def addJnt(obj=False,
parent=False,
noReplace=False,
grp=None,
jntName=None,
*args):
"""Create one joint for each selected object.
Args:
obj (bool or dagNode, optional): The object to drive the new
joint. If False will use the current selection.
parent (bool or dagNode, optional): The parent for the joint.
If False will try to parent to jnt_org. If jnt_org doesn't
exist will parent the joint under the obj
noReplace (bool, optional): If True will add the extension
"_jnt" to the new joint name
grp (pyNode or None, optional): The set to add the new joint.
If none will use "rig_deformers_grp"
*args: Maya's dummy
Returns:
pyNode: The New created joint.
"""
if not obj:
oSel = pm.selected()
else:
oSel = [obj]
for obj in oSel:
if not parent:
try:
oParent = pm.PyNode("jnt_org")
except TypeError:
oParent = obj
else:
oParent = parent
if not jntName:
if noReplace:
jntName = "_".join(obj.name().split("_")) + "_jnt"
else:
jntName = "_".join(obj.name().split("_")[:-1]) + "_jnt"
jnt = pm.createNode("joint", n=jntName)
if grp:
grp.add(jnt)
else:
try:
defSet = pm.PyNode("rig_deformers_grp")
pm.sets(defSet, add=jnt)
except TypeError:
pm.sets(n="rig_deformers_grp")
defSet = pm.PyNode("rig_deformers_grp")
pm.sets(defSet, add=jnt)
oParent.addChild(jnt)
jnt.setAttr("jointOrient", 0, 0, 0)
try:
mulmat_node = node.createMultMatrixNode(
obj + ".worldMatrix", jnt + ".parentInverseMatrix")
dm_node = node.createDecomposeMatrixNode(
mulmat_node + ".matrixSum")
pm.connectAttr(dm_node + ".outputTranslate", jnt + ".t")
pm.connectAttr(dm_node + ".outputRotate", jnt + ".r")
pm.connectAttr(dm_node + ".outputScale", jnt + ".s")
except RuntimeError:
for axis in ["tx", "ty", "tz", "rx", "ry", "rz"]:
jnt.attr(axis).set(0.0)
return jnt