示例#1
0
    def __init__(self, parent):
        self.parent = parent
        self.widgets = {}
        aw = self.addWidget
        win = pm.Window(title="Grid Manager", width=100, height=200)
        with aw('win', win):
            with aw('col', pm.ColumnLayout()):
                aw(
                    'resetButton',
                    pm.Button(label="Reset",
                              command=lambda x: self.parent.reset()))
                aw('resetText', pm.Text(label='  '))
                aw(
                    'snapButton',
                    pm.Button(label="Snap Selected Verts To Grid",
                              command=lambda x: self.parent.snapVertsToGrid()))
                aw('snapText', pm.Text(label='  '))

                aw(
                    'growButton',
                    pm.Button(
                        label="Grow",
                        command=lambda x: self.growWithWarning(log=True)))
                aw(
                    'shrinkButton',
                    pm.Button(
                        label="Shrink",
                        command=lambda x: self.shrinkWithWarning(log=True)))

        self.widgets['win'].show()
    def __init__(self, parentRef):
        self.parentRef = parentRef
        self.buttons = []
        self.window = pm.window(sizeable=False, title="Retoper", titleBar=True)
        with self.window:
            self.layout = pm.columnLayout()
            with self.layout:
                self.lab1 = pm.Text(
                    label='A "Retop" Tool For Creating New Topology.',
                    align='left',
                    parent=self.layout)
                self.lab2 = pm.Text(
                    label='Please Note: This tool does not preserve',
                    width=300,
                    align='left',
                    parent=self.layout)
                self.lab3 = pm.Text(
                    label='construction history of edited objects.',
                    width=300,
                    align='left',
                    parent=self.layout)

                btn__setReference = pm.Button(
                    label='Set Reference Mesh',
                    parent=self.layout,
                    command=lambda xc: self.parentRef.setReference(),
                    width=300)
                self.buttons.append(btn__setReference)

                btn__makeReferenceLive = pm.Button(
                    label='Make Reference Live',
                    parent=self.layout,
                    command=lambda xc: self.parentRef.makeReferenceLive(),
                    width=300)
                self.buttons.append(btn__makeReferenceLive)

                btn__makeReferenceNotLive = pm.Button(
                    label='Make Reference Not Live',
                    parent=self.layout,
                    command=lambda xc: self.parentRef.makeReferenceNotLive(),
                    width=300)
                self.buttons.append(btn__makeReferenceNotLive)

                btn__projectSelection = pm.Button(
                    label='Project Selection To Surface',
                    parent=self.layout,
                    command=lambda xc: self.parentRef.projectSelection(),
                    width=300)
                self.buttons.append(btn__projectSelection)

        # Show Window
        pm.showWindow(self.window)
        self.window.setWidth(600)
        self.window.setHeight(400)
示例#3
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
示例#4
0
def __update_rename_preview():
    preview_left = pm.ColumnLayout('th_rename_preview_left')
    preview_right = pm.ColumnLayout('th_rename_preview_right')
    old = []
    for item in preview_left.getChildArray():
        old.append(pm.Text(item).getLabel())
    new = __rename_list_from_textfields(*old)
    preview_right.clear()
    for name in new:
        pm.text(label=name, align='left', p=preview_right)
示例#5
0
    def makeUi(self):
        self.window = pm.Window(title="Mmmm Rename By Regular Expression Tool")
        with self.window:
            self.col = pm.ColumnLayout()
            with self.col:
                ## We should put a button in here for more help, giving some examples.
                ## ****
                #self.helpButton = pm.Button( label="Help - CLick here for more help." )

                #self.row0 = pm.RowLayout( numberOfColumns=2  )
                #with self.row0:
                #    self.textFieldFrom = pm.textField()

                self.row1 = pm.RowLayout(numberOfColumns=2)
                with self.row1:
                    self.textFrom = pm.Text(label="Rename regex - from:")
                    self.textFieldFrom = pm.textField()
                self.row2 = pm.RowLayout(numberOfColumns=2)
                with self.row2:
                    self.textTo = pm.Text(label="Rename regex - to:")
                    self.textFieldTo = pm.textField()
                self.row3 = pm.RowLayout(numberOfColumns=2)
                with self.row3:
                    self.textCount = pm.Text(label="Count:")
                    self.intFieldCount = pm.IntField()
                #self.row4 = pm.RowLayout( numberOfColumns=2 )
                #with self.row4:
                #self.textCount = pm.Text( label = "Padding (Not Yet Implemented):" )
                #self.intFieldCount = pm.IntField( )
                self.row5 = pm.RowLayout(numberOfColumns=2)
                with self.row5:
                    self.textRename = pm.Text(label="     ")
                    self.buttonRename = pm.Button(
                        label="Rename Selected",
                        command=lambda x: self.parent.rename(
                            toName=self.textFieldTo.getText(),
                            fromName=self.textFieldFrom.getText(),
                            count=self.intFieldCount.getValue()))
                self.textHelp = pm.Text(label="""
                
                This is a regular expression based renaming tool.
                It is designed to be extremely powerful, not extremely easy.
                --------------------------------
                
                Count is the maximum number of occurances to replace.
                When count is zero, replacement will be unlimited.
                
                * matches 0 or more (greedy)
                + matches 1 or more (greedy)
                ? matches 0 or 1 (greedy)
                ?* matches 0 or more (non-greedy)
                ?+ matches 1 or more (non-greedy)
                ?? matches 0 or 1 (non-greedy)
                
                
                ^ start of line
                $ end of string
                
                .  any character other than newline
                
                \w any alphanumeric character
                \W any non-alphanumeric character
                \d  any numerical digit
                \D  any non decimal character
                \s  any whitespace
                \S  any non-whitespace
                
                
                |   OR operator:  A|B, will match either A or B.
                
                """)

        self.window.show()
