def __init__(s, **kwargs):
     s.callback = None
     s.ids = ids = []
     kwargs["e"] = ("PostSceneRead", s._changed)
     ids.append(pmc.scriptJob(**kwargs))
     kwargs["e"] = ("NewSceneOpened", s._changed)
     ids.append(pmc.scriptJob(**kwargs))
Exemple #2
0
    def __init__(self, target=None):
        self.obj = None
        self.win = window()
        with columnLayout():
            button(l='Tear Off', c=lambda *args: self.tearOff())
            text(l='Orient')
            self.orient = textScrollList()
            text(l='Point')
            self.point = textScrollList()
            text(l='Parent')
            self.parent = textScrollList()
        showWindow()

        self.orient.selectCommand(
            lambda *args: select(self.orient.getSelectItem()))
        self.point.selectCommand(
            lambda *args: select(self.point.getSelectItem()))
        self.parent.selectCommand(
            lambda *args: select(self.parent.getSelectItem()))

        if target:
            self.viewObj(target)
        else:
            self.update()
            scriptJob(e=('SelectionChanged', core.alt.Callback(self.update)),
                      p=self.win)
    def __init__(s, meshes=missing, start=missing, stop=missing, click=missing, drag=missing):
        s.name = "OutOfControlPicker"
        s.active = False # tool state
        s.meshes = meshes # Return an MSelectonList of objs
        s.start = start # Callback
        s.stop = stop # Callback
        s.click = click # Callback
        s.drag = drag # Callback
        s.watch_tools() # Initialize tool watching

        s.kill() # Clear out last tool if there
        pmc.context.draggerContext(
            s.name,
            name=s.name,
            prePressCommand=s.initialize_click,
            releaseCommand=s.tool_click,
            dragCommand=s.tool_drag,
            initialize=s.tool_start,
            finalize=s.tool_end,
            cursor="hand",
            image1="hands.png",
            undoMode="sequence",
        )

        # Track tool changes, allowing us to track previous tool
        pmc.scriptJob(e=("PostToolChanged", s.watch_tools),p=s.name)
Exemple #4
0
def addUIElement(uiType, attribute, uiLabel, callback, renderGlobalsNodeName):
    ui = None
    if uiType == 'bool':
        ui = pm.checkBoxGrp(label=uiLabel)
        if callback is not None:
            pm.checkBoxGrp(ui, edit=True, cc=callback)
    if uiType == 'int':
        ui = pm.intFieldGrp(label=uiLabel, numberOfFields=1)
        if callback is not None:
            pm.intFieldGrp(ui, edit=True, cc=callback)
    if uiType == 'float':
        ui = pm.floatFieldGrp(label=uiLabel, numberOfFields=1)
        if callback is not None:
            pm.floatFieldGrp(ui, edit=True, cc=callback)
    if uiType == 'enum':
        ui = pm.attrEnumOptionMenuGrp(label=uiLabel,
                                      at=attribute,
                                      ei=getEnumList(attribute))
        # attrEnumOptionGrp has no cc callback, so I create a script job
        if callback is not None:
            attribute = pm.Attribute(renderGlobalsNodeName + "." + attribute)
            pm.scriptJob(attributeChange=[attribute, callback], parent=ui)
    if uiType == 'color':
        ui = pm.attrColorSliderGrp(label=uiLabel, at=attribute)
    if uiType == 'string':
        ui = pm.textFieldGrp(label=uiLabel)
        if callback is not None:
            pm.textFieldGrp(ui, edit=True, cc=callback)
    if uiType == 'vector':
        ui = pm.floatFieldGrp(label=uiLabel, nf=3)
        if callback is not None:
            pm.floatFieldGrp(ui, edit=True, cc=callback)
    return ui
Exemple #5
0
    def __init__(self):
        self.main = columnLayout()  # Can't use `with since parent is QT`

        with rowColumnLayout(nc=2):
            self.targets = textScrollList(nr=20,
                                          sc=Callback(self.targetSelected))

            with frameLayout(l='Multi Weights') as self.multiUI:
                pass

        with rowColumnLayout(nc=2):
            button(l='   ^   ', c=Callback(self.moveUp))
            button(l='   v   ', c=Callback(self.moveDown))

        self.name = textFieldButtonGrp(l='Custom Name', bl='Update Existing')
        button(l='Add', c=Callback(self.addSpace, space.Mode.ROTATE_TRANSLATE))
        button(l='Add (Trans Only)',
               c=Callback(self.addSpace, space.Mode.TRANSLATE))
        button(l='Add ( No Rot )', c=Callback(self.addSpace, "#NOROT"))
        button(l='Add (No Trans)', c=Callback(self.addSpace, space.ROTATE))
        button(l='Split Targets (pos then rot)',
               c=Callback(self.addSpace, space.Mode.ALT_ROTATE))
        button(l='Multi/Vert targets', c=Callback(self.addMultiSpace))
        button(l='Multi Orient', c=Callback(self.addMultiOrientSpace))
        text(l='')
        button(l='Add Parent', c=Callback(self.addSpace, '#PARENT'))
        button(l='Add World', c=Callback(self.addSpace, '#WORLD'))
        button(l='Add True World', c=Callback(self.addSpace, '#TRUEWORLD'))
        #button( l='Add External World (For attachments)', c=Callback(self.addSpace, '#EXTERNALWORLD') )
        button(l='Add User Driven', c=Callback(self.addSpace, '#USER'))
        button(l='Remove', c=Callback(self.remove))

        self.update()
        scriptJob(e=('SelectionChanged', Callback(self.update)), p=self.main)
    def __init__(self):
        title = 'pbRenderableCurve'
        version = 1.02

        if pm.window('pbRCurve', exists=True):
            pm.deleteUI('pbRCurve')

        with pm.window('pbRCurve', title='{0} | {1}'.format(title, version), s=False) as window:
            with pm.columnLayout():
                with pm.frameLayout(l='Selection:', cll=True, bs='out'):
                    with pm.columnLayout():
                        self.selField = pm.textFieldGrp(text='No Curves Selected', ed=False, l='Curve:', cw2=[72, 192])
                        with pm.rowLayout(nc=2):
                            self.bRenderable = pm.checkBox(l='Renderable', cc=self.bcRenderable)

                with pm.frameLayout(l='Mesh Settings:', cll=True, bs='out') as self.meshUI:
                    with pm.columnLayout():
                        with pm.rowLayout(nc=4):
                            self.useNormal = pm.checkBox(l='Use Normal', cc=self.bcUseNormal)
                            self.normalVector = [pm.intField(width=62, en=False, value=0, cc=self.setNormal),
                                                 pm.intField(width=62, en=False, value=1, cc=self.setNormal),
                                                 pm.intField(width=62, en=False, value=0, cc=self.setNormal)]
                        self.meshAttrs = [AttrSlider(maxValue=128, name='Thickness', obj=getCurves, type_='float', fmn=0.0001),
                                          AttrSlider(value=3, minValue=3, maxValue=64, name='Sides', obj=getCurves, fmn=3, fmx=100),
                                          AttrSlider(minValue=1, maxValue=32, name='Samples', obj=getCurves, fmn=1, fmx=128)]

                with pm.frameLayout('Shell Settings:', cll=True, bs='out') as self.shellUI:
                    with pm.columnLayout():
                        self.bShell = pm.checkBox(l='Enable Shell', cc=self.bcShell)
                        self.shellAttrs = [AttrSlider(value=1, minValue=-64, maxValue=64, name='ShellThickness', obj=getCurves, type_='float'),
                                           AttrSlider(value=1, minValue=1, maxValue=64, name='ShellDivisions', obj=getCurves, fmn=1, fmx=32)]

        window.show()
        pm.scriptJob(event=['SelectionChanged', self.refresh], protected=True, p=window)
        self.refresh()
 def killJob(self):
     try:
         pm.scriptJob(kill=self.jid)
         io.warn("Killed {0} job: {1}".format(self.event, self.jid))
         self.jid = None
     except Exception:
         raise
