コード例 #1
0
ファイル: guide.py プロジェクト: mgear-dev/mgear4
def create_guide_rig(name,
                     pos,
                     scalp,
                     sections,
                     length,
                     thickness):
    global COLOR
    if pos:
        face = transform.getClosestPolygonFromTransform(
            pm.PyNode(scalp), pos)[0]
        rot = transform.get_orientation_from_polygon(face)

        # section distance
        sd = length / (sections - 1)
        points = []
        x = 0.0
        for s in range(sections):
            p = [x, 0, 0]
            points.append(p)
            x += sd
        # create curve
        crv = curve.addCurve(None, name, points)
        crv.rotate.set(rot)
        crv.translate.set(pos)

        # lock first point in the curve
        curve.lock_first_point(crv)

        # set color and thickness
        curve.set_color(crv, COLOR)
        curve.set_thickness(crv, thickness)

        return crv
コード例 #2
0
ファイル: guide.py プロジェクト: mgear-dev/mgear4
def duplicate(ui, dup_guide=None):
    name = ui.xgen_description_lineEdit.text()
    description = xgen_handler.get_description(name)
    if not description:
        return
    if not dup_guide:
        dup_guide = pm.selected()
    if dup_guide:
        dup_guide = dup_guide[0]
    else:
        pm.displayWarning("Nothing selected to duplicate")
        return

    if dup_guide in xgen_handler.get_connected_curve_guides(description):
        # duplicate
        new_crv = pm.duplicate(dup_guide)[0]

        # config new crv.
        curve.set_thickness(new_crv, ui.thickness_spinBox.value())
        curve.lock_first_point(new_crv)

        xgen_handler.connect_curve_to_xgen_guide(new_crv, description)

        return new_crv

    else:
        pm.displayWarning(
            "Object {0} is not crv guide for {1} and can't be"
            " duplicated".format(dup_guide.name(), name))
コード例 #3
0
ファイル: guide.py プロジェクト: mgear-dev/mgear4
def duplicate_sym(ui, dup_guides=None, skip_all=False, re_sym_all=False):
    name = ui.xgen_description_lineEdit.text()
    description = xgen_handler.get_description(name)
    if not description:
        return
    crv_guides = xgen_handler.get_connected_curve_guides(description)
    new_guides = []
    if not dup_guides:
        dup_guides = pm.selected()
    for crv in dup_guides:
        if crv in crv_guides:
            if not crv.hasAttr("sym_guide"):
                crv.addAttr("sym_guide", at='message', multi=False)
            else:
                sym_cnx = crv.sym_guide.listConnections()
                if sym_cnx:
                    if skip_all:
                        continue
                    if re_sym_all:
                        pm.displayInfo(
                            "Re symmetry guide {}".format(crv.name()))
                        pm.delete(sym_cnx)
                    else:
                        dup_option = show_dup_sym_options(crv.name())
                        if dup_option == 1:  # skip all
                            skip_all = True
                            continue
                        elif dup_option == 2:  # re sym
                            pm.displayInfo(
                                "Re symmetry guide {}".format(crv.name()))
                            pm.delete(sym_cnx)
                        elif dup_option == 3:  # re sym all
                            re_sym_all = True
                            pm.displayInfo(
                                "Re symmetry guide {}".format(crv.name()))
                            pm.delete(sym_cnx)
                        elif dup_option == 4:  # cancel
                            break
                        else:  # skip. Also if close the menu will skip
                            continue

            # duplicate
            new_crv = pm.duplicate(crv)[0]
            # transform
            t = crv.getTransformation()
            t = transform.getSymmetricalTransform(t)
            new_crv.setTransformation(t)
            # create message connection
            pm.connectAttr(new_crv.sym_guide, crv.sym_guide, f=True)
            pm.connectAttr(crv.sym_guide, new_crv.sym_guide, f=True)
            # config new crv.
            curve.set_thickness(new_crv, ui.thickness_spinBox.value())
            curve.lock_first_point(new_crv)
            # connect
            xgen_handler.connect_curve_to_xgen_guide(new_crv, description)
            new_guides.append(new_crv)
        else:
            pm.displayWarning(
                "Object {0} is not crv guide for {1} and can't be"
                " duplicated".format(crv.name(), name))
    if new_guides:
        pm.select(new_guides)
    return new_guides