示例#6
0
    def __init__(self, parentRef, parentWidget=None):
        self.parentRef = parentRef
        self.buttons = []
        self.widgets = {}

        if parentWidget == None:
            parentWidget = self.widgets['parentWidget'] = pm.Window(
                sizeable=True, title="Retoper", titleBar=True)
        else:
            self.widgets['parentWidget'] = parentWidget

        with parentWidget:
            self.layout = pm.columnLayout()
            with self.layout:
                labelStr = 'A "Retop" Tool For Creating New Topology.'
                labelStr += '\n'
                labelStr += 'Please Note: This tool does not preserve'
                labelStr += '\n'
                labelStr += 'construction history of edited objects.'
                self.lab1 = pm.Text(label=labelStr,
                                    align='left',
                                    parent=self.layout)
                ##self.lab2 = pm.Text( label='Please Note: This tool does not preserve', width=300, align='left',parent = self.layout )
                ##self.lab3 = pm.Text( label='construction history of edited objects.', width=300, align='left',parent = self.layout )

                btn__setReference = pm.Button(
                    label='Set Reference Mesh',
                    parent=self.layout,
                    command=lambda xc: self.parentRef.setReference())
                self.buttons.append(btn__setReference)

                btn__selectReference = pm.Button(
                    label='Select Reference',
                    parent=self.layout,
                    command=lambda xc: self.parentRef.selectReference())
                self.buttons.append(btn__selectReference)

                btn__makeReferenceLive = pm.Button(
                    label='Make Reference Live',
                    parent=self.layout,
                    command=lambda xc: self.parentRef.makeReferenceLive())
                self.buttons.append(btn__makeReferenceLive)

                btn__makeReferenceNotLive = pm.Button(
                    label='Make Reference Not Live',
                    parent=self.layout,
                    command=lambda xc: self.parentRef.makeReferenceNotLive())
                self.buttons.append(btn__makeReferenceNotLive)

                btn__makeReferenceHidden = pm.Button(
                    label='Make Reference Hidden',
                    parent=self.layout,
                    command=lambda xc: self.parentRef.makeReferenceHidden())
                self.buttons.append(btn__makeReferenceHidden)

                btn__makeReferenceVisible = pm.Button(
                    label='Make Reference Visible',
                    parent=self.layout,
                    command=lambda xc: self.parentRef.makeReferenceVisible())
                self.buttons.append(btn__makeReferenceVisible)

                btn__projectSelection = pm.Button(
                    label='Project Selection To Surface',
                    parent=self.layout,
                    command=lambda xc: self.parentRef.projectSelection())
                self.buttons.append(btn__projectSelection)

                ## put a button here for auto new material and transparency animation
                ## put a button here for auto ref layer
                ## put a button here for quad draw (a shortcut)
                ## put a button here to project along particular axis (essentially just scale first)

        # Show Window
        if type(parentWidget) == pm.core.windows.window:
            win = parentWidget
            pm.showWindow(win)
            win.setWidth(200)
            win.setHeight(300)
