Hello,
I’m trying to write a simple GUI to be able to have the option in Maya to use xray and wireframe on shaded only on a selected object.
I half of the script working (the xray part) but when I try to do the same thing with the wireframe on shaded its a no go. I spent half the day trying to figure it out via autodesk documentation but I’m finally reaching out for help. I get two different errors.
Error: modelEditor: Object ‘pCube1’ not found.
Traceback (most recent call last):
File “<maya console>”, line 18, in wos
RuntimeError: modelEditor: Object ‘pCube1’ not found.
and
xRayWireUI()
Error: ‘bool’ object is unsubscriptable
Traceback (most recent call last):
File “<maya console>”, line 19, in wos
TypeError: ‘bool’ object is unsubscriptable
Here is the script any help would be appreciated.
import maya.cmds as cmds
def xRayWireUI():
window_name = “xRayWIreUI”
if cmds.window(window_name, q=True, exists=True):
cmds.deleteUI(window_name)
def xRay(*arg):
selection = cmds.ls(sl=True)
for selected in selection:
xRay = cmds.displaySurface(selected, q=True, xRay=True)
cmds.displaySurface(selected,xRay= not xRay[0])
def wos(*arg):
selection = cmds.ls(sl=True)
for selected in selection:
wos = cmds.modelEditor(selected, q=True, wos=True)
cmds.modelEditor(selected, wireframeOnShaded= not wos[0])
my_window = cmds.window(window_name, title="KMT_Toggle Xray / Wireframe on Shaded Tool", h=25, w=475)
cmds.columnLayout(parent=my_window, adj=True)
cmds.button(label="Toggle Xray", h=25, w=475, c=xRay)
cmds.button(label="Toggle Wireframe On Shaded", h=25, w=475, c=wos)
cmds.showWindow(my_window)
xRayWireUI()