dock menu help

33 views
Skip to first unread message

Cssara

unread,
Mar 6, 2018, 10:11:06 AM3/6/18
to Python Programming for Autodesk Maya
am new to python..I try to create a button with a ui..for the first time its ok.. if i try to run the script for the 2nd time its shows myrigshortcut is not unique. please help me to rectify this





import maya.cmds as christy

if christy.dockControl('MyRigShortcut', exists=True):
    christy.deleteUI('MyRigShortcut', window=True)



myWindow = christy.window( iconName='Short Name', widthHeight=(200, 55) )
christy.columnLayout( adjustableColumn=True )
christy.button (label = 'Show/Hide Joint', c = 'HideShow()')
christy.setParent('..')
christy.showWindow(myWindow)


def HideShow():
    jointList = []
    jointList = christy.ls(type = 'joint' )
    for j in jointList:
        n = christy.getAttr (j+'.drawStyle')
        if (n==0):
            christy.setAttr(j+'.drawStyle',2)
        else:
            christy.setAttr(j+'.drawStyle',0)
buttonForm = christy.formLayout( parent = myWindow)            
           

christy.dockControl( 'MyRigShortcut',area='left', content= myWindow , allowedArea='left' )

Kurian O.S

unread,
Mar 6, 2018, 12:43:26 PM3/6/18
to python_in...@googlegroups.com
There are few things wrong with this code .. but for answering your question 

You where trying to create multiple instance with same name with this line .."christy.dockControl( 'MyRigShortcut',area='left', content= myWindow , allowedArea='left' )"
that's why you got that error , to correct that you can add condition to check if its exists then delete it.  


import maya.cmds as christy

if christy.dockControl('MyRigShortcutDock',  q=1, ex=1) and  christy.window('MyRigShortcut', exists=True):
    christy.deleteUI('MyRigShortcutDock')
    christy.deleteUI('MyRigShortcut', window=True)
    
myWindow = christy.window("MyRigShortcut", iconName='Short Name', widthHeight=(200, 55) )
christy.columnLayout( adjustableColumn=True )
christy.button (label = 'Show/Hide Joint', c = 'HideShow()')
christy.setParent('..')
christy.showWindow(myWindow)


def HideShow():
    jointList = []
    jointList = christy.ls(type = 'joint' )
    for j in jointList:
        n = christy.getAttr (j+'.drawStyle')
        if (n==0):
            christy.setAttr(j+'.drawStyle',2)
        else:
            christy.setAttr(j+'.drawStyle',0)
buttonForm = christy.formLayout( parent = myWindow)             
            
christy.dockControl( 'MyRigShortcutDock',area='left', content= myWindow , allowedArea='left')


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/e7f84d83-7e5f-40a8-b5d3-19a613416da1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
--:: Kurian ::--

Cssara

unread,
Mar 6, 2018, 10:08:24 PM3/6/18
to Python Programming for Autodesk Maya
thanks kurian..

while running for second time am the rig shortcut window.. then it goes to dock window.. so i deleted some lines.. now working its fine as per my wish...

thanks alot for guiding me..

import maya.cmds as christy

if christy.dockControl('MyRigShortcutDock',  q=1, ex=1) :
    christy.deleteUI('MyRigShortcutDock')


   
myWindow = christy.window( iconName='Short Name', widthHeight=(200, 55) )
christy.columnLayout( adjustableColumn=True )
christy.button (label = 'Show/Hide Joint', c = 'HideShow()')
christy.setParent('..')
#christy.showWindow(myWindow)



def HideShow():
    jointList = []
    jointList = christy.ls(type = 'joint' )
    for j in jointList:
        n = christy.getAttr (j+'.drawStyle')
        if (n==0):
            christy.setAttr(j+'.drawStyle',2)
        else:
            christy.setAttr(j+'.drawStyle',0)
buttonForm = christy.formLayout( parent = myWindow)            
           
christy.dockControl( 'MyRigShortcutDock',area='left', content= myWindow , allowedArea='left')



Reply all
Reply to author
Forward
0 new messages