Beispiel #1
0
def object_creator_ui():
    """This method creates user interface to input object details

        User Inputs:
            - Object name
            - Object ID

    Returns : None
    """
    WINDOW = 'ObjectCreator'
    if pm.window(WINDOW, query=True, exists=True):
        pm.deleteUI(WINDOW)
    pm.window(WINDOW,
              title="Object creator",
              iconName='OC',
              widthHeight=(200, 250))
    column_1 = pm.columnLayout(adjustableColumn=True)

    pm.Text(label="Enter Object Name", parent=column_1)
    object_name = pm.TextField(text='Object', parent=column_1)

    pm.separator(height=20, style='in', parent=column_1)
    pm.Text(label="Enter ID to start with", parent=column_1)
    object_id = pm.TextField(text='01', parent=column_1)

    pm.separator(height=20, style='in', parent=column_1)
    pm.button(label='Create Joint',
              command=lambda x: create_joint(object_name.getText(),
                                             object_id.getText()),
              parent=column_1)

    pm.separator(height=20, style='in', parent=column_1)
    pm.button(label='Create Locator',
              command=lambda x: create_locator(object_name.getText(),
                                               object_id.getText()),
              parent=column_1)

    pm.separator(height=20, style='in', parent=column_1)
    pm.button(label='Create Group',
              command=lambda x: create_group(object_name.getText(),
                                             object_id.getText()),
              parent=column_1)

    pm.showWindow(WINDOW)
    pm.window(WINDOW, edit=True, widthHeight=(200, 250))
    return None
Beispiel #2
0
def __rename_list_from_textfields(*args):
    # preview = pm.PyUI( 'th_rename_preview_right' )
    search = pm.TextField('th_rename_search').getText()
    replace = pm.TextField('th_rename_replace').getText()
    prefix = pm.TextField('th_rename_prefix').getText()
    suffix = pm.TextField('th_rename_suffix').getText()
    fr = pm.TextField('th_rename_from').getText()
    by = pm.TextField('th_rename_by').getText()

    ret = []
    for i, name in enumerate(args):
        if (search and replace): name = re.sub(search, replace, name)
        if (prefix): name = prefix + name
        if (fr and by):
            name = name.rstrip('0123456789') + str(int(fr) + i * int(by))
        if (suffix): name = name + suffix
        ret.append(name)
        print '+', name
    return ret
Beispiel #3
0
def CustomScripts_UI():

    WINDOW = 'CustomScripts'
    if pm.window(WINDOW, query=True, exists=True):
        pm.deleteUI(WINDOW)
    pm.window(WINDOW,
              title="Custom Scripts",
              iconName='CS',
              widthHeight=(200, 400))
    column_1 = pm.columnLayout(adjustableColumn=True)

    pm.separator(height=20, style='in', parent=column_1)
    pm.button(label='Immediate Parent in Hierarchy',
              command=lambda x: CustomScripts.immediateParent())

    pm.separator(height=20, style='in', parent=column_1)
    hide_jnt_col = pm.rowColumnLayout(parent=column_1,
                                      numberOfColumns=3,
                                      columnWidth=(1, 95))
    pm.button(label='Hide Joint',
              command=lambda x: CustomScripts.jntHide(),
              parent=hide_jnt_col)
    pm.separator(parent=hide_jnt_col, horizontal=False, width=10)
    pm.button(label='Show Joint',
              command=lambda x: CustomScripts.jntShow(),
              parent=hide_jnt_col,
              width=95)

    pm.separator(height=20, style='in', parent=column_1)
    lod_col = pm.rowColumnLayout(parent=column_1,
                                 numberOfColumns=3,
                                 columnWidth=(1, 95))
    pm.button(label='LOD off',
              command=lambda x: CustomScripts.lodOff(),
              parent=lod_col)
    pm.separator(parent=lod_col, horizontal=False, width=10)
    pm.button(label='LOD on',
              command=lambda x: CustomScripts.lodOn(),
              parent=lod_col,
              width=95)

    pm.separator(height=20, style='in', parent=column_1)
    pm.button(label='Parent( in selection order)',
              command=lambda x: CustomScripts.parentChain(),
              parent=column_1)

    # get object name
    pm.separator(height=20, style='in', parent=column_1)
    row_col_2 = pm.rowColumnLayout(numberOfColumns=2,
                                   columnWidth=(1, 150),
                                   parent=column_1,
                                   columnOffset=(2, 'left', 10))
    object_name = pm.TextField(parent=row_col_2)
    pm.button(
        label='<<',
        parent=row_col_2,
        command=lambda x: object_name.setText(str(pm.ls(selection=True)[0])))
    row_col_3 = pm.rowColumnLayout(numberOfColumns=2,
                                   columnWidth=(1, 100),
                                   parent=column_1,
                                   columnOffset=(2, 'left', 10))
    prntChk = pm.checkBox("parent", parent=row_col_3)
    sclChk = pm.checkBox("scale", parent=row_col_3)
    pm.separator(height=5, style='none', parent=column_1)
    pm.button(
        label='Copy Object to selected positions',
        parent=column_1,
        command=lambda x: CustomScripts.copyObjects(obj=object_name.getText(),
                                                    prFlg=prntChk.getValue(),
                                                    scFlg=sclChk.getValue()))

    pm.separator(height=20, style='in', parent=column_1)
    pm.button(label="copy orientation",
              parent=column_1,
              command=lambda x: CustomScripts.CopyJntOri())

    pm.showWindow(WINDOW)
    pm.window(WINDOW, edit=True, widthHeight=(200, 320))
    return None
