Esempio n. 1
0
    def __init__(self):
        """
		Initializes the pop up menu class call
		"""
        self.optionVars = []
        self.IsClickedOptionVar = OptionVarFactory("cgmVar_IsClicked", "int", 0)
        self.mmActionOptionVar = OptionVarFactory("cgmVar_mmAction", "int", 0)

        self.setupVariables()

        panel = mc.getPanel(up=True)
        if panel:
            # Attempt at fixing a bug of some tools not working when the pop up parent isn't 'viewPanes'
            if "MayaWindow" in mc.panel(panel, q=True, ctl=True):
                panel = "viewPanes"

        sel = search.selectCheck()

        self.IsClickedOptionVar.set(0)
        self.mmActionOptionVar.set(0)

        if mc.popupMenu("cgmMM", ex=True):
            mc.deleteUI("cgmMM")

        if panel:
            if mc.control(panel, ex=True):
                try:
                    mc.popupMenu(
                        "cgmMM", ctl=0, alt=0, sh=0, mm=1, b=1, aob=1, p=panel, pmc=lambda *a: self.createUI("cgmMM")
                    )
                except:
                    guiFactory.warning("cgm.setMenu failed!")
Esempio n. 2
0
	def __init__(self):	
		"""
		Initializes the pop up menu class call
		"""
		self.optionVars = []
		IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked', 0)
		mmActionOptionVar = OptionVarFactory('cgmVar_mmAction',0)			
		
		panel = mc.getPanel(up = True)
		if panel:
			# Attempt at fixing a bug of some tools not working when the pop up parent isn't 'viewPanes'
			if 'MayaWindow' in mc.panel(panel,q = True,ctl = True):
				panel = 'viewPanes'
			
		sel = search.selectCheck()
		
		IsClickedOptionVar.set(0)
		mmActionOptionVar.set(0)
		
		if mc.popupMenu('cgmMM',ex = True):
			mc.deleteUI('cgmMM')
			
		if panel:
			if mc.control(panel, ex = True):
				try:
					mc.popupMenu('cgmMM', ctl = 0, alt = 0, sh = 0, mm = 1, b =1, aob = 1, p = panel,
						         pmc = lambda *a: self.createUI('cgmMM'))
				except:
					guiFactory.warning('Exception on set key marking menu')
					mel.eval('performSetKeyframeArgList 1 {"0", "animationList"};')		
Esempio n. 3
0
	def __init__(self):	
		"""
		Initializes the pop up menu class call
		"""
		self.optionVars = []
		IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked', 0)
		mmActionOptionVar = OptionVarFactory('cgmVar_mmAction',0)			
		
		panel = mc.getPanel(up = True)
		if panel:
			# Attempt at fixing a bug of some tools not working when the pop up parent isn't 'viewPanes'
			if 'MayaWindow' in mc.panel(panel,q = True,ctl = True):
				panel = 'viewPanes'
			
		sel = search.selectCheck()
		
		IsClickedOptionVar.set(0)
		mmActionOptionVar.set(0)
		
		if mc.popupMenu('cgmMM',ex = True):
			mc.deleteUI('cgmMM')
			
		if panel:
			if mc.control(panel, ex = True):
				try:
					mc.popupMenu('cgmMM', ctl = 0, alt = 0, sh = 0, mm = 1, b =1, aob = 1, p = panel,
						         pmc = lambda *a: self.createUI('cgmMM'))
				except:
					guiFactory.warning('Exception on set key marking menu')
					mel.eval('performSetKeyframeArgList 1 {"0", "animationList"};')		
Esempio n. 4
0
	def __init__(self):	
		"""
		Initializes the pop up menu class call
		"""
		self.optionVars = []		
		self.IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked','int',0)
		self.mmActionOptionVar = OptionVarFactory('cgmVar_mmAction','int',0)
		
		self.setupVariables()
		
		panel = mc.getPanel(up = True)
		if panel:
			# Attempt at fixing a bug of some tools not working when the pop up parent isn't 'viewPanes'
			if 'MayaWindow' in mc.panel(panel,q = True,ctl = True):
				panel = 'viewPanes'
			
		sel = search.selectCheck()
		
		self.IsClickedOptionVar.set(0)
		self.mmActionOptionVar.set(0)
		
		if mc.popupMenu('cgmMM',ex = True):
			mc.deleteUI('cgmMM')
			
		if panel:
			if mc.control(panel, ex = True):
				try:
					mc.popupMenu('cgmMM', ctl = 0, alt = 0, sh = 0, mm = 1, b =1, aob = 1, p = panel,
						         pmc = lambda *a: self.createUI('cgmMM'))
				except:
					guiFactory.warning('cgm.setMenu failed!')		
Esempio n. 5
0
def era_ScenePanel(delPanel = 0):
    defaultPanel = 'modelPanel4'
    currentPanel = mc.getPanel(wf = True)
    panels = mc.getPanel(vis = True)
    if 'scriptEditorPanel1' in panels:
        panels.remove('scriptEditorPanel1')
    if panels != [defaultPanel]:
        if delPanel:
            if defaultPanel in panels:
                panels.remove(defaultPanel)
                mc.deleteUI(panels)
            else:
                if not len(panels)==1:
                    mc.deleteUI(panels[1:])
                mc.panel(defaultPanel,e = True,rp = panels[0])
        else:
            return era_SplitFlag().join(panels)
Esempio n. 6
0
def getPoseEditorWidget():
    """
    For getting the qt widget of the Pose Editor.
    MEL file that handles building and showing the editor.
    C:\Program Files\Autodesk\Maya2018\scripts\others\createPosePanelMenu.mel
    :return:
    """
    panelName = 'posePanel1'
    poseEditorPanel = mc.panel(panelName, q=1, control=1)
