예제 #1
0
def createAnnotation(rootObj, endObj, text=None, name=None):
    name = name or "annotation"
    rootDag = om2.MFnDagNode(rootObj)
    boundingBox = rootDag.boundingBox
    center = om2.MVector(boundingBox.center)
    transform = nodes.createDagNode("_".join([name, "loc"]),
                                    "transform",
                                    parent=rootObj)
    nodes.setTranslation(transform,
                         nodes.getTranslation(rootObj, om2.MSpace.kWorld),
                         om2.MSpace.kWorld)
    annotationNode = nodes.asMObject(
        cmds.annotate(nodes.nameFromMObject(transform), tx=text))
    annParent = nodes.getParent(annotationNode)
    nodes.rename(annParent, name)
    plugs.setPlugValue(
        om2.MFnDagNode(annotationNode).findPlug("position", False), center)
    nodes.setParent(annParent, endObj, False)
    return annotationNode, transform
예제 #2
0
def convertToNode(node, parent, prefix, nodeType="joint"):
    """Converts a node into a joint but does not delete the node ,
    transfers matrix over as well

    :param node: mobject, the node that will be converted
    :param parent: mobject to the transform to parent to
    :param prefix: str, the str value to give to the start of the node name
    :param nodeType: str, the node type to convert to. must be a dag type node
    :return: mObject, the mobject of the joint
    """
    mod = om2.DagModifier("createJoint")
    jnt = mod.createNode(nodeType)
    mod.doIt()
    nodes.rename(jnt, prefix + nodes.nameFromMObject(node, partialName=True))
    nodes.setParent(jnt, parent)
    plugs.setPlugValue(
        om2.MFnDagNode(jnt).findPlug("worldMatrix", False),
        nodes.getWorldMatrix(node))

    return jnt
예제 #3
0
def createAnnotation(rootObj, endObj, text=None, name=None):
    newparent = nodes.createDagNode("_".join([name, "ann_hrc"]), "transform")
    name = name or "annotation"
    locator = nodes.createDagNode("_".join([name, "loc"]), "locator",
                                  newparent)

    annotationNode = nodes.asMObject(
        cmds.annotate(nodes.nameFromMObject(locator), tx=text))
    annParent = nodes.getParent(annotationNode)
    nodes.rename(annParent, name)
    nodes.setParent(annParent, newparent, False)
    extras = [newparent]
    constraint = constraints.MatrixConstraint(
        name="_".join([name, "startMtx"]))

    extras.extend(
        constraint.create(endObj, locator, (True, True, True),
                          (True, True, True), (True, True, True)))
    extras.extend(
        constraint.create(rootObj, annParent, (True, True, True),
                          (True, True, True), (True, True, True)))

    return annParent, locator, extras
예제 #4
0
 def rename(self, name):
     nodes.rename(self.node.object(), name)