Beispiel #4
0
def copySDK_UI():
    WINDOW = 'copySDK'
    if pm.window(WINDOW, query=True, exists=True):
        pm.deleteUI(WINDOW)
    pm.window(WINDOW,
              title="copySDK",
              iconName='SDKcpy',
              widthHeight=(210, 370))

    # Layout
    column_1 = pm.columnLayout(adjustableColumn=True)
    textlabel = pm.text(label="UI for script downloaded from\
                                 highend3d.com\nContact Email : [email protected]",
                        align="center",
                        wordWrap=True)
    pm.separator(height=20, style='in', parent=column_1)
    col2 = pm.columnLayout(width=200, adjustableColumn=False, parent=column_1)
    row_col_1 = pm.rowColumnLayout(numberOfColumns=2,
                                   columnWidth=(1, 100),
                                   parent=column_1,
                                   columnOffset=(2, 'left', 10))
    pm.separator(height=20, style='in', parent=column_1)
    col3 = pm.columnLayout(width=200, adjustableColumn=False, parent=column_1)
    row_col_2 = pm.rowColumnLayout(numberOfColumns=2,
                                   columnWidth=(1, 100),
                                   parent=column_1,
                                   columnOffset=(2, 'left', 10))
    row_col_3 = pm.rowColumnLayout(numberOfColumns=2,
                                   columnWidth=(1, 100),
                                   parent=column_1,
                                   columnOffset=(2, 'left', 10))
    pm.separator(height=20, style='in', parent=column_1)
    row_col_4 = pm.rowColumnLayout(numberOfColumns=2,
                                   columnWidth=(1, 100),
                                   parent=column_1,
                                   columnOffset=(2, 'left', 10))
    row_col_5 = pm.rowColumnLayout(numberOfRows=2, parent=row_col_4)
    column_2 = pm.columnLayout(adjustableColumn=False,
                               width=200,
                               columnOffset=["both", 50],
                               parent=column_1)

    # Widgets
    cr_attr_chk_bx = pm.checkBox('Create attribute',
                                 parent=column_2,
                                 editable=False)
    mode_lbl = pm.text(label="mode", align="center", parent=col2, width=200)
    mode_radio = pm.radioCollection(parent=column_1)
    rb1 = pm.radioButton(label='driven',
                         parent=row_col_1,
                         select=True,
                         onCommand=lambda x: pm.checkBox(
                             cr_attr_chk_bx, edit=True, editable=False))
    rb1 = pm.radioButton(label='driver',
                         parent=row_col_1,
                         select=False,
                         onCommand=lambda x: pm.checkBox(
                             cr_attr_chk_bx, edit=True, editable=True))

    ctr_replace_lbl = pm.text(label="controller",
                              align="center",
                              parent=col3,
                              width=200)
    search_lbl = pm.text(label="search",
                         align="center",
                         parent=row_col_2,
                         width=100)
    replace_lbl = pm.text(label="replace",
                          align="center",
                          parent=row_col_2,
                          width=100)
    search_str = pm.TextField(text='', parent=row_col_3)
    replace_str = pm.TextField(text='', parent=row_col_3)
    refresh_button = pm.button(
        label='Refresh',
        parent=row_col_5,
        command=lambda x: populate_attr(field_obj=attr_list))
    attr_list = pm.textScrollList('Attr',
                                  numberOfRows=10,
                                  parent=row_col_5,
                                  height=150,
                                  width=100,
                                  allowMultiSelection=True)
    populate_attr(field_obj=attr_list)
    mirror_chk_bx = pm.checkBox('mirror', parent=row_col_4)

    apply_button = pm.button(
        label='Apply',
        parent=column_2,
        width=100,
        command=lambda x: sdk_call(mode_radio, attr_list, search_str,
                                   replace_str, mirror_chk_bx, cr_attr_chk_bx))

    pm.showWindow(WINDOW)
    pm.window(WINDOW, edit=True, widthHeight=(210, 370))
    return None