Exemple #8
0
    def __init__(self):
        columnLayout()
        self.targets = textScrollList(nr=20, sc=Callback(self.targetSelected))

        rowColumnLayout(nc=2)
        button(l='   ^   ', c=Callback(self.moveUp))
        button(l='   v   ', c=Callback(self.moveDown))
        setParent("..")

        self.name = textFieldButtonGrp(l='Custom Name', bl='Update Existing')
        button(l="Add", c=Callback(self.addSpace, space.Mode.ROTATE_TRANSLATE))
        button(l="Add (Trans Only)",
               c=Callback(self.addSpace, space.Mode.TRANSLATE))
        button(l="Add ( No Rot )", c=Callback(self.addSpace, "#NOROT"))
        button(l="Add (No Trans)", c=Callback(self.addSpace, space.ROTATE))
        button(l="Split Targets (pos then rot)",
               c=Callback(self.addSpace, space.Mode.ALT_ROTATE))
        button(l="Multi/Vert targets", c=Callback(self.addMultiSpace))
        button(l="Multi Orient", c=Callback(self.addMultiOrientSpace))
        text(l='')
        button(l="Add Parent", c=Callback(self.addSpace, '#PARENT'))
        button(l="Add World", c=Callback(self.addSpace, '#WORLD'))
        button(l="Add True World", c=Callback(self.addSpace, '#TRUEWORLD'))
        button(l="Add External World (For attachments)",
               c=Callback(self.addSpace, '#EXTERNALWORLD'))
        button(l="Remove", c=Callback(self.remove))

        self.update()
        scriptJob(e=('SelectionChanged', Callback(self.update)), p=self.name)
Exemple #9
0
    def closeEvent(self, event):
        #print('------  - - -  i am closing')
        pdil.pubsub.unsubscribe(pdil.pubsub.Event.MAYA_DAG_OBJECT_CREATED,
                                self.ui.cardLister.newObjMade)
        try:
            if self.updateId is not None:
                jid = self.updateId
                self.updateId = None
                scriptJob(kill=jid)

            self.spaceTab.close()

            self.settings['geometry'] = pdil.ui.getGeometry(self)
            self.settings['currentTabIndex'] = self.ui.tabWidget.currentIndex()

            if self.runUpdatersId is not None:
                jid = self.runUpdatersId
                self.updateId = None
                scriptJob(kill=jid)

        except Exception:
            pass

        # Might be overkill but I'm trying to prevent new gui parenting to the old widgets
        #self.spaceTabLayout.setObjectName( 'delete_me2' )


#        self.shapeEditor.curveColorLayout.setObjectName( 'delete_me3' )
#        self.shapeEditor.surfaceColorLayout.setObjectName( 'delete_me4' )
        self.startTabLayout.setObjectName('delete_me5')

        event.accept()
Exemple #10
0
    def updateMenu(self, nodeName):
        """
        called to update an optionMenuGrp for choosing between multiple translator options for a given node
        """
        # delete current options
        translators = pm.optionMenuGrp(self._optionMenu,
                                       q=True,
                                       itemListLong=True)
        for tran in translators:
            pm.deleteUI(tran, menuItem=True)

        # populate with a fresh list
        parent = pm.setParent(self._optionMenu)
        for tran in self._translators:
            pm.menuItem(label=tran, parent=parent + '|OptionMenu')

        transName = self.getCurrentTranslator(nodeName)
        pm.optionMenuGrp(self._optionMenu,
                         edit=True,
                         value=transName,
                         cc=lambda *args: self.menuChanged(nodeName, args[0]))
        self.updateChildren(nodeName, transName)

        transAttr = nodeName + ".aiTranslator"
        pm.scriptJob(attributeChange=[
            transAttr,
            lambda *args: self.attributeChanged(nodeName, transAttr, *args)
        ],
                     replacePrevious=True,
                     parent=self._optionMenu)
 def _dock_closed(s, *loop):
     visible = s._dock_query(vis=True)
     if not visible and loop:
         pmc.scriptJob(ie=s._dock_closed, p=s._dock, ro=True)
     elif not visible:
         pmw.deleteUI(s._dock, control=True)
         print "Window closed."
Exemple #12
0
    def buildUI(self):

        pm.setUITemplate("attributeEditorTemplate", pushTemplate=True)

        self.passesParent = pm.setParent(query=True)
        frameLayout = None
        with pm.frameLayout(label="Passes",
                            collapsable=False,
                            parent=self.parent) as frameLayout:
            with pm.columnLayout(adj=True):
                with pm.rowLayout(adj=True,
                                  nc=2,
                                  cw=((1, 200), (2, 200)),
                                  h=350):
                    with pm.frameLayout(label="Existing Passes",
                                        collapsable=False,
                                        h=350):
                        self.availableAOVsListUI = pm.textScrollList(
                            doubleClickCommand=self.AOVdoubleClicked)
                        pm.textScrollList(self.availableAOVsListUI,
                                          edit=True,
                                          append=self.getAOVs())

                    with pm.frameLayout(label="Active Passes",
                                        collapsable=False,
                                        h=350):
                        self.activeAOVsListUI = pm.textScrollList(
                            selectCommand=self.exsistingAOVclicked,
                            doubleClickCommand=self.exsistingAOVdoubleClicked)
                        self.updateExistingAOVList()

        pm.setUITemplate("attributeEditorTemplate", popTemplate=True)
        pm.scriptJob(event=("NameChanged", self.nameChangedCallback),
                     parent=frameLayout)
Exemple #13
0
    def register(self):
        """ Register the dock in maya """
        self.deleteViews()
        
        # Dock
        if pm.dockControl(self.dockName, ex=True):
            pm.deleteUI(self.dockName)

        # Window
        if pm.window(self.winName, ex=True):
            pm.deleteUI(self.winName)
        
        self._win = None
        self.applyMetrics()

        # For a dockControl, we've got to go create the ui this way
        # otherwise when we create the dockControl it doesn't see the main layout
        self._win = pm.window(self.winName, title=self.title)
        with pm.frameLayout('mainForm', lv=False, bv=False, p=self._win) as self._mainLayout:
            self.mainControl = self._mainLayout

            # Create the dockControl
            self._dockControl = pm.dockControl(self.winName+"Dock",
                con=self._win, aa=['left', 'right'], a=self.area, fl=int(self.floating), l=self.title,
                vcc=Callback(self.dockVisibleChanged), vis=False,
            )
            self._win = self._mainLayout
            self.showDefaultView()

        pm.scriptJob(uid=(self._win, Callback(self.winClosed)))
 def killJob(self):
     try:
         pm.scriptJob(kill=self.jid)
         io.warn("Killed {0} job: {1}".format(self.event, self.jid))
         self.jid = None
     except Exception:
         raise