Esempio n. 7
0
def getParentPanel():
    """return the parent panel """
    upPanel = cmds.getPanel(up=True)
    if cmds.panel(upPanel, q=True, ex=True):
        upPanelLayout = cmds.layout(upPanel, q=True, p=True)
        while not cmds.paneLayout(upPanelLayout, q=True, ex=True):
            upPanelLayout = cmds.control(upPanelLayout, q=True, p=True)
        if cmds.paneLayout(upPanelLayout, q=True, ex=True):
            return upPanelLayout
    else:
        return "viewPanes"
Esempio n. 8
0
def get_parent_panel():
    """
    Return current panels parent.
    """
    panel = cmds.getPanel(up=True)
    if cmds.panel(panel, q=True, ex=True):
        panel_layout = cmds.layout(panel, q=True, p=True)
        while not cmds.paneLayout(panel_layout, q=True, ex=True):
            panel_layout = cmds.control(panel_layout, q=True, p=True)
        if cmds.paneLayout(panel_layout, q=True, ex=True):
            return panel_layout
        else:
            return 'viewPanes'
Esempio n. 9
0
def get_parent_panel():
    """
    Return current panels parent.
    """
    panel = cmds.getPanel(up=True)
    if cmds.panel(panel, q=True, ex=True):
        panel_layout = cmds.layout(panel, q=True, p=True)
        while not cmds.paneLayout(panel_layout, q=True, ex=True):
            panel_layout = cmds.control(panel_layout, q=True, p=True)
        if cmds.paneLayout(panel_layout, q=True, ex=True):
            return panel_layout
        else:
            return 'viewPanes'
Esempio n. 10
0
 def __handleUIClosed(self, *args):
     self.__isolateSelectedInViewport(0)
     
     if cmds.panel(self.viewport, exists=True):
         cmds.deleteUI(self.viewport, pnl=True)   
     
     cmds.lockNode(self.grp, l=False)
     cmds.delete(self.grp)
     
     try:
         cmds.namespace(rm=self.ns)
     except:
         mel.eval('''warning "Could not cleanup namespace '%s' when closing window"''' % self.ns)
     
     OpenMaya.MMessage.removeCallback(self.__uiCallback)
Esempio n. 11
0
def getRvStatus():
    # has the renderview been opened already?
    if cmds.layout('editorForm', q=1, ex=1):

        ## is it in a window or in a panel??
        rView = 'renderView'

        if rView in cmds.getPanel(vis=1):
            if cmds.panel(rView, q=1, to=1):
                # 'it is in a window!'
                cmds.deleteUI('renderViewWindow', wnd=1)
            else:
                #'is in a panel'

                rvv = cmds.getPanel(sty='renderWindowPanel')
                visibleModelPanels = []
                camerasVisible = []
                allCameras = []
                possibleCams = []

                for i in cmds.ls(ca=1):
                    allCameras.append(cmds.listRelatives(i, p=1)[0])

                for i in cmds.getPanel(vis=1):
                    if i in cmds.getPanel(typ="modelPanel"):
                        visibleModelPanels.append(i)

                for i in visibleModelPanels:
                    camerasVisible.append(cmds.modelPanel(i, q=True, cam=True))

                for i in allCameras:
                    if i not in camerasVisible:
                        possibleCams.append(i)

                if possibleCams >= 1:
                    mel.eval('lookThroughModelPanel ' + str(possibleCams[0]) +
                             ' ' + str(rvv[0]) + ';')
                #else:

                cmds.scriptedPanel('renderView', e=1, up=1)
                cmds.scriptedPanel('renderView', q=1, ctl=1)
        else:

            cmds.scriptedPanel('renderView', e=1, up=1)
            cmds.scriptedPanel('renderView', q=1, ctl=1)

    else:
        return False
Esempio n. 12
0
	def __init__(self):	
		"""
		Initializes the pop up menu class call
		"""
		self._str_MM = 'snapMarkingMenu'
		self.optionVars = []
		self.toolName = 'cgm.snapMM'
		IsClickedOptionVar = cgmMeta.cgmOptionVar('cgmVar_IsClicked', 'int')
		mmActionOptionVar = cgmMeta.cgmOptionVar('cgmVar_mmAction', 'int')	
		surfaceSnapAimModeVar = cgmMeta.cgmOptionVar('cgmVar_SurfaceSnapAimMode', 'int')	
		UpdateRotateOrderOnTagVar = cgmMeta.cgmOptionVar('cgmVar_TaggingUpdateRO', 'int')	
		self.LocinatorUpdateObjectsBufferOptionVar = cgmMeta.cgmOptionVar('cgmVar_LocinatorUpdateObjectsBuffer',defaultValue = [''])
		
		self.LocinatorUpdateObjectsOptionVar = cgmMeta.cgmOptionVar('cgmVar_SnapMMUpdateMode',defaultValue = 0)
		guiFactory.appendOptionVarList(self,self.LocinatorUpdateObjectsOptionVar.name)
		
		self.SnapModeOptionVar = cgmMeta.cgmOptionVar('cgmVar_SnapMatchMode',defaultValue = 0)
		guiFactory.appendOptionVarList(self,self.SnapModeOptionVar.name)
						
		IsClickedOptionVar.setValue(0)
		mmActionOptionVar.setValue(0)
		
		#if mc.popupMenu('cgmMM',ex = True):
			#mc.deleteUI('cgmMM')#...deleting ui elements seems to be hard crashing maya 2017
			
		
		_p = mc.getPanel(up = True)
		if _p is None:
			log.error("No panel detected...")
			return 
		if _p:
			log.info("{0} panel under pointer {1}...".format(self._str_MM, _p))                    
			_parentPanel = mc.panel(_p,q = True,ctl = True)
			log.info("{0} panel under pointer {1} | parent: {2}...".format(self._str_MM, _p,_parentPanel))
			if 'MayaWindow' in _parentPanel:
				_p = 'viewPanes' 
		if not mc.control(_p, ex = True):
			raise ValueError,"{0} doesn't exist!".format(_p)
			#_p = panel
		if not mc.popupMenu('cgmMM',ex = True):
			mc.popupMenu('cgmMM', ctl = 0, alt = 0, sh = 0, mm = 1, b =1, aob = 1, p = _p,
			             pmc = lambda *a: self.createUI('cgmMM'), postMenuCommandOnce = True)
		else:
			mc.popupMenu('cgmMM', edit = True, ctl = 0, alt = 0, sh = 0, mm = 1, b =1, aob = 1, p = _p,
			              pmc = lambda *a: self.createUI('cgmMM'), postMenuCommandOnce = True)
