Esempio n. 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)
Esempio n. 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()
Esempio n. 4
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)
Esempio n. 5
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)