Exemple #15
0
    def __init__(self, **kwargs):
        self.name = 'Topology Tool'
        self.object = 'Topology_win'
        self.symetry_data = None
        self.targetGeo = None
        self.baseGeo = None
        self.edge = None

        # -----------------------------
        # ---  DATA

        self.final_path = self.setPath()
        self.dataList = []
        self.dataList = self.loadData()
        if self.dataList is not []:
            self.baseGeo = self.dataList[1]
            self.edge = self.dataList[0]

        self.ui()

        try:
            self.load_symetry_data()
        except:
            pass

        pm.scriptJob(uiDeleted=(self.object, self.death_notice), runOnce=True)
Exemple #16
0
    def __init__(self, rigObject, callback):

        self._rig      = rigObject
        self._callback = callback
        self._row      = FluidRowLayout(numberOfChildren = 3, separation = Format.SEPARATION)

        with self._row:

            NameField(node = self._rig.node, type = pm.nt.Transform, width = Format.Text.WIDTH)
            pm.button(label = 'Edit', width = Format.Button.WIDTH / 2 - Format.SEPARATION / 2, command = lambda *args: self.editRig())
            pm.button(label = 'Delete', width = Format.Button.WIDTH / 2 - Format.SEPARATION / 2, command = lambda *args: self.deleteRig())

        self._deleteDialog = ConfirmationDialog(
            title   = 'Rig Editor | Delete',
            message = 'Do you want to delete {0}?'.format(self._rig.node),
            confirm = 'Delete',
            deny    = 'Cancel',
            icon    = Window.Icon.WARNING
        )

        pm.scriptJob(
            nodeDeleted     = [self._rig._node, self._callback],
            parent          = self._row,
            replacePrevious = True
        )
 def __init__(self, *args, **kwargs ):
   
   # Make sure that the bakeLayer plugin is loaded
   if not ( pmc.pluginInfo( 'bake_layer_init.py', q = True, loaded = True ) ):
     raise Exception( 'Bake Layer Plugin is not currently loaded' )
   
   # Create the MEL Global var for the currently selected bake layer
   
   pmc.MelGlobals.initVar('string[]', 'selected_bake_layers')
     
   
   self.__window = pmc.window( self,
                               title = "Bake Layer Editor" )
   
   pmc.scriptJob( permanent = True,
                  parent = self.__window,
                  event = [ 'NewSceneOpened', self.new_scene ] )
   
   pmc.scriptJob( permanent = True,
                  parent = self.__window,
                  event = [ 'SceneOpened', self.open_scene ] )
                  
                  
   
   self.menu_dict = { }
   
   self.build( )
   
   self.refresh( )
   
   self.__window.show( )
Exemple #18
0
def addUIElement(uiType, attribute, uiLabel, callback, renderGlobalsNodeName):
    ui = None
    if uiType == 'bool':
        ui = pm.checkBoxGrp(label=uiLabel)
        if callback is not None:
            pm.checkBoxGrp(ui, edit=True, cc=callback)
    if uiType == 'int':
        ui = pm.intFieldGrp(label=uiLabel, numberOfFields = 1)
        if callback is not None:
            pm.intFieldGrp(ui, edit=True, cc = callback)
    if uiType == 'float':
        ui = pm.floatFieldGrp(label=uiLabel, numberOfFields = 1)
        if callback is not None:
            pm.floatFieldGrp(ui, edit=True, cc= callback)
    if uiType == 'enum':
        ui = pm.attrEnumOptionMenuGrp(label = uiLabel, at=attribute, ei = getEnumList(attribute)) 
        # attrEnumOptionGrp has no cc callback, so I create a script job
        if callback is not None:
            attribute = pm.Attribute(renderGlobalsNodeName + "." + attribute)
            pm.scriptJob(attributeChange=[attribute, callback], parent=ui)           
    if uiType == 'color':
        ui = pm.attrColorSliderGrp(label=uiLabel, at=attribute)
    if uiType == 'string':
        ui = pm.textFieldGrp(label=uiLabel)
        if callback is not None:
            pm.textFieldGrp(ui, edit=True, cc=callback)
    if uiType == 'vector':
        ui = pm.floatFieldGrp(label=uiLabel, nf=3)
        if callback is not None:
            pm.floatFieldGrp(ui, edit=True, cc=callback)
    return ui
Exemple #19
0
def _delete_camera_tracker():
    """Delete the camera tracking script-job."""
    scriptjob_exists = (this._camera_script_job is not None
                        and pm.scriptJob(exists=this._camera_script_job))
    if scriptjob_exists:
        pm.scriptJob(kill=this._camera_script_job, force=True)
        this._camera_script_job = None
 def closeEvent(self, event):
     pm.scriptJob(kill=self.scriptJobID)
     self.settings.beginGroup("MainWindow")
     self.settings.setValue("libSeq", QVariant(self.animLibComboBox.currentText()))
     self.settings.setValue("pubSeq", QVariant(self.seqComboBox.currentText()))
     self.settings.setValue("pubShot", QVariant(self.shotComboBox.currentText()))
     self.settings.setValue("pos", QVariant(self.pos()))
     self.settings.endGroup()
 def closeEvent(self, *args, **kwargs):
     """
     Try to kill the script job when the window is closed
     """
     try:
         pymel.scriptJob(kill=self.iJobNum, force=True)
     except:
         pass
Exemple #22
0
 def updateCallBack(self):
     # safety clean of synoticTab script jobs
     # this is neded when we switch models witout close synopticwindow.
     oldJobs = pm.scriptJob(listJobs=True)
     for oldjob in oldJobs:
         if "SynopticTab" in str(oldjob):
             id = oldjob.split(" ")[0][:-1]
             pm.scriptJob(kill=int(id), force=True)
 def closeEvent(self, *args, **kwargs):
     """
     Try to kill the script job when the window is closed
     """
     try:
         pymel.scriptJob(kill=self.iJobNum, force=True)
     except:
         pass
Exemple #24
0
 def setAttribute(self, attribute):
     self.attribute = attribute
     if self.type not in self.UI_TYPES:
         return
     self.UI_TYPES[self.type](self.control, edit=True, attribute=self.attribute)
     if self.callback:
         pm.scriptJob(attributeChange=[self.attribute, self.callback],
                      replacePrevious=True, parent=self.control)
def flushScript( *args ):
    if( script_job_id != -1 ):
        pm.scriptJob( kill=script_job_id, force=True )
        
    pm.lockNode( 'light_probe', lock=False )
    pm.delete('light_probe')
        
    pm.makeLive(none=True)
 def start_all_jobs(self):
     '''
     Start a Maya scriptJob on 'SceneOpened' that will run all update methods.  Store the ID # for
     the scriptJob on the class type
     '''
     if SceneManager.scene_opened_id == -1:
         SceneManager.scene_opened_id = pm.scriptJob(event = ['SceneOpened', self.scene_update])
     if SceneManager.selection_changed_id == -1:
         SceneManager.selection_changed_id = pm.scriptJob(event = ['SelectionChanged', self.selection_changed])
Exemple #27
0
    def refresh(self):

        if self._refreshEvent and pm.scriptJob(exists = self._refreshEvent):
            return

        self._refreshEvent  = pm.scriptJob(
            idleEvent       = self.refreshActions,
            runOnce         = True
        )