Esempio n. 13
0
    def __init__(self):	
        """
        Initializes the pop up menu class call
        """
        self._str_MM = 'snapMarkingMenu'        
        self.optionVars = []
        IsClickedOptionVar = cgmMeta.cgmOptionVar('cgmVar_IsClicked', value = 0)
        mmActionOptionVar = cgmMeta.cgmOptionVar('cgmVar_mmAction',value = 0)			


        #>>>> Clock set
        #====================================================================
        self.clockStartVar = cgmMeta.cgmOptionVar('cgmVar_PuppetKeyClockStart', defaultValue = 0.0)	
        self.clockStartVar.value = time.clock()
        log.debug("cgmPuppetKey.clockStart: %s"%self.clockStartVar.value)

        IsClickedOptionVar.value = 0
        mmActionOptionVar.value = 0
        
        

        try:#>> Panel check and build...
            _sub = "Panel check and build"
            _p = mc.getPanel(up = True)
            if _p is None:
                log.error("No panel detected...")
                return 
            if _p:
                log.info("{0} panel under pointer {1}...".format(self._str_MM, _p))                    
                _parentPanel = mc.panel(_p,q = True,ctl = True)
                log.info("{0} panel under pointer {1} | parent: {2}...".format(self._str_MM, _p,_parentPanel))
                if 'MayaWindow' in _parentPanel:
                    _p = 'viewPanes'     
            if not mc.control(_p, ex = True):
                return "{0} doesn't exist!".format(_p)
            else:
                if not mc.popupMenu('cgmMM',ex = True):
                    mc.popupMenu('cgmMM', ctl = 0, alt = 0, sh = 0, mm = 1, b =1, aob = 1, p = _p,
                                 pmc = mUI.Callback(self.createUI,'cgmMM'))
                else:
                    mc.popupMenu('cgmMM', edit = True, ctl = 0, alt = 0, sh = 0, mm = 1, b =1, aob = 1, p = _p,
                                 pmc = mUI.Callback(self.createUI,'cgmMM'))
        except Exception,err:
            raise Exception,"{0} {1} exception | {2}".format(self._str_MM,_sub,err)
Esempio n. 14
0
    def __init__(self):	
        """
        Initializes the pop up menu class call
        """
        self._str_funcName = "puppetKeyMarkingMenu"
        self.optionVars = []
        IsClickedOptionVar = cgmMeta.cgmOptionVar('cgmVar_IsClicked', value = 0)
        mmActionOptionVar = cgmMeta.cgmOptionVar('cgmVar_mmAction',value = 0)			

        panel = mc.getPanel(up = True)
        if panel:
            # Attempt at fixing a bug of some tools not working when the pop up parent isn't 'viewPanes'
            if 'MayaWindow' in mc.panel(panel,q = True,ctl = True):
                panel = 'viewPanes'

        sel = search.selectCheck()

        #>>>> Clock set
        #====================================================================
        self.clockStartVar = cgmMeta.cgmOptionVar('cgmVar_PuppetKeyClockStart', defaultValue = 0.0)	
        self.clockStartVar.value = time.clock()
        log.debug("cgmPuppetKey.clockStart: %s"%self.clockStartVar.value)

        IsClickedOptionVar.value = 0
        mmActionOptionVar.value = 0

        if mc.popupMenu('cgmMM',ex = True):
            mc.deleteUI('cgmMM')

        if panel:
            if mc.control(panel, ex = True):
                try:
                    mc.popupMenu('cgmMM', ctl = 0, alt = 0, sh = 0, mm = 1, b =1, aob = 1, p = panel,
                                 pmc = lambda *a: self.createUI('cgmMM'))
                except:
                    log.warning('Exception on set key marking menu')
                    mel.eval('performSetKeyframeArgList 1 {"0", "animationList"};')		
