コード例 #1
0
def move_guide_rig(ui, crv_guide=None, context=_MOVE_GUIDE_CTX):
    global SCALP
    global DESCRIPTION
    global CRV_GUIDE
    global CRV_GUIDES_LIST

    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)

    if not crv_guide:
        crv_guide = pm.selected()
    if crv_guide:
        crv_guide = crv_guide[0]
    if crv_guide not in crv_guides:
        return

    CRV_GUIDE = crv_guide

    # diconnect curve
    xgen_handler.disconnect_curve_from_xgen_guide(crv_guide)

    # list the curve guides after diconnecting the one that we are moving
    CRV_GUIDES_LIST = xgen_handler.get_connected_curve_guides(DESCRIPTION)

    mpx, mpy, _ = cmds.draggerContext(context, query=True, anchorPoint=True)

    pos = transform.get_raycast_translation_from_mouse_click(
        SCALP.name(), mpx, mpy)
    # if the raycast dont intersect with the scalp don't continue calculation
    if pos:
        refresh_guide_rig_from_ui(pos, ui)
コード例 #2
0
ファイル: guide.py プロジェクト: mgear-dev/mgear4
def create_guide_rig_from_ui(pos, ui):
    global SCALP
    global CRV_GUIDE
    global DESCRIPTION
    global CRV_GUIDES_LIST

    # get the date from the ui

    name = ui.xgen_description_lineEdit.text()
    indx = 0  # need to get the guide index based on the name of the area
    full_name = name.replace("_Shape", "") + "_crvGuide_" + str(indx)
    sections = ui.sections_spinBox.value()
    length = ui.length_doubleSpinBox.value()
    thickness = ui.thickness_spinBox.value()

    CRV_GUIDES_LIST = xgen_handler.get_connected_curve_guides(DESCRIPTION)

    CRV_GUIDE = create_guide_rig(full_name,
                                 pos,
                                 SCALP,
                                 sections,
                                 length,
                                 thickness)

    # set lock length status
    lock = ui.lock_length_checkBox.isChecked()
    curve.lock_length(CRV_GUIDE, lock)

    return CRV_GUIDE
コード例 #3
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))
コード例 #4
0
ファイル: guide.py プロジェクト: mgear-dev/mgear4
def lock_length(ui):
    name = ui.xgen_description_lineEdit.text()
    description = xgen_handler.get_description(name)
    lock = ui.lock_length_checkBox.isChecked()
    if description:
        try:
            for crv in xgen_handler.get_connected_curve_guides(description):
                curve.lock_length(crv, lock)
        except TypeError:
            pass
コード例 #5
0
ファイル: guide.py プロジェクト: mgear-dev/mgear4
def smooth_deform(ui, crvs=None):
    name = ui.xgen_description_lineEdit.text()
    description = xgen_handler.get_description(name)
    if not description:
        return
    if crvs:
        if not isinstance(crvs, list):
            crvs = [crvs]
    else:
        crvs = pm.selected()

    crv_guides = xgen_handler.get_connected_curve_guides(description)
    def_curv = []
    for crv in crvs:
        if crv in crv_guides:
            def_curv.append(crv)
    factor = 1.0 - (1.0 / ui.smooth_def_perc_spinBox.value())
    print(factor)
    curve.smooth_curve(def_curv, factor)
コード例 #6
0
ファイル: guide.py プロジェクト: mgear-dev/mgear4
def toggle_guides_visibility(ui):
    name = ui.xgen_description_lineEdit.text()
    description = xgen_handler.get_description(name)
    if description:
        for crv in xgen_handler.get_connected_curve_guides(description):
            attribute.toggle_bool_attr(crv.visibility)
コード例 #7
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