Toggle viewport xray mode

199 views
Skip to first unread message

Chad Vernon

unread,
Aug 20, 2009, 1:41:18 PM8/20/09
to python_in...@googlegroups.com
I'd like to toggle xray mode in a viewport:

cmds.modelEditor('modelPanel1', edit=True, displayAppearance='smoothShaded', xray=True)

But I don't necessarily know the name of the modelPanel.  Is there a command to list all the modelPanels in the UI?

Thanks,
Chad

Paul Molodowitch

unread,
Aug 20, 2009, 2:08:15 PM8/20/09
to python_in...@googlegroups.com
I don't know of a single command, but this should work:

modelPanels = []
for panel in lsUI(panels=True):
if modelPanel(panel, q=1, exists=1):
modelPanels.append(panel)

There's also a way to get the name of the currently selected modeling
panel, too, if that's all you want... used that before in a script,
but don't remember offhand. I can find it if you want...

- Paul

Richard Kazuo

unread,
Aug 20, 2009, 2:35:52 PM8/20/09
to python_in...@googlegroups.com
I think this is the command to get the current active panel. :)

import maya.cmds as cmds
cmds.getPanel(wf=1)


Richard

Chad Dombrova

unread,
Aug 20, 2009, 2:58:02 PM8/20/09
to python_in...@googlegroups.com

cmds.getPanel(withFocus=1)

br...@meljunky.com

unread,
Aug 20, 2009, 2:59:53 PM8/20/09
to python_in...@googlegroups.com
cmds.getPanel(wf=True)

-brian

Paul Molodowitch

unread,
Aug 20, 2009, 8:25:17 PM8/20/09
to python_in...@googlegroups.com
...or, I can make my minions do my evil bidding for me!

*Throws his minions a goldfish snack...*

- Paul

sabareesh rg

unread,
Aug 21, 2009, 2:30:14 PM8/21/09
to python_in...@googlegroups.com
hi  guys


i think this will toogle xray mode

################################################

from maya import cmds,mel

modelPanel=cmds.getPanel(wf=True)

if (cmds.modelEditor(modelPanel,q=1,xr=1)==1):
   
    cmds.modelEditor(modelPanel,e=1,xr=0)
else:
    cmds.modelEditor(modelPanel,e=1,xr=1)

################################################




sabareeshrg

Reply all
Reply to author
Forward
0 new messages