Esempio n. 15
0
    def __init__(self):	
	"""
	Initializes the pop up menu class call
	"""
	self.optionVars = []
	IsClickedOptionVar = cgmMeta.cgmOptionVar('cgmVar_IsClicked', value = 0)
	mmActionOptionVar = cgmMeta.cgmOptionVar('cgmVar_mmAction',value = 0)			

	panel = mc.getPanel(up = True)
	if panel:
	    # Attempt at fixing a bug of some tools not working when the pop up parent isn't 'viewPanes'
	    if 'MayaWindow' in mc.panel(panel,q = True,ctl = True):
		panel = 'viewPanes'

	sel = search.selectCheck()
	
	#>>>> Clock set
	#====================================================================
	self.clockStartVar = cgmMeta.cgmOptionVar('cgmVar_PuppetKeyClockStart', defaultValue = 0.0)	
	self.clockStartVar.value = time.clock()
	log.debug("cgmPuppetKey.clockStart: %s"%self.clockStartVar.value)
	
	IsClickedOptionVar.value = 0
	mmActionOptionVar.value = 0

	if mc.popupMenu('cgmMM',ex = True):
	    mc.deleteUI('cgmMM')

	if panel:
	    if mc.control(panel, ex = True):
		try:
		    mc.popupMenu('cgmMM', ctl = 0, alt = 0, sh = 0, mm = 1, b =1, aob = 1, p = panel,
		                 pmc = lambda *a: self.createUI('cgmMM'))
		except:
		    log.warning('Exception on set key marking menu')
		    mel.eval('performSetKeyframeArgList 1 {"0", "animationList"};')		
Esempio n. 16
0
def clear_panels():
    '''Description: Removes all panels and resets to default panels.
       Input: None
       Return: None'''
    default_panels = {
        'modelPanel1': 'Top View',
        'modelPanel2': 'Side View',
        'modelPanel3': 'Front View',
        'modelPanel4': 'Persp View',
        'outlinerPanel1': 'Outliner',
        'graphEditor1': 'Graph Editor',
        'dopeSheetPanel1': 'Dope Sheet',
        'clipEditorPanel1': 'Trax Editor',
        'sequenceEditorPanel1': 'Camera Sequencer',
        'hyperGraphPanel1': 'Hypergraph Hierarchy',
        'hyperShadePanel1': 'Hypershade',
        'visorPanel1': 'Visor',
        'nodeEditorPanel1': 'Node Editor',
        'createNodePanel1': 'Create Node',
        'polyTexturePlacementPanel1': 'UV Texture Editor',
        'renderView': 'Render View',
        'blendShapePanel1': 'Blend Shape',
        'dynRelEdPanel1': 'Dynamic Relationships Editor',
        'relationshipPanel1': 'Relationship Editor',
        'referenceEditorPanel1': 'Reference Editor',
        'componentEditorPanel1': 'Component Editor',
        'dynPaintScriptedPanel': 'Paint Effects',
        'scriptEditorPanel1': 'Script Editor'
    }
    default_layouts = set([
        'hyperGraphInfo', 'hyperGraphLayout', 'hyperView1', 'hyperLayout1',
        'nodeEditorPanel1Info'
    ])

    dagContainers = cmds.ls(type='dagContainer')
    for dc in dagContainers:
        hl = cmds.listConnections('%s.hyperLayout' % dc)
        if hl:
            if not hl[0] == ('%s_hyperLayout' % dc):
                hl[0] = cmds.rename(hl[0], '%s_hyperLayout' % dc)
            default_layouts.add(hl[0])

    p_names = set(default_panels.keys())
    panels = set(cmds.getPanel(allPanels=True))
    panels = list(panels.difference(p_names))
    p_num = 0
    for panel in panels:
        cmds.deleteUI(panel, panel=True)
        p_num += 1

    layouts = set(cmds.ls(type=['hyperView', 'hyperLayout', 'hyperGraphInfo']))

    layouts = list(layouts.difference(default_layouts))
    l_num = 0
    for layout in layouts:
        try:
            cmds.delete(layout)
        except:
            pass
        finally:
            l_num += 1

    print '%i panels / %i layouts deleted' % (p_num, l_num)

    #Rebuild model panels if missing
    model_panels = ['modelPanel1', 'modelPanel2', 'modelPanel3', 'modelPanel4']
    gMainPane = mel.eval('global string $gMainPane; $temp = $gMainPane;')
    for m_panel in model_panels:
        if not cmds.modelPanel(m_panel, exists=True):
            cmds.modelPanel(m_panel, parent=gMainPane)

    for name, label in default_panels.items():
        try:
            cmds.panel(name, e=True, label=label)
        except:
            pass

    mel.eval('lookThroughModelPanel top modelPanel1')
    mel.eval('lookThroughModelPanel side modelPanel2')
    mel.eval('lookThroughModelPanel front modelPanel3')
    mel.eval('lookThroughModelPanel persp modelPanel4')
    mel.eval('setNamedPanelLayout "Single Perspective View"')
    return