Beispiel #5
0
def constraints_ui():
    WINDOW = 'Constraints'
    if pm.window(WINDOW, query=True, exists=True):
        pm.deleteUI(WINDOW)
    pm.window(WINDOW,
              title="Constraints",
              iconName='CON',
              widthHeight=(200, 275))
    column_1 = pm.columnLayout(adjustableColumn=True)
    pm.separator(height=2, style='in', parent=column_1)
    mulChLbl = pm.Text(label="Multiple Children", parent=column_1)
    pm.separator(height=5, style='none', parent=column_1)
    rowCol1 = pm.rowColumnLayout(numberOfRows=3, parent=column_1)
    txt_row_col_1 = pm.rowColumnLayout(numberOfColumns=2,
                                       columnWidth=(1, 150),
                                       parent=rowCol1,
                                       columnSpacing=(1, 15))
    mulCtrlNm = pm.TextField(parent=txt_row_col_1)
    mulCtrlBtn = pm.button(
        label='<<',
        parent=txt_row_col_1,
        command=lambda x: mulCtrlNm.setText(str(pm.ls(selection=True)[0])))
    row_col_1 = pm.rowColumnLayout(numberOfColumns=2,
                                   columnWidth=(1, 100),
                                   parent=rowCol1,
                                   columnAlign=(2, 'center'),
                                   columnSpacing=(1, 25))
    prChk = pm.checkBox("Parent", parent=row_col_1)
    scChk = pm.checkBox("Scale", parent=row_col_1)
    conBtn = pm.button(label="Constraint",
                       parent=column_1,
                       command=lambda x: mul_con_call(mulCtrlNm, prChk, scChk))

    pm.separator(height=20, style='in', parent=column_1)
    setLbl = pm.Text(label="Selection Set", parent=column_1)
    pm.separator(height=5, style='none', parent=column_1)
    rowCol2 = pm.rowColumnLayout(numberOfRows=2, parent=column_1)

    row_col_2 = pm.rowColumnLayout(numberOfColumns=2,
                                   columnWidth=(1, 100),
                                   parent=rowCol2,
                                   columnAlign=(2, 'center'),
                                   columnSpacing=(1, 25))
    prSetChk = pm.checkBox("Parent", parent=row_col_2)
    scSetChk = pm.checkBox("Scale", parent=row_col_2)
    conSetBtn = pm.button(label="Constraint",
                          parent=column_1,
                          command=lambda x: set_con_call(prSetChk, scSetChk))

    pm.separator(height=20, style='in', parent=column_1)
    delConLbl = pm.Text(label="Delete Constraints", parent=column_1)
    pm.separator(height=5, style='none', parent=column_1)
    rowCol3 = pm.rowColumnLayout(numberOfRows=3, parent=column_1)
    row_col_3_1 = pm.rowColumnLayout(numberOfColumns=2,
                                     columnWidth=(1, 100),
                                     parent=rowCol3,
                                     columnAlign=(2, 'center'),
                                     columnSpacing=(1, 25))
    row_col_3_2 = pm.rowColumnLayout(numberOfColumns=2,
                                     columnWidth=(1, 100),
                                     parent=rowCol3,
                                     columnAlign=(2, 'center'),
                                     columnSpacing=(1, 25))
    prDelChk = pm.checkBox("Parent", parent=row_col_3_1)
    scDelChk = pm.checkBox("Scale", parent=row_col_3_1)
    ptDelChk = pm.checkBox("Point", parent=row_col_3_2)
    orDelChk = pm.checkBox("Orient", parent=row_col_3_2)
    conDelBtn = pm.button(
        label="Delete",
        parent=column_1,
        command=lambda x: del_cons(prDelChk, scDelChk, ptDelChk, orDelChk))

    pm.showWindow(WINDOW)
    pm.window(WINDOW, edit=True, widthHeight=(200, 275))
    return None