示例#7
0
    def __init__(self, parent=None, mmmm=None, parentWidget=None):
        self.parent = parent
        self.mmmm = mmmm
        self.widgets = {}

        self.annotationAboutInteraction = (
            "The settings should also auto apply when you change them,\n " +
            "but due to a Maya bug, you may occasionally have to apply manually,\n "
            + "with the button.")

        try:
            initialMultiplier = pm.melGlobals[
                'MmmmToolsModelerGridToolsMultiplier']
        except:
            initialMultiplier = 1.0
            pm.melGlobals.initVar('float',
                                  'MmmmToolsModelerGridToolsMultiplier')
            pm.melGlobals['MmmmToolsModelerGridToolsMultiplier'] = 1.0
        initialSpacing = ((pm.grid(query=True, spacing=True) /
                           pm.grid(query=True, divisions=True)) /
                          initialMultiplier)
        initialWholeSize = pm.grid(query=True, size=True) / initialMultiplier

        ## Use this as parent otherwise use something else
        if parentWidget == None:
            parentWidget = self.widgets['parentWidget'] = pm.Window(
                title="Grid Manager", width=100, height=200)
        else:
            self.widgets['parentWidget'] = parentWidget

        ## Make a shortcut for function that addWidgets
        aw = self.addWidget

        with parentWidget:
            with aw('col', pm.ColumnLayout()):
                aw(
                    'mayaOptionsButton',
                    pm.Button(label="Maya Grid Options...",
                              command=lambda x: pm.mel.eval("GridOptions;")))
                aw(
                    'resetButton',
                    pm.Button(label="Reset (To Maya Defaults)",
                              command=lambda x: self.resetToMayaDefault()))
                #aw('resetText', pm.Text(label='  '))
                aw(
                    'reset2Button',
                    pm.Button(label="Apply These Settings",
                              annotation=self.annotationAboutInteraction,
                              command=lambda x: MmmmToolsMod.Static.Grid.
                              reset_via_numbers(
                                  multiplier=self.getMultiplierFromUi(),
                                  spacing=self.getSpacingFromUi(),
                                  wholeSize=self.getWholeSizeFromUi(),
                                  setManip=True,
                              )))

                ## note the "with" doesn't work with rows,
                ## so we manually specify parents
                priorParent = self.widgets['col']

                row1 = self.widgets["row1"] = pm.rowLayout(numberOfColumns=2)
                aw('rowText1', pm.Text('Multiplier:', parent=row1))
                aw(
                    'multiplierFloatField',
                    pm.floatField(
                        value=initialMultiplier,
                        parent=row1,
                        annotation=
                        "This will mutiply with both spacing and whole size \n "
                        + "to determine the final amount used. \n \n" +
                        self.annotationAboutInteraction,
                        changeCommand=lambda x: self.onChangedField(),
                        enterCommand=lambda x: self.onChangedField(),
                    ))
                pm.setParent(priorParent)

                row2 = self.widgets["row2"] = pm.rowLayout(numberOfColumns=2)
                aw('rowText2', pm.Text('Spacing:', parent=row2))
                aw(
                    'spacingFloatField',
                    pm.floatField(
                        value=initialSpacing,
                        parent=row2,
                        annotation="This will control grid point spacing,\n " +
                        "and will multiply with multiplier\n " +
                        "to determine the final amount used. \n \n" +
                        self.annotationAboutInteraction,
                        changeCommand=lambda x: self.onChangedField(),
                        enterCommand=lambda x: self.onChangedField(),
                    ))
                pm.setParent(priorParent)

                row3 = self.widgets["row3"] = pm.rowLayout(numberOfColumns=2)
                aw('rowText3', pm.Text('Whole:', parent=row3))
                aw(
                    'wholeSizeFloatField',
                    pm.floatField(
                        value=initialWholeSize,
                        parent=row3,
                        annotation=
                        "This will control the extents of the whole grid,\n " +
                        "(width/height) and will multiply with multiplier \n "
                        + "to determine the final amount used. \n \n" +
                        "Note, Maya's grid width is like a radius, \n" +
                        "visible grid in Maya always looks twice as tall/wide, \n"
                        +
                        "since the 'size' setting in Maya is distance from grid center, \n"
                        + "that's how Maya is intended to work. \n \n" +
                        self.annotationAboutInteraction,
                        changeCommand=lambda x: self.onChangedField(),
                        enterCommand=lambda x: self.onChangedField(),
                    ))
                pm.setParent(priorParent)

                row4 = self.widgets["row4"] = pm.rowLayout(numberOfColumns=2)
                aw('rowText4',
                   pm.Text('Auto adjust discreet move:', parent=row4))
                aw('setManipCheckBox',
                   pm.CheckBox(value=True, label=' ', parent=row4))
                ## the checkbox has a built in label, but that shows on wrong side
                pm.setParent(priorParent)

                aw('spacerBlankText', pm.Text(label='  '))

                aw(
                    'snapButton',
                    pm.Button(label="Snap Selected Objs To Grid",
                              command=lambda x: MmmmToolsMod.Static.Grid.
                              putSelectedObjsOnGrid()))
                aw(
                    'snapButton',
                    pm.Button(label="Snap Selected Verts To Grid",
                              command=lambda x: MmmmToolsMod.Static.Grid.
                              snapVertsToGrid()))
                aw('snapText', pm.Text(label='  '))

                aw(
                    'growButton',
                    pm.Button(
                        label="Grow",
                        command=lambda x: self.growWithWarning(log=True)))
                aw(
                    'shrinkButton',
                    pm.Button(
                        label="Shrink",
                        command=lambda x: self.shrinkWithWarning(log=True)))

        # Show Window
        if type(parentWidget) == pm.core.windows.window:
            win = parentWidget
            pm.showWindow(win)
            win.setWidth(200)
            win.setHeight(300)
示例#8
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