Esempio n. 17
0
    def __init__(self):
        """
		Initializes the pop up menu class call
		"""
        self._str_MM = 'snapMarkingMenu'
        self.optionVars = []
        self.toolName = 'cgm.snapMM'
        IsClickedOptionVar = cgmMeta.cgmOptionVar('cgmVar_IsClicked', 'int')
        mmActionOptionVar = cgmMeta.cgmOptionVar('cgmVar_mmAction', 'int')
        surfaceSnapAimModeVar = cgmMeta.cgmOptionVar(
            'cgmVar_SurfaceSnapAimMode', 'int')
        UpdateRotateOrderOnTagVar = cgmMeta.cgmOptionVar(
            'cgmVar_TaggingUpdateRO', 'int')
        self.LocinatorUpdateObjectsBufferOptionVar = cgmMeta.cgmOptionVar(
            'cgmVar_LocinatorUpdateObjectsBuffer', defaultValue=[''])

        self.LocinatorUpdateObjectsOptionVar = cgmMeta.cgmOptionVar(
            'cgmVar_SnapMMUpdateMode', defaultValue=0)
        guiFactory.appendOptionVarList(
            self, self.LocinatorUpdateObjectsOptionVar.name)

        self.SnapModeOptionVar = cgmMeta.cgmOptionVar('cgmVar_SnapMatchMode',
                                                      defaultValue=0)
        guiFactory.appendOptionVarList(self, self.SnapModeOptionVar.name)

        IsClickedOptionVar.setValue(0)
        mmActionOptionVar.setValue(0)

        #if mc.popupMenu('cgmMM',ex = True):
        #mc.deleteUI('cgmMM')#...deleting ui elements seems to be hard crashing maya 2017

        _p = mc.getPanel(up=True)
        if _p is None:
            log.error("No panel detected...")
            return
        if _p:
            log.info("{0} panel under pointer {1}...".format(self._str_MM, _p))
            _parentPanel = mc.panel(_p, q=True, ctl=True)
            log.info("{0} panel under pointer {1} | parent: {2}...".format(
                self._str_MM, _p, _parentPanel))
            if 'MayaWindow' in _parentPanel:
                _p = 'viewPanes'
        if not mc.control(_p, ex=True):
            raise ValueError, "{0} doesn't exist!".format(_p)
            #_p = panel
        if not mc.popupMenu('cgmMM', ex=True):
            mc.popupMenu('cgmMM',
                         ctl=0,
                         alt=0,
                         sh=0,
                         mm=1,
                         b=1,
                         aob=1,
                         p=_p,
                         pmc=lambda *a: self.createUI('cgmMM'),
                         postMenuCommandOnce=True)
        else:
            mc.popupMenu('cgmMM',
                         edit=True,
                         ctl=0,
                         alt=0,
                         sh=0,
                         mm=1,
                         b=1,
                         aob=1,
                         p=_p,
                         pmc=lambda *a: self.createUI('cgmMM'),
                         postMenuCommandOnce=True)
Esempio n. 18
0
    def process(self, context):
        """Extracting a playblast is quite involved.

        Step one is finding an appropriate panel to playblast from.
        The panel must be a valid "modelPanel", which means a 3d view.
        We modify the current camera of this panel to the one specified
        in our pyblish, and then trigger a playblast. The next step is
        restoring the previous panels and cameras so as to make the pyblish
        as transparent to the end-user as possible.

        ..note:: At the moment, if there is no active modelPanel,
            the pyblish fails.

        """

        self.log.info("Extracting playblast")

        temp_dir = tempfile.mkdtemp()

        compatible_instances = list(pyblish.backend.plugin.instances_by_plugin(
            instances=context, plugin=self))

        # Get cameras
        cameras = list()
        for instance in compatible_instances:
            for node in instance:
                if cmds.nodeType(node) == 'camera':
                    cameras.append(node)

        if not cameras:
            self.log.info("No cameras found..")
            raise ValueError("No cameras found for Review '{0}'".format(
                self.instances.name))

        # Setup panel
        previous_panel = cmds.getPanel(withFocus=True)

        # If we're taking over a model panel, ensure we also
        # restore the camera which was used at the time of pyblish.
        if previous_panel in cmds.getPanel(type='modelPanel'):
            previous_camera = cmds.modelPanel(previous_panel,
                                              query=True,
                                              camera=True)
        else:
            previous_camera = None

        playblast_panel = cmds.getPanel(withLabel='Persp View')
        cmds.panel(previous_panel, edit=True, replacePanel=playblast_panel)

        # Establish configuration
        for instance in compatible_instances:

            config = instance.config

            min_time = cmds.playbackOptions(minTime=True, query=True)
            max_time = cmds.playbackOptions(maxTime=True, query=True)
            default_width = cmds.getAttr('defaultResolution.width')
            default_height = cmds.getAttr('defaultResolution.height')

            playblast_kwargs = {
                'percent': 100,
                'quality': 100,
                'offScreen': True,
                'viewer': False,
                'startTime': config.get('startFrame', min_time),
                'endTime': config.get('endFrame', max_time),
                'format': config.get('format', 'image'),
                'width': config.get('width', default_width),
                'height': config.get('height', default_height),
                'compression': config.get('compression', 'png')
            }

            self.log.info("Configuration: {0}".format(playblast_kwargs))

            # Make one playblast per included camera
            try:
                for camera in cameras:
                    self.log.info("Playblasting {camera}".format(
                        camera=camera))
                    cmds.lookThru(playblast_panel, camera)

                    cmds.isolateSelect(playblast_panel, state=True)

                    for obj in instance:
                        cmds.isolateSelect(playblast_panel, addDagObject=obj)

                    temp_file = os.path.join(temp_dir, camera, camera)
                    playblast_kwargs['filename'] = temp_file

                    self.log.info("Running playblast..")
                    cmds.playblast(**playblast_kwargs)  # Do not open player
                    self.log.info("Completed at {0}".format(temp_file))

            finally:
                # No matter what happens, always restore panels
                cmds.refresh(suspend=True)

                self.log.info("Restoring panels")
                cmds.isolateSelect(playblast_panel, state=False)

                if previous_camera:
                    cmds.lookThru(playblast_panel, previous_camera)

                cmds.panel(playblast_panel,
                           edit=True,
                           replacePanel=previous_panel)
                cmds.refresh(suspend=False)

            # Move temporary files to directory relative the
            # current working file.
            family = instance.config.get('family')

            self.commit(temp_dir, family=family)
            self.log.info("_extract_model: Clearing local cache..")
            shutil.rmtree(temp_dir)

            yield instance, None