Exemple #28
0
    def removeCallbacks(cls, self, group=None, windowInstance=None, windowID=None):
        """Remove all the registered callbacks.
        If group is not set, then all will be removed.

        Either windowInstance or windowID is needed if calling without a class instance.
        """
        # Handle classmethod
        if self is cls:
            if windowInstance is None and windowID is not None:
                windowInstance = cls.windowInstance(windowID)
            if windowInstance is None:
                raise ValueError('windowInstance or windowID parameter is required for classmethod')
        # Handle normal method
        elif windowInstance is None:
            windowInstance = self.windowInstance()

        # Select all groups if specific one not provided
        if group is None:
            groups = windowInstance['callback'].keys()
        else:
            if group not in windowInstance['callback']:
                return 0
            groups = [group]

        # Iterate through each callback to remove certain groups
        numEvents = 0
        for group in groups:
            for callbackID in windowInstance['callback'][group]['event']:
                try:
                    om.MMessage.removeCallback(callbackID)
                except RuntimeError:
                    pass
                else:
                    numEvents += 1
            for callbackID in windowInstance['callback'][group]['node']:
                try:
                    om.MNodeMessage.removeCallback(callbackID)
                except RuntimeError:
                    pass
                else:
                    numEvents += 1
            for callbackID in windowInstance['callback'][group]['scene']:
                try:
                    om.MSceneMessage.removeCallback(callbackID)
                except RuntimeError:
                    pass
                else:
                    numEvents += 1
            for callbackID in windowInstance['callback'][group]['job']:
                try:
                    pm.scriptJob(kill=callbackID)
                except RuntimeError:
                    pass
                else:
                    numEvents += 1
            del windowInstance['callback'][group]
        return numEvents
Exemple #29
0
    def __init__(self, rig, *args, **kwargs):

        self._rig                     = rig

        if not isinstance(rig, Rig):
            raise TypeError('{0} is not type {1}'.format(rig, Rig))

        name                          = rig.name
        kwargs['name']                = name
        kwargs['title']               = name

        kwargs['resizeToFitChildren'] = True
        kwargs['sizeable']            = False

        super(RigEditor, self).__init__(*args, **kwargs)

        with self._window:

            with FluidColumnLayout(numberOfChildren = 1, attachBottom = False, attachRight = False):

                self._sectionsColumn = FluidColumnLayout(numberOfChildren = 1)
                with self._sectionsColumn:

                    self._legFrame = pm.frameLayout(label='Legs', borderStyle='in')
                    with self._legFrame:

                        with FluidColumnLayout(padding = Format.PADDING):

                            self._legColumn = FluidColumnLayout(numberOfChildren = 3, separation = Format.PADDING)
                            with self._legColumn:

                                self._legCreateLayout = FluidRowLayout(numberOfChildren = 2, separation = Format.SEPARATION)
                                with self._legCreateLayout:

                                    self._legNameInput    = pm.textField(text = 'Leg', width = Format.Text.WIDTH, changeCommand = lambda *args: self.createLegRig())
                                    self._legCreateButton = pm.button(label = 'Create New', command = lambda *args: self.createLegRig(), width = Format.Button.WIDTH)

                                pm.separator()

                                self._legListLayout = FluidColumnLayout(numberOfChildren = 2)

        self.populateRigList()

        self._updateOnCreate  = pm.scriptJob(
            event             = ['DagObjectCreated', self.populateRigList],
            parent            = self._window,
            replacePrevious   = True
        )

        self._updateOnDelete = pm.scriptJob(
            nodeDeleted      = [self._rig.node, self.delete],
            parent           = self._window,
            replacePrevious  = True
        )

        self._window.show()
Exemple #30
0
    def __init__(self, value, min, max, name, ceObj):
        self.name = name
        self.ceObj = ceObj

        self.undoState = False
        self.attr = pm.floatSliderGrp(field=True, l=self.name, value=value, pre=3, enable=False,
                                      minValue=min, maxValue=max, dc=lambda *args: self.set(cc=False),
                                      cc=lambda *args: self.set(cc=True), cw3=[96, 64, 128])

        pm.scriptJob(event=['Undo', self.get], protected=True, p=self.attr)
Exemple #31
0
 def _create_scriptjobs(self):
     """Create scriptjobs and stores their ids."""
     self._scriptjobs = (
         pmc.scriptJob(
             nodeNameChanged=(self.node_master.name(), self._on_node_renamed)
         ),
         pmc.scriptJob(
             nodeDeleted=(self.node_master.name(), self.close), runOnce=True
         )
     )
Exemple #32
0
 def removeCallbacks(self):
     self.viewportWidget.removeEventFilter(self.vptoolsEventFilter)
     QApplication.instance().removeEventFilter(self.appEventFilter)
     
     core.scriptJob(kill=self.selectionChangedCallbackId)        
     for id in self.callbackIds:
         core.scriptJob(kill=id)
     self.callbackIds = []
     
     self.selectionChangedCallbackId = -1
Exemple #33
0
    def AppleseedEnvironmentCreateTab(self):
        self.createGlobalsNode()
        parentForm = pm.setParent(query=True)
        pm.setUITemplate("attributeEditorTemplate", pushTemplate=True)
        scLo = self.rendererName + "AOScrollLayout"
        envDict = {}
        self.rendererTabUiDict['environment'] = envDict
        uiDict = envDict
        with pm.scrollLayout(scLo, horizontalScrollBarThickness=0):
            with pm.columnLayout(self.rendererName + "ColumnLayout", adjustableColumn=True, width=400):
                with pm.frameLayout(label="Environment Lighting", collapsable=False):
                    with pm.columnLayout(self.rendererName + "ColumnLayout", adjustableColumn=True, width=400):
                        attr = pm.Attribute(self.renderGlobalsNodeName + ".environmentType")
                        envDict['environmentType'] = pm.attrEnumOptionMenuGrp(label="Environment Type", at=self.renderGlobalsNodeName + ".environmentType", ei=self.getEnumList(attr))

                with pm.frameLayout(label="Environment Colors", collapsable=False) as envDict['commonEnvFrame']:
                    with pm.columnLayout(self.rendererName + "ColumnLayout", adjustableColumn=True, width=400):
                        ui = pm.floatFieldGrp(label="Environment Intensity:", value1=1.0, numberOfFields=1)
                        pm.connectControl(ui, self.renderGlobalsNodeName + ".environmentIntensity", index=2)
                        envDict['environmentColor'] = pm.attrColorSliderGrp(label="Environment Color:", at=self.renderGlobalsNodeName + ".environmentColor")
                        envDict['gradientHorizon'] = pm.attrColorSliderGrp(label="Gradient Horizon Color:", at=self.renderGlobalsNodeName + ".gradientHorizon")
                        envDict['gradientZenit'] = pm.attrColorSliderGrp(label="Gradient Zenith Color:", at=self.renderGlobalsNodeName + ".gradientZenit")
                        envDict['environmentMap'] = pm.attrColorSliderGrp(label="Environment Map:", at=self.renderGlobalsNodeName + ".environmentMap")
                        self.addRenderGlobalsUIElement(attName='latlongHoShift', uiType='float', displayName='Lat-Long Horizontal Shift:', uiDict=uiDict)
                        self.addRenderGlobalsUIElement(attName='latlongVeShift', uiType='float', displayName='Lat-Long Vertical Shift:', uiDict=uiDict)

                with pm.frameLayout(label="Physical Sky", collapsable=False) as envDict['pysSkyFrame']:
                    with pm.columnLayout(self.rendererName + "ColumnLayout", adjustableColumn=True, width=400):
                        attr = pm.Attribute(self.renderGlobalsNodeName + ".skyModel")
                        envDict['pskModel'] = pm.attrEnumOptionMenuGrp(label="Sky Model:", at=self.renderGlobalsNodeName + ".skyModel", ei=self.getEnumList(attr))
                        uiDict['sunLightOptionMenu'] = pm.optionMenuGrp(label="Sun Light:", changeCommand=self.updateSunLightOptionMenu)
                        envDict['pskGrAlbedo'] = pm.floatFieldGrp(label="Ground Albedo:", value1=1.0, numberOfFields=1)
                        pm.connectControl(envDict['pskGrAlbedo'], self.renderGlobalsNodeName + ".ground_albedo", index=2)
                        envDict['pskGrHShit'] = pm.floatFieldGrp(label="Horizon Shift:", value1=1.0, numberOfFields=1)
                        pm.connectControl(envDict['pskGrHShit'], self.renderGlobalsNodeName + ".horizon_shift", index=2)
                        envDict['pskLumMulti'] = pm.floatFieldGrp(label="Luminance Multiplier:", value1=1.0, numberOfFields=1)
                        pm.connectControl(envDict['pskLumMulti'], self.renderGlobalsNodeName + ".luminance_multiplier", index=2)
                        envDict['pskSatMulti'] = pm.floatFieldGrp(label="Saturation Multiplier:", value1=1.0, numberOfFields=1)
                        pm.connectControl(envDict['pskSatMulti'], self.renderGlobalsNodeName + ".saturation_multiplier", index=2)
                        envDict['pskTurb'] = pm.floatFieldGrp(label="Turbidity:", value1=1.0, numberOfFields=1)
                        pm.connectControl(envDict['pskTurb'], self.renderGlobalsNodeName + ".turbidity", index=2)
                        envDict['pskTurbMin'] = pm.floatFieldGrp(label="Turbidity Min:", value1=1.0, numberOfFields=1)
                        pm.connectControl(envDict['pskTurbMin'], self.renderGlobalsNodeName + ".turbidity_min", index=2)
                        envDict['pskTurbMax'] = pm.floatFieldGrp(label="Turbidity Max:", value1=1.0, numberOfFields=1)
                        pm.connectControl(envDict['pskTurbMax'], self.renderGlobalsNodeName + ".turbidity_max", index=2)

                with pm.frameLayout(label="OSL", collapsable=False) as envDict['oslFrame']:
                    with pm.columnLayout(self.rendererName + "ColumnLayout", adjustableColumn=True, width=400):
                        envDict['environmentOSL'] = pm.attrColorSliderGrp(label="OSL Background", at=self.renderGlobalsNodeName + ".environmentOSL")

        pm.setUITemplate("attributeEditorTemplate", popTemplate=True)
        pm.formLayout(parentForm, edit=True, attachForm=[ (scLo, "top", 0), (scLo, "bottom", 0), (scLo, "left", 0), (scLo, "right", 0) ])
        pm.scriptJob(attributeChange=[self.renderGlobalsNode.environmentType, pm.Callback(self.uiCallback, tab="environment")])
        pm.scriptJob(attributeChange=[self.renderGlobalsNode.skyModel, pm.Callback(self.uiCallback, tab="environment")])
        self.updateEnvironment()
