Monday, December 17, 2012

Switch wireframe on shaded.

One more small script. Now to use shelf button to switch wireframe on shaded mode. Instead of Shading->Wireframe on shaded menu.
Usage:
- make new shelf button with script text (python command)
- press "5" to turn shaded view in current MAYA viewport
- press created shelf button
It turns on and off wireframe on objects in current viewport.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
'''
@author: Serge Scherbakov
Date: 25.07.2012
'''
import maya.cmds as cmds
 
def wireframeSwitcher():
    viewport = cmds.getPanel( withFocus = True)
    if 'modelPanel' in viewport:
        currentState = cmds.modelEditor( viewport, q = True, wireframeOnShaded = True)
        if currentState:
            cmds.modelEditor( viewport, edit = True, wireframeOnShaded = False)
        else:
            cmds.modelEditor( viewport, edit = True, wireframeOnShaded = True)
             
wireframeSwitcher()

2 comments:

  1. Thank you Serge! You can make the script shorter by setting the state to not(currentState) (if it's true; it'll be not true ie false and visa versa)

    ReplyDelete