Esempio n. 19
0
def object_view_menu(*args):
    if not cmds.ls( sl=True ):
        print 'Nothing is selected'
    else:
        first_selected_node = cmds.ls(sl=True)[0]

        cmds.select(clear=True)

        all_model_panels = cmds.getPanel(type='modelPanel')
        m_panel_list =[]
        for o_panel in all_model_panels:
            o_label = cmds.panel(o_panel, q=True, label=True)
            if "CustomObjectViewer" in o_label:
                m_panel_list.append(o_panel) 

        invis_panel_list = cmds.getPanel(invisiblePanels=True)

        for d_panel in m_panel_list:
            if d_panel in invis_panel_list:
                cmds.deleteUI(d_panel,panel=True)

        cmds.select(clear=True)
        mel.eval('CreateCameraAimUp;')
        aimup_list = cmds.ls( sl=True )
        cmds.select(clear=True)

        for n_camdata in aimup_list:
            cmds.select(n_camdata,r=True)
            n_dataShape = cmds.listRelatives(n_camdata, children=True)[0]
            n_cam_type = cmds.objectType(n_dataShape)
            if n_cam_type == 'camera':
                n_number = n_camdata[len('camera'):]
                cmds.setAttr( n_dataShape + '.nearClipPlane', 10 )
                cmds.setAttr( n_camdata + '.translateZ', 30)
                o_cam = n_camdata
            if '_aim' in n_camdata:
                cmds.setAttr( n_camdata + '.translateX', 0)
                cmds.setAttr( n_camdata + '.translateY', 0)                
                cmds.setAttr( n_camdata + '.translateZ', 0)
            cmds.select(clear=True)

        o_pregrp = cmds.listRelatives(o_cam,parent=True )[0]
        cmds.select(o_pregrp,r=True)
        o_grp = cmds.rename('ObjectViewCamera_group' + n_number )
        cmds.parent(o_grp, first_selected_node, relative=True )


        cmds.select(clear=True)
        cmds.select(o_grp,r=True)
        pre_parent = cmds.listRelatives(o_grp,parent=True )[0]
        cmds.parent(o_grp,world=True)
        const_node = cmds.parentConstraint(pre_parent,o_grp,maintainOffset=True)[0]
        cmds.select(clear=True)

        try:
            cmds.window()
            window = cmds.window('CustomObjectViewer' + n_number, 
                title='Custom ObjectViewer' + n_number, sizeable=True, 
                topLeftCorner=[200, 200], widthHeight=(400,470))
            form = cmds.formLayout()
            c_model= cmds.modelPanel(label='CustomObjectViewer_Panel' + n_number, camera=o_cam)
        except:
            print 'Check Panel Editor & CleanUp Unused Panels !!'

        cmds.setParent('..')
        column = cmds.columnLayout()
        cmds.rowLayout(numberOfColumns=2)
        cmds.floatSliderGrp(label=' Far ClipPlane ',field=True,columnWidth3=[85,40,70],
            adjustableColumn=3, minValue=0.1, maxValue=100,fieldMinValue=0.1,
            fieldMaxValue=100, value=70,
            dragCommand=lambda x:cam_far_slider(x,o_cam),
            changeCommand=lambda x:cam_far_slider(x,o_cam))
        cmds.floatSliderGrp(label='NearClipPlane ',field=True,columnWidth3=[85,40,70],
            adjustableColumn=3, minValue=0.01, maxValue=100,fieldMinValue=0.01,
            fieldMaxValue=100, value=10,
            dragCommand=lambda x:cam_near_slider(x,o_cam),
            changeCommand=lambda x:cam_near_slider(x,o_cam))
        cmds.setParent('..')

        cmds.rowLayout(numberOfColumns=3)
        cmds.floatSliderGrp(label='Trans Offset X',field=True,columnWidth3=[85,40,50],
            adjustableColumn=3, minValue=-100, maxValue=100,fieldMinValue=-100,
            fieldMaxValue=100, value=0,
            dragCommand=lambda x:cam_txoffset_slider(x,const_node),
            changeCommand=lambda x:cam_txoffset_slider(x,const_node))
        cmds.floatSliderGrp(label='Y',field=True,columnWidth3=[10,40,50],
            adjustableColumn=3, minValue=-100, maxValue=100,fieldMinValue=-100,
            fieldMaxValue=100, value=0,
            dragCommand=lambda x:cam_tyoffset_slider(x,const_node),
            changeCommand=lambda x:cam_tyoffset_slider(x,const_node))
        cmds.floatSliderGrp(label='Z',field=True,columnWidth3=[10,40,50],
            adjustableColumn=3, minValue=-100, maxValue=100,fieldMinValue=-100,
            fieldMaxValue=100, value=0,
            dragCommand=lambda x:cam_tzoffset_slider(x,const_node),
            changeCommand=lambda x:cam_tzoffset_slider(x,const_node))
        cmds.setParent('..')

        cmds.rowLayout(numberOfColumns=3)
        cmds.floatSliderGrp(label='RotateOffset X',field=True,columnWidth3=[85,40,50],
            adjustableColumn=3, minValue=0, maxValue=360,fieldMinValue=0,
            fieldMaxValue=360, value=0,
            dragCommand=lambda x:cam_rxoffset_slider(x,const_node),
            changeCommand=lambda x:cam_rxoffset_slider(x,const_node))
        cmds.floatSliderGrp(label='Y',field=True,columnWidth3=[10,40,50],
            adjustableColumn=3, minValue=0, maxValue=360,fieldMinValue=0,
            fieldMaxValue=360, value=0,
            dragCommand=lambda x:cam_ryoffset_slider(x,const_node),
            changeCommand=lambda x:cam_ryoffset_slider(x,const_node))
        cmds.floatSliderGrp(label='Z',field=True,columnWidth3=[10,40,50],
            adjustableColumn=3, minValue=0, maxValue=360,fieldMinValue=0,
            fieldMaxValue=360, value=0,
            dragCommand=lambda x:cam_rzoffset_slider(x,const_node),
            changeCommand=lambda x:cam_rzoffset_slider(x,const_node))
        cmds.setParent('..')


        cmds.formLayout(form,edit=True,
             attachForm=[
                  (c_model,'left',5),(c_model,'top',0),(c_model,'right',5),(c_model,'bottom',80),
                  (column,'left',5),(column,'top',400),(column,'right',0),(column,'bottom',0)
                  ],
             attachPosition=[(column,'right',0,100)],
             attachNone=[(column,'top')]
             )
        cmds.modelEditor(c_model,edit=True,grid=False,
            displayAppearance='smoothShaded',activeOnly=False, displayTextures=True )
        cmds.showWindow( window )
