示例#1
0
def test_normalize(setup_path):
    # mGear imports
    from mgear.core.string import normalize

    value = "1234-mgear=string@normalize"
    assert normalize(value) == "_1234-mgear_string_normalize"
    assert normalize(value, True) == "_1234_mgear_string_normalize"
示例#2
0
def create_channel_master_node(name):
    """Create a new channel master node

    Args:
        name (str): name of the nodes

    Returns:
        str: name of the channel master node
    """

    # Create data node (render sphere for outliner "icon")
    shp = cmds.createNode("renderSphere")
    cmds.setAttr("{}.radius".format(shp), 0)
    cmds.setAttr("{}.isHistoricallyInteresting".format(shp), 0)
    cmds.setAttr("{}.v".format(shp), 0)

    # Rename data node
    node = cmds.listRelatives(shp, p=True)[0]
    node = cmds.rename(node, string.normalize(name))

    cmds.addAttr(node, ln=__TAG__, at="bool", dv=True)
    cmds.setAttr("{}.{}".format(node, __TAG__), k=False, l=True)
    cmds.addAttr(node, ln="data", dt="string")

    attribute.lockAttribute(pm.PyNode(node))

    # init data
    cmds.setAttr("{}.data".format(node),
                 cmu.init_channel_master_config_data(),
                 type="string")
    return node
示例#3
0
def create_layer(oSel):
    """Create new crank layer for shot sculpting

    Args:
        oSel (Mesh list): Objects to be included in the layer

    Returns:
        dagNode: cranklayer node with all the layer data
    """
    oSel = [x for x in oSel
            if x.getShapes()
            and x.getShapes()[0].type() == 'mesh']

    if oSel:
        result = pm.promptDialog(title='Crank Layer Name',
                                 message='Enter Name:',
                                 button=['OK', 'Cancel'],
                                 defaultButton='OK',
                                 cancelButton='Cancel',
                                 dismissString='Cancel',
                                 text="")

        if result == 'OK':
            text = pm.promptDialog(query=True, text=True)
            name = string.normalize(text)

            layer_node = create_layer_node(name, oSel)
            bs_list = create_blendshape_node(name, oSel)
            for bs in bs_list:
                layer_node.crank_layer_envelope >> bs.envelope
                idx = attribute.get_next_available_index(
                    layer_node.layer_blendshape_node)
                pm.connectAttr(bs.message,
                               layer_node.layer_blendshape_node[idx])
            pm.select(oSel)

            return layer_node