Exemple #34
0
 def setAttribute(self, attribute):
     self.attribute = attribute
     if self.type not in self.UI_TYPES:
         return
     self.UI_TYPES[self.type](self.control,
                              edit=True,
                              attribute=self.attribute)
     if self.callback:
         pm.scriptJob(attributeChange=[self.attribute, self.callback],
                      replacePrevious=True,
                      parent=self.control)
Exemple #35
0
def attrTextFieldGrp(*args, **kwargs):
    """
    There is a bug with attrControlGrp and string attributes where it ignores
    any attempt to edit the current attribute.  So, we have to write our own
    replacement
    """
    attribute = kwargs.pop('attribute', kwargs.pop('a', None))
    assert attribute is not None, "You must passed an attribute"
    changeCommand = kwargs.pop('changeCommand', kwargs.pop('cc', None))
    if changeCommand:

        def cc(newVal):
            pm.setAttr(attribute, newVal)
            changeCommand(newVal)
    else:
        cc = lambda newVal: pm.setAttr(attribute, newVal)

    if kwargs.pop('edit', kwargs.pop('e', False)):
        ctrl = args[0]
        pm.textFieldGrp(ctrl,
                        edit=True,
                        text=pm.getAttr(attribute),
                        changeCommand=cc)
        pm.scriptJob(parent=ctrl,
                     replacePrevious=True,
                     attributeChange=[
                         attribute, lambda: pm.textFieldGrp(
                             ctrl, edit=True, text=pm.getAttr(attribute))
                     ])
    elif kwargs.pop('query', kwargs.pop('q', False)):
        # query
        pass
    else:
        # create
        labelText = kwargs.pop('label', None)
        if not labelText:
            labelText = pm.mel.interToUI(attribute.split('.')[-1])
        ctrl = None
        if len(args) > 0:
            ctrl = args[0]
            pm.textFieldGrp(ctrl,
                            label=labelText,
                            text=pm.getAttr(attribute),
                            changeCommand=cc)
        else:
            ctrl = pm.textFieldGrp(label=labelText,
                                   text=pm.getAttr(attribute),
                                   changeCommand=cc)
        pm.scriptJob(parent=ctrl,
                     attributeChange=[
                         attribute, lambda: pm.textFieldGrp(
                             ctrl, edit=True, text=pm.getAttr(attribute))
                     ])
        return ctrl
Exemple #36
0
 def closeEvent(self, event):
     core.pubsub.unsubscribe(core.pubsub.Event.MAYA_DAG_OBJECT_CREATED,
                             self.ui.cardLister.newObjMade)
     try:
         if self.updateId is not None:
             id = self.updateId
             self.updateId = None
             scriptJob(kill=id)
     except Exception:
         pass
     event.accept()
    def activate_selection_callback(self):
        """
        Activate script job for selection change tool update
        """

        callback_no = int()
        if callback_no:
            pm.scriptJob(kill=callback_no)
        callback_no = pm.scriptJob(
            parent='weight_tool_object',
            e=['SelectionChanged', self.update_joint_list_influence],
            protected=True)
 def update_velocity_grid_export(self, param_name):
     grp = "OpenVDBVelocityGrids"
     attr_value = pm.getAttr(param_name)
     pm.textFieldGrp(grp, edit=True,
                     text="" if attr_value is None else attr_value,
                     changeCommand=lambda val: pm.setAttr(param_name, val))
     pm.scriptJob(parent=grp,
                  replacePrevious=True,
                  attributeChange=[param_name,
                                   lambda: pm.textFieldGrp(grp, edit=True,
                                                           text=pm.getAttr(param_name))])
     self.setup_velocity_grid_popup(grp, param_name)
 def update_velocity_grid_export(self, param_name):
     grp = "OpenVDBVelocityGrids"
     attr_value = pm.getAttr(param_name)
     pm.textFieldGrp(grp, edit=True,
                     text="" if attr_value is None else attr_value,
                     changeCommand=lambda val: pm.setAttr(param_name, val))
     pm.scriptJob(parent=grp,
                  replacePrevious=True,
                  attributeChange=[param_name,
                                   lambda: pm.textFieldGrp(grp, edit=True,
                                                           text=pm.getAttr(param_name))])
     self.setup_velocity_grid_popup(grp, param_name)