Esempio n. 20
0
    def __init__(self):
        """
        Initializes the pop up menu class call
        """

        self._str_MM = type(self).__name__
        log.debug(">>> %s " % (self._str_MM) + "=" * 75)
        self.l_optionVars = []
        self.create_guiOptionVar('isClicked', value=0)
        self.create_guiOptionVar('mmAction', value=0)
        self.create_guiOptionVar('clockStart', value=0.0)

        #>>>> Clock set
        #====================================================================

        self.var_clockStart.value = time.clock()
        #log.info("{0} >> clockStart: {1}".format(self._str_MM,self.clockStartVar.value))

        self.var_isClicked.value = 0
        self.var_mmAction.value = 0

        #try:#>> Panel check and build...
        _sub = "Panel check and build"
        log.debug(mc.getPanel(withFocus=True))
        _p = mc.getPanel(up=True)
        if _p is None:
            log.debug("No panel detected...")
            return
        if _p:
            log.debug("...panel under pointer {1}...".format(self._str_MM, _p))
            _parentPanel = mc.panel(_p, q=True, ctl=True)
            log.debug("...panel parent: {1}...".format(self._str_MM,
                                                       _parentPanel))
            if 'MayaWindow' in _parentPanel:
                _p = 'viewPanes'
        if not mc.control(_p, ex=True):
            return "{0} doesn't exist!".format(_p)
        else:
            #_pmc = mUI.Callback(self.createUI,self.__class__.POPWINDOW)
            if not mc.popupMenu('cgmMM', ex=True):
                mc.popupMenu(
                    'cgmMM',
                    ctl=0,
                    alt=0,
                    sh=0,
                    pmc=lambda *a: self.createUI('cgmMM'),
                    mm=self.__class__.MM,
                    b=1,
                    aob=1,
                    p=_p,
                    postMenuCommandOnce=True)  #postMenuCommandOnce=True
            else:
                mc.popupMenu('cgmMM',
                             edit=True,
                             ctl=0,
                             alt=0,
                             sh=0,
                             pmc=lambda *a: self.createUI('cgmMM'),
                             mm=self.__class__.MM,
                             b=1,
                             aob=1,
                             p=_p,
                             dai=True,
                             postMenuCommandOnce=True)
Esempio n. 21
0
def test():
	####################
	#                  #
	#     CleanUp      #
	#                  #
	####################
	if cmds.window(WINDOW_NAME, exists=True):
		cmds.deleteUI(WINDOW_NAME)

	for pan in cmds.lsUI(panels=True):
		if cmds.panel(pan, q=True, label=True).startswith("vuRenderTree_"):
			print "Delte: " + pan
			cmds.deleteUI(pan, panel=True)





	cmds.window(WINDOW_NAME)
	main = cmds.paneLayout(configuration='vertical3')


	####################
	#                  #
	#   Frame Left     #
	#                  #
	####################
	paneLeft = cmds.paneLayout(configuration='horizontal2', p=main)

	cmds.frameLayout(label="ShadingNodes:", li=3, borderVisible=False, p=paneLeft)
	cmds.nodeTreeLister('theTreeLister', expandToDepth=1, addItem=shaders)

	# Textures
	cmds.frameLayout(label="Textures:", li=3, borderVisible=False, p=paneLeft)
	panel = cmds.outlinerPanel(label="vuRenderTree_Outliner", menuBarVisible=False)
	outlinerEditor = cmds.outlinerPanel(panel, query=True,outlinerEditor=True)

	filterTextures = cmds.createNode("objectRenderFilter")
	cmds.setAttr(filterTextures + ".textures", True)
	cmds.outlinerEditor( outlinerEditor, edit=True, showDagOnly=False, filter=filterTextures)



