0

I am creating a new workspaceControl inside maya 2018.6.

When I change the uiScript flag to point to a new function and re launch the workspaceControl it is still calling the old function. Here is a simple version of my code:

dockName = 'myNewDock'
def test1():
    print 'test 1'
def test2():
    print 'test 2'    
cmds.workspaceControl(dockName, retain=False, floating=True, l='My Dock Test', uiScript="test1()")

The above works fine. However, when I change:

uiScript="test1()"

To be:

uiScript="test2()"

It still prints out

test 1

I have tried closing the workspaceControl manually. I have also tried using various combinations of the following code:

cmds.deleteUI(dockName)
cmds.workspaceControl(dockName, edit=True, close=True)

Even closing Maya and re launching it does not solve the issue, it still calls test1()

It will only update if I change the 'dockName'. This tells me that Maya is storing the UIScript somewhere internally, I have been all through my preferences and can not find reference to it anywhere. Does anyone have any idea how to solve this issue without constantly renaming the dock every time I want to try something different?

Thanks

vfxChris
  • 3
  • 2

2 Answers2

0

I've never used this command and I don't have maya for few weeks. Note that command flag is not meant to have string :

mywcctrl = cmds.workspaceControl(dockName, retain=False, floating=True, l='My Dock Test', uiScript=test1)

you should be able to modify it with :

cmds.workspaceControl(mywcctrl , edit = True, uiScript=test2)

otherwise, in maya pref, it saves your scene file with layout pref, window, and few other things, so if you close maya and re-open it might cause problems :

Window > Settings/Preferences > Preferences > UI Elements

enter image description here

DrWeeny
  • 2,487
  • 1
  • 14
  • 17
  • Hi DrWeeny, thank you for the reply. Using the edit flag did indeed work. Seems that once a dock has been created its name lives forever hidden somewhere deep inside maya, and can only be changed by using the edit flag. – vfxChris Aug 07 '19 at 19:57
0

Just for future clarity of what I found worked. The command flag is meant to be a string, it does not work otherwise. So combining that with DrWeeny's solution:

# create UI First time round    
dockName = 'myNewDock'
def test1():
    print 'test 1'
def test2():
    print 'test 2'    
cmds.workspaceControl(dockName, retain=False, floating=True, l='My Dock Test', uiScript="test1()")

# Delete UI
cmds.deleteUI(dockName)
cmds.workspaceControl(dockName, edit=True, close=True)

# edit the command flag
cmds.workspaceControl(dockName, e=True, uiScript='test2()')

# re launch UI pointing to new function
cmds.workspaceControl(dockName, retain=False, floating=True, l='My Dock Test', uiScript="test2()")
vfxChris
  • 3
  • 2