def placeHighLight(*args):
    ### UI setup 
    global UI_name
    UI_name = [ 'txtBtn_light', 'txtBtn_camera', 'txtBtn_object', 'txtBtn_HLitPoint', 'btn_placeHLit', 'chk_interaction' ]
    
    if pm.window( 'winPlaceHLit', exists=True ):
        pm.deleteUI( 'winPlaceHLit', window=True )
        
    ui_layout['window'] = pm.window( 'winPlaceHLit', title='Place Highlight', sizeable=False, h=100, w=250 )
    ui_layout['mainLayout'] = pm.columnLayout( columnAlign='left', columnAttach=['left', 0] )
    
    #// get active camera
    activeViewCamera = getActiveCam()
    
    '''loc_light_probe = pm.createNode('locator', name='light_probe')
    pm.lockNode(loc_light_probe, lock=False)'''

    #// sub layout
    #// sub1
    ui_layout['ui_sub1'] = pm.rowLayout(nc=2, cw=[(1, 210), (2, 40)], p=ui_layout['mainLayout'] )
    pm.textFieldButtonGrp( UI_name[0], label='Light: ', text='', buttonLabel='Pick',editable=False, buttonCommand='pickLit()', cw=[(1,50), (2,120), (3,40)], p=ui_layout['ui_sub1'] )
    pm.button( 'btn_sel_light' ,label='Sel', command=pm.Callback( doSelItem, UI_name[0] ), p=ui_layout['ui_sub1'] )
    
    #// sub2
    ui_layout['ui_sub2'] = pm.rowLayout(nc=2, cw=[(1, 210), (2, 40)], p=ui_layout['mainLayout'] )
    pm.textFieldButtonGrp( UI_name[1], label='Camera: ', text=activeViewCamera, buttonLabel='Pick', editable=False, buttonCommand='pickCam()', cw=[(1,50), (2,120), (3,40)], p=ui_layout['ui_sub2'] )
    pm.button( 'btn_sel_camera' ,label='Sel', command=pm.Callback( doSelItem, UI_name[1] ), p=ui_layout['ui_sub2'] )
    
    #// sub3
    ui_layout['ui_sub3'] = pm.rowLayout(nc=2, cw=[(1, 210), (2, 40)], p=ui_layout['mainLayout'] )
    pm.textFieldButtonGrp( UI_name[2], label='Object: ', text='', buttonLabel='Pick', editable=False, buttonCommand='pickTgtObj()', cw=[(1,50), (2,120), (3,40)], p=ui_layout['ui_sub3'] )
    pm.button( 'btn_sel_obj' ,label='Sel', command=pm.Callback( doSelItem, UI_name[2] ), p=ui_layout['ui_sub3'] )
    
    #// sub4
    ui_layout['ui_sub4'] = pm.rowLayout(nc=2, cw=[(1, 210), (2, 40)], p=ui_layout['mainLayout'] )    
    pm.textFieldButtonGrp( UI_name[3], label='Point: ', text='', buttonLabel='Pick', editable=False, buttonCommand='pickHLitPt()', cw=[(1,50), (2,120), (3,40)], p=ui_layout['ui_sub4'] )
    pm.button( 'btn_sel_point' ,label='Sel', command=pm.Callback( doSelItem, UI_name[3] ), p=ui_layout['ui_sub4'] )
    
    #// sub5
    ui_layout['ui_sub5'] = pm.rowLayout(nc=2, cw=[(1, 70), (2, 50)], p=ui_layout['mainLayout'] )
    pm.button( UI_name[4] ,label='Place Light!', command='doPlaceHLight()', p=ui_layout['ui_sub5'] )    
    pm.checkBox( UI_name[5], label='interactive mode', onCommand=pm.Callback( doInteractionON ), offCommand=pm.Callback( doInteractionOFF ), p=ui_layout['ui_sub5'] )
    
    
    pm.showWindow( ui_layout['window'] )
    
    pm.spaceLocator( name='light_probe' )
    pm.lockNode( 'light_probe', lock=True )
    pm.textFieldButtonGrp( 'txtBtn_HLitPoint', edit=True, text='light_probe' )
    
    #// clean make live and scriptJob after exit script
    pm.scriptJob( uiDeleted=[ ui_layout['window'], pm.Callback( flushScript ) ] )
Exemple #41
0
def createArnoldAOVTab():
    parentForm = cmds.setParent(query=True)

    aovNode = aovs.AOVInterface()
    pm.columnLayout('enableAOVs', adjustableColumn=True)

    pm.setUITemplate('attributeEditorTemplate', pushTemplate=True)

    pm.attrControlGrp(attribute=aovNode.node.aovMode, label='Mode')

    # the tab gets recreated from scratch each time rather than updated and each
    # time the AOVOptionMenuGrp adds itself to the AOVChanged callback list.
    # we must remove it or we'll leave behind invalid copies
    global _aovDisplayCtrl
    if _aovDisplayCtrl is not None:
        aovs.removeAOVChangedCallback(_aovDisplayCtrl.update)

    _aovDisplayCtrl = shaderTemplate.AOVOptionMenuGrp('aiOptions',
                                                      'displayAOV',
                                                      label='Render View AOV',
                                                      allowCreation=False,
                                                      includeBeauty=True,
                                                      allowEmpty=False,
                                                      allowDisable=False)
    _aovDisplayCtrl._setToChildMode()
    _aovDisplayCtrl._doSetup(aovNode.node.name() + '.displayAOV')

    pm.setParent(parentForm)

    cmds.scrollLayout('arnoldAOVsScrollLayout', horizontalScrollBarThickness=0)

    cmds.columnLayout('arnoldTabColumn', adjustableColumn=True)

    ed = ArnoldAOVEditor(aovNode)

    cmds.formLayout(parentForm,
                    edit=True,
                    af=[('enableAOVs', "top", 5), ('enableAOVs', "left", 0),
                        ('enableAOVs', "right", 0),
                        ('arnoldAOVsScrollLayout', "bottom", 0),
                        ('arnoldAOVsScrollLayout', "left", 0),
                        ('arnoldAOVsScrollLayout', "right", 0)],
                    an=[('enableAOVs', "bottom")],
                    ac=[('arnoldAOVsScrollLayout', "top", 5, 'enableAOVs')])

    pm.setUITemplate('attributeEditorTemplate', popTemplate=True)

    cmds.setParent(parentForm)
    pm.evalDeferred(ed.fixOptionMenus)
    ed.setEnabledState()
    pm.scriptJob(attributeChange=(aovNode.node.aovMode, ed.setEnabledState),
                 parent=ed.mainCol)
 def update_channel(self, channel_name, param_name):
     grp = "OpenVDB%sChannelGrp" % channel_name
     attr_value = pm.getAttr(param_name)
     pm.textFieldGrp(grp, edit=True,
                     text="" if attr_value is None else attr_value,
                     changeCommand=lambda val: pm.setAttr(param_name, val))
     pm.scriptJob(parent=grp,
                  replacePrevious=True,
                  attributeChange=[param_name,
                                   lambda : pm.textFieldGrp(grp, edit=True,
                                                           text=pm.getAttr(param_name))])
     self.clear_popups(grp)
     pm.popupMenu(parent=grp, postMenuCommand=lambda popup, popup_parent: AEvdb_visualizerTemplate.setup_popup_menu_elems(popup, popup_parent, param_name))
Exemple #43
0
    def closeEvent(self, e):
        """
        Deletes this ui scriptjobs and save geometry settings
        when closing the window.
        :param e: QtCore.QEvent.
        """
        # Remove scriptjobs
        for num in self._scriptjobs:
            if pmc.scriptJob(ex=num):
                pmc.scriptJob(kill=num, force=True)

        # Save settings
        Settings.save_geometry(self.saveGeometry())