#
#				ToDo Later:
#
#########################################################################
#																		#
#																		#
#		filterKeyable = cmds.createNode("objectAttrFilter")				#
#		cmds.setAttr(filterKeyable + ".attrType ", 3)					#
#																		#
#																		#
#########################################################################
#
#
#



	####################
	#                  #
	#   Node Editor    #
	#                  #
	####################
	# formNodes = cmds.formLayout(p=main)


	# nEdit = cmds.scriptedPanel(type="nodeEditorPanel", label="Node Editor")
	# #cmds.formLayout(formNodes, e=True, af=[(centershelf,s,0) for s in ("top","left","right")])
	# cmds.formLayout(formNodes, e=True, af=[(nEdit,s,0) for s in ("top", "bottom","left","right")])

	formNodes = cmds.formLayout(p=main)

	nEdit = cmds.scriptedPanel(type="nodeEditorPanel", label="vuRenderTree_NodeEditor")
	centershelf = cmds.shelfLayout("vuRenderUtils", p=formNodes)
	#cmds.formLayout(formNodes, e=True, af=[(centershelf,s,0) for s in ("top","left","right")])
	#cmds.formLayout(formNodes, e=True, af=[(nEdit,s,0) for s in ("bottom","left","right")])

	cmds.formLayout(formNodes, e=True,
		attachForm=[
				(centershelf,"top",0), (centershelf,"left",0), (centershelf,"right",0),
				(nEdit,"bottom",0), (nEdit,"left",0), (nEdit,"right",0)
				],
		attachControl=[
				(nEdit, "top", 0, centershelf)
				])



	####################
	#                  #
	#   Frame Right    #
	#                  #
	####################
	paneRight = cmds.paneLayout( configuration='horizontal3', p=main)

	# Shading Groups
	#rightTabs = cmds.tabLayout()

	cmds.frameLayout(label="ShadingGroups:", li=3, borderVisible=False, p=paneRight)
	outlinerShadingGroups = cmds.outlinerPanel(label="vuRenderTree_Outliner", menuBarVisible=False)
	outlinerEditor = cmds.outlinerPanel(outlinerShadingGroups, query=True,outlinerEditor=True)
	filterShadingGroups = cmds.createNode("objectTypeFilter")
	cmds.setAttr(filterShadingGroups + ".typeName",  "shadingEngine", type="string")
	cmds.outlinerEditor( outlinerEditor, edit=True, showDagOnly=False, filter=filterShadingGroups)

	# Shaders
	cmds.frameLayout(label="Shaders:", li=3, borderVisible=False, p=paneRight)
	outlinerShaders = cmds.outlinerPanel(label="vuRenderTree_Outliner", menuBarVisible=False)
	outlinerEditor = cmds.outlinerPanel(outlinerShaders, query=True,outlinerEditor=True)
	filterShaders = cmds.createNode("objectRenderFilter")
	cmds.setAttr(filterShaders + ".shaders", True)
	cmds.outlinerEditor( outlinerEditor, edit=True, showDagOnly=False, filter=filterShaders)

	#cmds.tabLayout( rightTabs, edit=True, tabLabel=((outlinerShadingGroups, 'ShadingGroups'), (outlinerShaders, 'Shaders')))

	# Outliner
	cmds.frameLayout(label="Outliner:", li=3, borderVisible=False, p=paneRight)
	cmds.outlinerPanel(label="vuRenderTree_Outliner", menuBarVisible=True)



	cmds.showWindow()
Esempio n. 22
0
def clear_panels():
   '''Description: Removes all panels and resets to default panels.
      Input: None
      Return: None'''
   default_panels = {'modelPanel1': 'Top View',
                     'modelPanel2': 'Side View',
                     'modelPanel3': 'Front View',
                     'modelPanel4': 'Persp View',
                     'outlinerPanel1': 'Outliner', 
                     'graphEditor1': 'Graph Editor',
                     'dopeSheetPanel1': 'Dope Sheet',
                     'clipEditorPanel1': 'Trax Editor',
                     'sequenceEditorPanel1': 'Camera Sequencer',
                     'hyperGraphPanel1': 'Hypergraph Hierarchy',
                     'hyperShadePanel1': 'Hypershade',
                     'visorPanel1': 'Visor',
                     'nodeEditorPanel1': 'Node Editor',
                     'createNodePanel1': 'Create Node',
                     'polyTexturePlacementPanel1': 'UV Texture Editor',
                     'renderView': 'Render View',
                     'blendShapePanel1': 'Blend Shape',
                     'dynRelEdPanel1': 'Dynamic Relationships Editor',
                     'relationshipPanel1': 'Relationship Editor',
                     'referenceEditorPanel1': 'Reference Editor',
                     'componentEditorPanel1': 'Component Editor',
                     'dynPaintScriptedPanel': 'Paint Effects',
                     'scriptEditorPanel1': 'Script Editor'}
   default_layouts = set(['hyperGraphInfo', 'hyperGraphLayout'])

   p_names = set(default_panels.keys())
   panels = set(cmds.getPanel(allPanels=True))
   panels = list(panels.difference(p_names))
   p_num = 0
   for panel in panels:
       cmds.deleteUI(panel, panel=True)
       p_num += 1
   
   layouts = set(cmds.ls(type=['hyperView', 'hyperLayout', 'hyperGraphInfo']))
   layouts = list(layouts.difference(default_layouts))
   l_num = 0
   for layout in layouts:
       try:
           cmds.delete(layout)
       except:
           pass
       finally:
           l_num += 1
       
   msg = '%i panels / %i layouts deleted' % (p_num, l_num)
   
   #Rebuild model panels if missing
   model_panels = ['modelPanel1','modelPanel2','modelPanel3','modelPanel4']
   gMainPane = mel.eval('global string $gMainPane; $temp = $gMainPane;')
   for m_panel in model_panels:
       if not cmds.modelPanel(m_panel, exists=True):
           cmds.modelPanel(m_panel, parent=gMainPane)
   
   for name, label in default_panels.items():
       try:
           cmds.panel(name, e=True, label=label)
       except:
           pass

   mel.eval('lookThroughModelPanel top modelPanel1')
   mel.eval('lookThroughModelPanel side modelPanel2')
   mel.eval('lookThroughModelPanel front modelPanel3')
   mel.eval('lookThroughModelPanel persp modelPanel4')
   mel.eval('setNamedPanelLayout "Single Perspective View"')
   return msg