Switch off UV Toolkit with Python

Anonymous

Switch off UV Toolkit with Python

Anonymous
Not applicable

I'm trying to write a script that will simple toggle the *!@$%^& UV Toolkit  window off!

 

Trouble is the windows aren't called by the same thing they are named and I'm not sure how to determine if the current window exists. Also a little confused as to what constitutes a panel and a window

 

import maya.cmds as cmds

for panel in cmds.getPanel(sty = "UV Toolkit"):
  cmds.window( panel, e = True, visible = False )

Yeah, it's not called the UV Toolkit, is it? Which is where I when down a digital rabbit hole as to how to find out the name of the desired window. Any ideas how to switch the UV Toolkit off - apart from from Hide UV Tookit from the UV Editor window?

0 Likes
Reply
Accepted solutions (1)
1,656 Views
5 Replies
Replies (5)

rflannery
Collaborator
Collaborator
Accepted solution

Short answer:

cmds.workspaceControl("UVToolkitDockControl", e=True, close=True)

Long answer:

To figure out how to close the UV Toolkit, the first thing I did was to open the Script Editor.  Then I turned on "Echo All Commands".  Then I opened the UV Editor.  (On my machine, the UV Toolkit always opens when I open the UV Editor.)  This printed a bunch of output to the Script Editor.  Reading through the lines of output, I saw something that looked promising, "createUVToolkitDockControl();".

Next I ran the "whatIs" command and got the following result:

whatIs createUVToolkitDockControl;
// Mel procedure found in: C:/Program Files/Autodesk/Maya2019/scripts/others/UVToolkitPanel.mel // 

Note that the "whatIs" command must be run from MEL.  There is no Python version of it.

Next I found the file "UVToolkitPanel.mel" and opened it in a text editor.  Then I looked for the "createUVToolkitDockControl()" function.  Inside that function, I found this line:

    workspaceControl -e -initialWidth 285
-initialHeight `optionVar -q workspacesNarrowPanelInitialHeight`
-minimumWidth 285 -widthProperty "preferred" UVToolkitDockControl;

This line tells us that we are dealing with a "workspaceControl" and that it is named "UVToolkitDockControl".

Finally, I went to the documentation for "workspaceControl" and found out that it has a "close" flag.

 

That's pretty much how I track down most things in Maya.  Hopefully it will help if you have to do something similar in the future.

introbuck
Advocate
Advocate

Thank you! As i noticed the mel command of UV  is:

TextureViewWindow

and Python just added those lines:

import maya.cmds as cmds

cmds.

 So to "convert" any of standart editors (no only) to Python i have to add those lines? 

nicolashendriksvillasante
Explorer
Explorer
Hey there! I was wondering if you could help me here. I am creating my custom User Interface in Maya and so far so good but I can't figure out how to use MEL in order to toggle the UV Toolkit on or off. I would appreciate it so much if you could lend me a hand with getting the UV Toolkit to toggle because my head is about to explode. Thank you in advance for your time!
0 Likes

ajspeed_14
Participant
Participant
Sometimes the most obvious is the answer.
toggleUVToolkit;

I'm trying to figure out how to make the tab disappear completely rather than collapse but have not figured that out yet
0 Likes

ajspeed_14
Participant
Participant
I was looking for a way of hiding the Tab completely and figured it out using the whatis statement as you had suggested so thank you.

workspaceControl -e -visible true UVToolkitDockControl
workspaceControl -e -visible false UVToolkitDockControl


0 Likes