Exemple #44
0
    def updateNode(self, *args):

        self.updateName()

        if self._nameWatch and pm.scriptJob(exists = self._nameWatch):
            pm.scriptJob(kill = self._nameWatch)

        if self._attribute.get():

            self._nameWatch = pm.scriptJob(
                nodeNameChanged = [self._attribute.get(), self.updateName],
                parent          = self._field
            )
Exemple #45
0
    def _unregisterScriptJobs(self):
        """
        This will unregster all the events tied with this UI. It will
        then clear any registered ID's stored within the class.
        """
        for job_id in self.script_job_ids:
            pm.scriptJob(
                kill=job_id,
                force=True,
            )

        # -- Clear all our job ids
        self.script_job_ids = list()
 def update_channel(self, channel_name, param_name):
     grp = "OpenVDB%sChannelGrp" % channel_name
     attr_value = pm.getAttr(param_name)
     pm.textFieldGrp(grp, edit=True,
                     text="" if attr_value is None else attr_value,
                     changeCommand=lambda val: pm.setAttr(param_name, val))
     pm.scriptJob(parent=grp,
                  replacePrevious=True,
                  attributeChange=[param_name,
                                   lambda : pm.textFieldGrp(grp, edit=True,
                                                           text=pm.getAttr(param_name))])
     self.clear_popups(grp)
     pm.popupMenu(parent=grp, postMenuCommand=lambda popup, popup_parent: AEvdb_visualizerTemplate.setup_popup_menu_elems(popup, popup_parent, param_name))
Exemple #47
0
    def selectChanged(self, *args):
        # wrap to catch exception guaranteeing maya does not stop at this
        try:
            self.__selectChanged(*args)

        except Exception as e:
            mes = traceback.format_exc()
            mes = "error has occur in scriptJob " \
                  "SelectionChanged\n{0}".format(mes)

            mes = "{0}\n{1}".format(mes, e)
            mgear.log(mes, mgear.sev_error)
            pm.scriptJob(kill=self.selJob)
            self.close()
Exemple #48
0
def installCallbacks():
    """
    install all callbacks
    """
    # certain scenes fail to execute this callback:
    #callbacks.addAttributeChangedCallback(_rendererChanged, 'renderGlobals', 'currentRenderer')
    if pm.about(batch=True):
        callbacks.addAttributeChangedCallback(_rendererChanged, 'renderGlobals', 'currentRenderer')
    else:
        pm.scriptJob(attributeChange=['defaultRenderGlobals.currentRenderer', _rendererChanged] )
        pm.scriptJob(event =['SceneOpened', _rendererChanged] )

    import mtoa.aovs as aovs
    aovs.installCallbacks()
Exemple #49
0
    def outputChangedCallback(self, aovOutputAttr, newValue, outputType,
                              defaultNode):
        """
        change callback for both filter and driver menus
        
        outputType: either 'aiAOVDriver' or 'aiAOVFilter'
        """
        conn = aovOutputAttr.inputs()
        if newValue.startswith('<'):
            isDefault = True
            pm.connectAttr(defaultNode + '.message', aovOutputAttr, force=True)
            outputNode = pm.PyNode(defaultNode)
            pm.select(outputNode)
            if conn and not conn[0].outputs():
                utils.safeDelete(conn[0])
        else:
            isDefault = False
            if conn and conn[0].outputs():
                # other AOVs are dependent on existing filter/driver. create and connect a new one
                outputNode = pm.createNode(outputType)
                pm.connectAttr(outputNode.message, aovOutputAttr, force=True)
            else:
                outputNode = conn[0]
            newValue = newValue.strip('<>')
            outputNode.aiTranslator.set(newValue)

        if outputType == 'aiAOVFilter':
            self.filterNode = outputNode
            hooks.setupFilter(outputNode, self.aovItem.aovName())
            menu = self.filterMenu
        else:
            self.driverNode = outputNode
            hooks.setupDriver(outputNode, self.aovItem.aovName())
            menu = self.driverMenu

        transAttr = outputNode.attr('aiTranslator')
        if not isDefault:
            # change the selected menu item when the translator attribute changes for our driver/filter
            pm.scriptJob(attributeChange=[
                transAttr, lambda: self.translatorChanged(transAttr, menu)
            ],
                         replacePrevious=True,
                         parent=menu)
        else:
            # delete pre-existing scriptJob
            pm.scriptJob(attributeChange=[transAttr, lambda: self.dummy()],
                         replacePrevious=True,
                         parent=menu)

        self.aovItem.outputsChanged = True
Exemple #50
0
def attrTextFieldGrp(*args, **kwargs):
    """
    There is a bug with attrControlGrp and string attributes where it ignores
    any attempt to edit the current attribute.  So, we have to write our own
    replacement
    """
    attribute = kwargs.pop('attribute', kwargs.pop('a', None))
    assert attribute is not None, "You must passed an attribute"
    changeCommand = kwargs.pop('changeCommand', kwargs.pop('cc', None))
    if changeCommand:
        def cc(newVal):
            pm.setAttr(attribute, newVal)
            changeCommand(newVal)
    else:
        cc = lambda newVal: pm.setAttr(attribute, newVal)

    if kwargs.pop('edit', kwargs.pop('e', False)):
        ctrl = args[0]
        pm.textFieldGrp(ctrl, edit=True,
                    text=pm.getAttr(attribute),
                    changeCommand=cc)
        pm.scriptJob(parent=ctrl,
                     replacePrevious=True,
                     attributeChange=[attribute,
                                      lambda: pm.textFieldGrp(ctrl, edit=True,
                                                              text=pm.getAttr(attribute))])
    elif kwargs.pop('query', kwargs.pop('q', False)):
        # query
        pass
    else:
        # create
        labelText = kwargs.pop('label', None)
        if not labelText:
            labelText = pm.mel.interToUI(attribute.split('.')[-1])
        ctrl = None
        if len(args) > 0:
            ctrl = args[0]
            pm.textFieldGrp(ctrl,
                            label=labelText,
                            text=pm.getAttr(attribute),
                            changeCommand=cc)
        else:
            ctrl = pm.textFieldGrp(label=labelText,
                                   text=pm.getAttr(attribute),
                                   changeCommand=cc)
        pm.scriptJob(parent=ctrl,
                     attributeChange=[attribute,
                                      lambda: pm.textFieldGrp(ctrl, edit=True,
                                                              text=pm.getAttr(attribute))])
        return ctrl
Exemple #51
0
    def _unregisterScriptJobs(self):
        """
        This will unregster all the events tied with this UI. It will
        then clear any registered ID's stored within the class.
        """
        while self.script_job_ids:
            try:
                pm.scriptJob(
                    kill=self.script_job_ids.pop(),
                    force=True,
                )

            except Exception:
                pass