Beispiel #6
0
def spline_ik_setup_UI():
    WINDOW = 'SplineIK'
    if pm.window(WINDOW, query=True, exists=True):
        pm.deleteUI(WINDOW)
    pm.window(WINDOW,
              title="Spline IK",
              iconName='SplineIK',
              widthHeight=(250, 310))

    main_column = pm.columnLayout(adjustableColumn=True)
    pm.separator(height=5, style='in', parent=main_column)
    name_col = pm.rowColumnLayout(numberOfColumns=2,
                                  parent=main_column,
                                  columnOffset=(1, "left", 30),
                                  columnSpacing=(2, 5),
                                  columnWidth=(2, 130))
    pm.separator(height=5, style='in', parent=main_column)
    joint_col = pm.rowColumnLayout(numberOfColumns=3,
                                   parent=main_column,
                                   columnOffset=(1, "left", 30),
                                   columnSpacing=(2, 5))
    pm.separator(height=5, style='in', parent=main_column)
    dense_col = pm.rowColumnLayout(numberOfColumns=4,
                                   columnOffset=(1, "left", 5),
                                   parent=main_column,
                                   columnSpacing=(3, 10))
    pm.separator(height=5, style='in', parent=main_column)
    curve_option_col = pm.rowColumnLayout(numberOfColumns=2,
                                          columnOffset=(1, "left", 5),
                                          parent=main_column,
                                          columnSpacing=(2, 70))
    pm.separator(height=5, style='none', parent=main_column)
    curve_name_col = pm.rowColumnLayout(numberOfColumns=3,
                                        columnOffset=(1, "left", 40),
                                        parent=main_column,
                                        columnSpacing=(2, 5))
    pm.separator(height=5, style='none', parent=main_column)
    curve_simplify_col = pm.rowColumnLayout(numberOfColumns=4,
                                            columnOffset=(1, "left", 5),
                                            parent=main_column,
                                            columnSpacing=(3, 5))
    pm.separator(height=5, style='in', parent=main_column)
    stretch_col = pm.rowColumnLayout(numberOfColumns=2,
                                     columnWidth=(1, 100),
                                     parent=main_column,
                                     columnOffset=(1, "left", 5))
    pm.separator(height=5, style='in', parent=main_column)

    global_scale_col = pm.rowColumnLayout(numberOfColumns=3,
                                          columnWidth=(1, 100),
                                          parent=main_column,
                                          columnOffset=(1, "left", 5),
                                          columnSpacing=(3, 10))

    pm.separator(height=20, style='in', parent=main_column)

    ctrl_jnt_col = pm.rowColumnLayout(numberOfColumns=3,
                                      columnOffset=(1, "left", 5),
                                      parent=main_column,
                                      columnWidth=(3, 50),
                                      columnSpacing=(3, 5))
    pm.separator(height=20, style='in', parent=main_column)

    create_btn_col = pm.rowColumnLayout(numberOfColumns=3,
                                        parent=main_column,
                                        columnOffset=(2, "left", 65),
                                        columnWidth=(2, 300))

    pm.text(label="Ik name", parent=name_col)
    name_text = pm.TextField(text="", parent=name_col)
    pm.text(label="base joint", parent=joint_col)
    joint_name = pm.textField(text="", parent=joint_col)
    pm.button(
        label="<<",
        parent=joint_col,
        command=lambda x: joint_name.setText(str(pm.ls(selection=True)[0])))

    dense_div_label = pm.text()
    dense_div_text = pm.textField()
    dense_chain_chb = pm.checkBox(
        "dense chain",
        parent=dense_col,
        changeCommand=lambda x:
        (dense_div_label.setEnable(dense_chain_chb.getValue()),
         dense_div_text.setEditable(dense_chain_chb.getValue())))
    pm.separator(style='single', horizontal=False, parent=dense_col, width=20)

    pm.text(dense_div_label,
            edit=True,
            label="divisions",
            parent=dense_col,
            enable=dense_chain_chb.getValue())
    pm.textField(dense_div_text,
                 edit=True,
                 text="3",
                 parent=dense_col,
                 editable=dense_chain_chb.getValue(),
                 width=50)

    curve_label = pm.text(label="Curve", parent=curve_name_col)
    curve_text = pm.textField(text="", parent=curve_name_col, editable=False)
    curve_btn = pm.button(
        label="<<",
        parent=curve_name_col,
        enable=False,
        command=lambda x: curve_text.setText(str(pm.ls(selection=True)[0])))

    spans_label = pm.text()
    spans_text = pm.TextField()
    curve_simple_chb = pm.checkBox(
        label="simplify curve",
        parent=curve_simplify_col,
        enable=True,
        changeCommand=lambda x:
        (spans_label.setEnable(curve_simple_chb.getValue()),
         spans_text.setEditable(curve_simple_chb.getValue())))
    pm.separator(style='single',
                 horizontal=False,
                 parent=curve_simplify_col,
                 width=5)
    pm.text(spans_label,
            edit=True,
            label="spans    ",
            parent=curve_simplify_col,
            enable=curve_simple_chb.getValue())
    pm.textField(spans_text,
                 edit=True,
                 text="3",
                 parent=curve_simplify_col,
                 editable=curve_simple_chb.getValue())

    curve_create = pm.radioCollection(parent=curve_option_col)
    pm.radioButton(
        "AutoCurve",
        label="Auto Curve",
        select=True,
        parent=curve_option_col,
        onCommand=lambda x:
        (curve_btn.setEnable(False), curve_label.setEnable(False),
         curve_text.setEditable(False), curve_simple_chb.setEnable(True),
         spans_label.setEnable(curve_simple_chb.getValue()),
         spans_text.setEditable(curve_simple_chb.getValue())))
    pm.radioButton(
        "UseCurve",
        label="use Curve",
        select=False,
        parent=curve_option_col,
        onCommand=lambda x:
        (curve_btn.setEnable(True), curve_label.setEnable(True),
         curve_text.setEditable(True), curve_simple_chb.setEnable(False),
         spans_label.setEnable(False), spans_text.setEditable(False)))

    stretch_scale_chb = pm.checkBox()
    global_scale_chb = pm.checkBox()
    scale_attr_text = pm.TextField()
    scale_label = pm.text()

    stretch_chb = pm.checkBox(
        label="stretch",
        parent=stretch_col,
        changeCommand=lambda x:
        (stretch_scale_chb.setEditable(stretch_chb.getValue()),
         global_scale_chb.setEditable(stretch_chb.getValue()),
         scale_attr_text.setEditable(stretch_chb.getValue() and
                                     global_scale_chb.getValue()),
         scale_label.setEnable(stretch_chb.getValue() and global_scale_chb.
                               getValue())))

    pm.checkBox(stretch_scale_chb,
                edit=True,
                label="connect scale",
                parent=stretch_col,
                editable=stretch_chb.getValue())

    pm.checkBox(global_scale_chb,
                edit=True,
                label="global scale",
                parent=global_scale_col,
                editable=stretch_chb.getValue(),
                changeCommand=lambda x:
                (scale_attr_text.setEditable(global_scale_chb.getValue()),
                 scale_label.setEnable(global_scale_chb.getValue())))
    pm.text(scale_label,
            edit=True,
            label="scale attr",
            parent=global_scale_col,
            enable=(stretch_scale_chb.getValue() and stretch_chb.getValue))
    pm.textField(scale_attr_text,
                 edit=True,
                 text="",
                 parent=global_scale_col,
                 editable=stretch_chb.getValue(),
                 width=90)
    pm.text(label="number of control joints ", parent=ctrl_jnt_col)
    ctrl_jnt_num = pm.textField(text="3", parent=ctrl_jnt_col, width=50)
    pm.text(label="", parent=create_btn_col)
    pm.button(label="create",
              align="center",
              parent=create_btn_col,
              width=100,
              command=lambda x: call_fun(name_text.getText(
              ), joint_name.getText(), dense_chain_chb.getValue(
              ), int(dense_div_text.getText()), curve_create.getSelect(
              ), curve_text.getText(), curve_simple_chb.getValue(
              ), int(spans_text.getText()), stretch_chb.getValue(
              ), stretch_scale_chb.getValue(), int(ctrl_jnt_num.getText(
              )), global_scale_chb.getValue(), scale_attr_text.getText()))

    pm.showWindow(WINDOW)
    pm.window(WINDOW, edit=True, widthHeight=(250, 310))
    return None
    def tread_create_ui(self):
        self.WINDOW = 'Loop_Motion_Path'
        if pm.window(self.WINDOW, query=True, exists=True):
            pm.deleteUI(self.WINDOW)
        pm.window(self.WINDOW,
                  title="Loop Motion Path",
                  iconName='TR',
                  widthHeight=(200, 220))
        column_1 = pm.columnLayout(adjustableColumn=True)
        pm.separator(height=20, style='none', parent=column_1)
        self.tread_name = pm.TextField(text='Setup_Name', parent=column_1)
        pm.separator(height=20, style='none', parent=column_1)
        # get parent name
        row_col_1 = pm.rowColumnLayout(numberOfColumns=2,
                                       columnWidth=(1, 150),
                                       parent=column_1,
                                       columnOffset=(2, 'left', 10))
        self.curve_name = pm.TextField(text='PathCurve', parent=row_col_1)
        pm.button(label='<<',
                  parent=row_col_1,
                  command=lambda x: self.set_path_name())

        chk_bx_col = pm.rowColumnLayout(parent=column_1,
                                        numberOfColumns=2,
                                        columnWidth=(1, 20))
        pm.text("", parent=chk_bx_col)
        self.dup_crv_chk_bx = pm.checkBox("Duplicate Curve",
                                          parent=chk_bx_col,
                                          value=True)
        pm.separator(height=20, style='in', parent=column_1)
        self.jnt_type_lbl = pm.text(label="object placement type",
                                    align="left",
                                    parent=column_1)
        pm.separator(height=5, style='none', parent=column_1)
        self.jnt_typ_radio = pm.radioCollection(parent=column_1)

        row_layout = pm.rowLayout(numberOfColumns=2,
                                  height=20,
                                  parent=column_1)
        sel_chk_bx_col = pm.rowColumnLayout(parent=column_1,
                                            numberOfColumns=2,
                                            columnWidth=(1, 20))

        info_chk_bx_col = pm.ColumnLayout(parent=column_1)
        self.chk_bx_info = pm.text("", parent=info_chk_bx_col, enable=False)
        pm.text("", parent=sel_chk_bx_col)
        self.sel_obj_chk_bx = pm.checkBox("Use Selection On Curve",
                                          parent=sel_chk_bx_col,
                                          value=False,
                                          enable=False)
        self.divisions = pm.TextField(text='1', parent=column_1)

        pm.radioButton(
            label='uniform',
            parent=row_layout,
            select=True,
            onCommand=lambda x: self.ui_set_selection_enable(flag="uniform"))
        pm.radioButton(
            label='selection',
            parent=row_layout,
            onCommand=lambda x: self.ui_set_selection_enable(flag="selection"))

        pm.separator(height=20, style='none', parent=column_1)
        pm.text("Input sample object (default joint)", parent=column_1)

        sample_row_col = pm.rowColumnLayout(numberOfColumns=2,
                                            columnWidth=(1, 150),
                                            parent=column_1,
                                            columnOffset=(2, 'left', 10))
        self.sample_name = pm.text(label="", parent=sample_row_col)
        pm.button(label='<<',
                  parent=sample_row_col,
                  command=lambda x: self.set_sample_object())
        pm.separator(height=20, style='none', parent=column_1)
        pm.button(label='Create',
                  parent=column_1,
                  command=lambda x: self.setup_motion_path())
        pm.showWindow(self.WINDOW)
        pm.window(self.WINDOW, edit=True, widthHeight=(200, 320))
        return None