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')


On Tue, Mar 6, 2018 at 7:11 AM, Cssara <christyso...@gmail.com> wrote:

> 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' )
>
> --
> 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+unsubscr...@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
> <https://groups.google.com/d/msgid/python_inside_maya/e7f84d83-7e5f-40a8-b5d3-19a613416da1%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
--:: Kurian ::--

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CANEMyhNTZw0UKWQf-NSTP7FMDAxyke1rrtz7W4rPrjv0DPRwDw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to