Exemple #52
0
def createArnoldAOVTab():
    parentForm = cmds.setParent(query=True)

    aovNode = aovs.AOVInterface()
    pm.columnLayout('enableAOVs', adjustableColumn=True)
    
    pm.setUITemplate('attributeEditorTemplate', pushTemplate=True)

    pm.attrControlGrp(attribute=aovNode.node.aovMode, label='Mode')

    # the tab gets recreated from scratch each time rather than updated and each
    # time the AOVOptionMenuGrp adds itself to the AOVChanged callback list. 
    # we must remove it or we'll leave behind invalid copies
    global _aovDisplayCtrl
    if _aovDisplayCtrl is not None:
        aovs.removeAOVChangedCallback(_aovDisplayCtrl.update)

    _aovDisplayCtrl = shaderTemplate.AOVOptionMenuGrp('aiOptions', 'displayAOV', label='Render View AOV',
                                           allowCreation=False,
                                           includeBeauty=True,
                                           allowEmpty=False,
                                           allowDisable=False)
    _aovDisplayCtrl._setToChildMode()
    _aovDisplayCtrl._doSetup(aovNode.node.name() + '.displayAOV')
    
    pm.setParent(parentForm)

    cmds.scrollLayout('arnoldAOVsScrollLayout', horizontalScrollBarThickness=0)

    cmds.columnLayout('arnoldTabColumn', adjustableColumn=True)

    ed = ArnoldAOVEditor(aovNode)

    cmds.formLayout(parentForm,
               edit=True,
                    af=[('enableAOVs',"top", 5),
                        ('enableAOVs', "left", 0),
                        ('enableAOVs', "right", 0),
                        ('arnoldAOVsScrollLayout', "bottom", 0),
                        ('arnoldAOVsScrollLayout', "left", 0),
                        ('arnoldAOVsScrollLayout', "right", 0)],
                    an=[('enableAOVs', "bottom")],
                    ac=[('arnoldAOVsScrollLayout', "top", 5, 'enableAOVs')])

    pm.setUITemplate('attributeEditorTemplate', popTemplate=True)

    cmds.setParent(parentForm)
    pm.evalDeferred(ed.fixOptionMenus)
    ed.setEnabledState()
    pm.scriptJob(attributeChange = (aovNode.node.aovMode, ed.setEnabledState), parent=ed.mainCol)
	def SelectBlueprintJoint_callBack(self):
		
		selection = pm.ls(selection = True)
		self.blueprintJoints = self.FindBlueprintJoints(selection)
		
		
		if self.blueprintJoints == None:
			pm.confirmDialog(title = "Attach Geometry to Blueprint", message = "Blueprint joint selection invalid. \nTerminating tool.", button = ["Accept"], defaultButton = "Accept")
		
		elif self.geometry == None:
			pm.headsUpMessage("Please select the geometry you wish to attach to the specified blueprint joint(s).")
			pm.scriptJob(event = ["SelectionChanged", self.SelectGeometry_callBack], runOnce = True)
		
		else:
			self.AttachGeometryToBlueprint_attachment()
Exemple #54
0
 def create(self):
     """ Build the window and show the default view """
     self.deleteViews()
     
     if pm.window(self.winName, ex=True):
         pm.deleteUI(self.winName)
     
     self._win = None
     self.applyMetrics()
     with pm.window(self.winName, title=self.title, toolbox=self.toolbox) as self._win:
         self.mainControl = self._win
         with pm.frameLayout('mainForm', lv=False, bv=False) as self._mainLayout:
             self.showDefaultView()
     
     pm.scriptJob(uid=(self._win, Callback(self.winClosed)))
Exemple #55
0
    def __init__(self):
        with pm.frameLayout(l='Set Editor:', cll=True, cl=False, bs='out') as setUI:
            with pm.columnLayout(width=162):
                self.uvs = pm.textScrollList(w=160, h=72,
                                             sc=self.select_set,
                                             dcc=self.rename_set,
                                             dkc=self.delete_set)
                self.update_sets()

                with pm.rowLayout(nc=3):
                    pm.button(l='New', c=self.add_set)
                    pm.button(l='Copy', c=self.dup_set)
                    pm.button(l='UV Linking', c=lambda *args: pm.mel.UVCentricUVLinkingEditor())

        pm.scriptJob(event=['SelectionChanged', self.update_sets], protected=True, p=setUI)
    def contents(self):
        with ui.TopMidDownLayout(): 
            with pm.columnLayout(adj=True):
                ui.ObjectSelector( label='Sample Object : ', pht='Select Object',  optVar=self.objName, height=22, auto=True, id=-1 )
                pm.separator(h=8, style='in')
            
            self.TSL = pm.textScrollList( w=10, h=20, selectCommand=pm.Callback( self.uiCmds, 'TSL_select') )
            
            pm.separator(h=1,style='none')
            
        # update
        self.uiCmds('scriptJob_selectionChange')

        # add ScriptJob
        pm.scriptJob( parent=self.TSL, event=['SelectionChanged', pm.Callback( self.uiCmds, 'scriptJob_selectionChange') ] )
Exemple #57
0
 def connectMaya(self):
     # type: () -> None
     # script job callback
     ptr = long(shiboken.getCppPointer(self)[0])
     gui = OpenMayaUI.MQtUtil.fullName(ptr)
     self.selJob = pm.scriptJob(e=("SelectionChanged", self.selectChanged),
                                parent=gui)
Exemple #58
0
def uiCreate(selText, obName, selectionOk):
    objectName = obName
    selOk = selectionOk
    if pm.window('fkCtrlMaker', exists=True):
        pm.deleteUI('fkCtrlMaker')

    window = pm.window('fkCtrlMaker',
                       title='Fk Ctrl Maker',
                       iconName='FK',
                       widthHeight=(400, 200))

    if pm.columnLayout('winLayout', exists=True):
        pm.deleteUI('winLayout')

    winLayout = pm.columnLayout('winLayout', adjustableColumn=True)
    pm.separator('sep1', height=10, style='double')
    windowText = pm.text(selText, p=winLayout, al='center')
    pm.separator(height=20, style='double')
    pm.button(label='Basic Circle',
              command='makeShape("BCircle", objectName, groupName, offName)',
              en=selOk)
    pm.button(label='Detailed Circle',
              command='makeShape("DCircle", objectName, groupName, offName)',
              en=selOk)
    pm.button(label='Basic Square', command='buttonPressed()', en=selOk)
    pm.button(label='Close',
              command=('pm.deleteUI(\"' + window + '\", window=True)'))
    pm.setParent('..')
    pm.showWindow(window)
    winJob = pm.scriptJob(kws=True,
                          p=window,
                          e=("SelectionChanged", selectionCheck))
Exemple #59
0
 def noUiUpdate(self):
     self._uiActiveStack.append( self.uiActive )
     self.uiActive = False
     yield
     self.uiActive = self._uiActiveStack.pop()
             
     self.updateId = scriptJob( e=('SelectionChanged', core.alt.Callback(self.selectionChanged)) )
Exemple #60
0
    def __init__(self, rig_component):
        self.process = System.Diagnostics.Process.GetCurrentProcess()
        self.ui = Freeform.Rigging.SpaceSwitcher.SpaceSwitcher(self.process)
        self.vm = self.ui.DataContext

        self.space_string = "Current Space - "
        self.component = rig_component
        self.index_rig_dict = {}
        self.job_id = pm.scriptJob(event=('timeChanged', self.update_ui))

        current_network = self.component.network.get('component')
        current_type = v1_shared.shared_utils.get_class_info(
            current_network.get('component_type'))[-1]
        self.vm.WindowName = "Rig Component Switcher - {0} {1}".format(
            current_network.get('side'), current_network.get('region'))
        self.vm.CurrentSpace = "{0}{1}".format(self.space_string, current_type)

        self.update_ui()

        # Load Event Handlers
        self.vm.CloseWindowEventHandler += self.close
        self.vm.SetFrameHandler += self.set_frame
        self.vm.GetCurrentFrameHandler += self.get_frame
        self.vm.SwitchSpaceHandler += self.switch_space
        self.vm.SelectSwitchObjectsHandler += self.pick_switch_objects
        self.vm.SelectSwitchSpaceHandler += self.pick_space_object