Maya Viewport Display Toggles
Tool for toggling nurbsCurves, geometry, etc in the viewport.
How to Use
Download
https://eblabs.com/eblabs/wp-content/uploads/2013/04/ebLabs_displayToggle1.zip
Setup
Make sure to save this to your scripts folder as, “ebLabs_displayToggle.py”. Assign the following python code to a hotkey or shelf buttons:
For Nurbs Curves
from ebLabs_displayToggle import * ebLabs_displayToggle(nurbsCurves=True)
For Polygon Geometry
from ebLabs_displayToggle import * ebLabs_displayToggle(polyMesh=True)
For Locators
from ebLabs_displayToggle import * ebLabs_displayToggle(locators=True)
For Object Handle Display
from ebLabs_displayToggle import * ebLabs_displayToggle(enableHandles=True)
For Joints
from ebLabs_displayToggle import * ebLabs_displayToggle(joints=True)
Feedback
If you’d like to see any other object types added, just let me know.
Code
# eblabs displayToggle
# Eric Bates (c) 2013
# checkout eblabs.com for more cool stuff!
# v002
'''
from ebLabs_displayToggle import *
ebLabs_displayToggle(nurbsCurves=True)
ebLabs_displayToggle(locators=True)
ebLabs_displayToggle(polyMesh=True)
ebLabs_displayToggle(handles=True)
ebLabs_displayToggle(enableHandles=True)
ebLabs_displayToggle(joints=True)
'''
######################################################################################################
import maya.cmds as cmds
import maya.mel as mel
######################################################################################################
def ebLabs_displayToggle( **kwargs ):
#
nurbsCurves = False
if 'nurbsCurves' in kwargs:
nurbsCurves = kwargs.pop( 'nurbsCurves' )
locators = False
if 'locators' in kwargs:
locators = kwargs.pop( 'locators' )
polyMesh = False
if 'polyMesh' in kwargs:
polyMesh = kwargs.pop( 'polyMesh' )
handles = False
if 'handles' in kwargs:
handles = kwargs.pop( 'handles' )
enableHandles = False
if 'enableHandles' in kwargs:
enableHandles = kwargs.pop( 'enableHandles' )
joints = False
if 'joints' in kwargs:
joints = kwargs.pop( 'joints' )
# object related toggles
selected = cmds.ls( sl = True )
if enableHandles:
toggleState = cmds.getAttr( selected[0] + '.displayHandle' )
for s in selected:
cmds.setAttr( s + '.displayHandle', not toggleState )
# view related toggles
# if user is in a model panel, carry on
panel = cmds.getPanel( withFocus = True )
if cmds.getPanel( typeOf = panel ) == 'modelPanel':
# collect current UI toggle states
nurbsToggleState = cmds.modelEditor( panel, query = True, nurbsCurves = True )
locatorsToggleState = cmds.modelEditor( panel, query = True, locators = True )
polymeshesToggleState = cmds.modelEditor( panel, query = True, polymeshes = True )
handlesToggleState = cmds.modelEditor( panel, query = True, handles = True )
jointsToggleState = cmds.modelEditor( panel, query = True, joints = True )
# set toggles
if nurbsCurves:
cmds.modelEditor( panel, edit = True, nurbsCurves = ( not nurbsToggleState ) )
if locators:
cmds.modelEditor( panel, edit = True, locators = ( not locatorsToggleState ) )
if polyMesh:
cmds.modelEditor( panel, edit = True, polymeshes = ( not polymeshesToggleState ) )
if handles:
cmds.modelEditor( panel, edit = True, handles = ( not handlesToggleState ) )
if joints:
cmds.modelEditor( panel, edit = True, joints = ( not jointsToggleState ) )
Comments (13)
-
-
-
Eddie Chew
Amazing tools mate, I've added it into my workflow. Cheers.
-
Aly
Thank you so much!! Just what I was looking for :)
-
Benoit
Waw very nice and useful script. Only one thing is missing: a query mode. It could be a thing like ebLabs_displayToggle(nurbsCurves=True, query=True). Thanks again
-
Harrison
not sure where I did it wrong in 2017. I couldn't get it to work. there is no error when I try to run the script. it loads just nothing happens
-
Harrison
stupid me, I figured it out. it worked after I run it as a shelf button/hotkey, was trying to run it directly from the script editor. I guess it couldn't see which viewport I am selecting. thanks!
-
Harrison
not sure if I am asking for too much here, I know very little about scripting :( how much time will it take you if you could add a hide everything toggle and only the nurbs cruves, polygon/surface, ik handle, locator, image planes are on. you know the usual set up for animators. I am gonna try and see if I could modify it myself and see if I could get it to work, as well as create a separate window with buttons :P anyway, thanks for the script, really helpful already :)
-
Leave a Reply
You must be logged in to post a comment.



Grant
Handles and joints!