Пример #1
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)
Пример #2
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()
Пример #3
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()
Пример #4
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)
    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