Community
Maya Forum
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Docking behavior of Maya 2016 in 2017

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
borbs727
1593 Views, 7 Replies

Docking behavior of Maya 2016 in 2017

I'd basically like to get the docking behavior of Maya 2016 in 2017.  There are no examples in the docs, so I'm having a little trouble.  The other docking thread explains how to get a dockable window, but not how to get it working like dockControls did.

 

  • Questions:
  1. How to get dockControl behavior out of windowControl in 2017?
  2. How can I properly clean up these windows?

 

  • dockControl Example:

This will append my tool to the existing tab panel on the right of the screen.  If the tab panel doesn't already exist, my tool will still dock and allow other panels to append if necessary.

 

 Snippet:

mc.dockControl(
	aa='right', a='right',
	content=self.objectName(),
	w=500, label='toolName'
)

 

  • workspaceControl Example:

Right now I can only get my tool to create a totally new panel that docks to the right of the entire Maya window:

 

Snippet:

WorkspaceName = 'myWorkspace'
if mc.workspaceControlState(WorkspaceName, exists=True):
    print 'hey'
    mc.deleteUI(WorkspaceName)
    
def buildContent():
    WinLayout = mc.columnLayout( adjustableColumn=True )
    mc.button( label='Do Nothing' )
    mc.button( label='Close', command=('mc.deleteUI(\"' + WorkspaceName + '\" )') )
     
cmds.workspaceControl( WorkspaceName, uiScript = "buildContent()", dtm=('right', 1))

 

7 REPLIES 7
Message 2 of 8
jordanjs
in reply to: borbs727

Same issue, scouring forums for answer...

Message 3 of 8
borbs727
in reply to: jordanjs

I posted a solution over on tech-artists.org a while ago. The key to doing this is basically all inside the run2017 method:

http://tech-artists.org/t/workspacecontrol-migrating-dockcontrol-so-we-can-dock-into-the-channelbox-...


 

 

 

Message 4 of 8
jordanjs
in reply to: borbs727

Hey borbs727,

 

Thanks for reply! I tried your example code out and it worked. 

 

However, when fiddling with it and trying to insert the call to the plugin I'm using, I couldn't get it to work.

 

It seems the only way to interact with this plugin in Python is by calling "AnimSchoolPicker()". I can't create a "buildContent" function with all the buttons in it, because it's an mll plugin.

 

I tried using Mark J's simpler way of working with workspaceControl, but it doesn't work:

 

element=mel.eval('getUIComponentDockControl("Channel Box / Layer Editor", false);')  
windowcall='AnimSchoolPicker();'

def createCustomWorkspaceControlUI():
	print("TEST");

cmds.workspaceControl(createCustomWorkspaceControlUI, label="Red9_Animation", 
                                      uiScript=windowcall, 
                                      tabToControl=(element, -1), 
                                      initialWidth=355, 
                                      initialHeight=720,
                                      retain=False,
                                      loadImmediately=False)  

This is so frustrating. Any advice? 

 

Message 5 of 8
borbs727
in reply to: jordanjs

You're close i think! I haven't loaded a plugin this way before, but here's how I'd go about solving this issue. Let me know if this helps:

 

You can think of the windowcall flag as a script that you'd write in order to to execute the plugin from a shelf button. So in Mark's example, you need to do these 3 things in order to run a python module's class:

  1. access the script (it must be known by maya by placing it in the scripts path),
  2. instantiate the class,
  3. run the lauch method, in this case it's named "show"

That's the process for a python script, but what about a plugin? 

 

 

Same process, except the 3rd option is optional-

  1. maya needs to access the plugin by knowing where the plugin is (by either placing it in maya's default plugin location or explicitly telling maya where to look)
  2. the plugin needs to be loaded,
  3. (optional) you need to execute the launch command (whatever that may be) if the plugin doesn't already contain a function to launch on initial load.

 

Knowing all that it's time to simplify and isolate in order to problem solve. I'd do this by creating a python shelf button and writing a command in python that will:

  1. access my plugin
  2. load it
  3. (optional) launch it (remember only if plugin doesn't have an automatic launch method that is ran during instantiation)

Here's an example of the concept in action for launching vray:

import maya.cmds as mc
import os

# Path to your plugin
vray_plugin_path = os.path.join('C:', os.path.sep, 'Program Files', 'Autodesk', Maya2017', 'vray', 'plug-ins', 'vrayformaya.mll').replace('\\', '/'))

# Access plugin
mc.pluginInfo(vray_plugin_path, e=1, a=True)

# Load it
mc.loadPlugin("vrayformaya" )

# We don't need to execute a launch command because vray launches when it's loaded

 

In the end your script would look something like this maybe. You need to manually put in the location of the plugin (mind the forward slashes): 

element=mel.eval('getUIComponentDockControl("Channel Box / Layer Editor", false);')  
windowcall='import maya.cmds as mc, plugin_path="path/to/plugin/AnimSchoolPicker.mll", mc.pluginInfo(plugin_path), mc.loadPlugin("AnimSchoolPicker")'

def createCustomWorkspaceControlUI():
	print("TEST");

cmds.workspaceControl(createCustomWorkspaceControlUI, label="Red9_Animation", 
                                      uiScript=windowcall, 
                                      tabToControl=(element, -1), 
                                      initialWidth=355, 
                                      initialHeight=720,
                                      retain=False,
                                      loadImmediately=False)  

Again, I've never done this but this is the first thing I'd try and my thought process behind it.

 

 

Message 6 of 8
jordanjs
in reply to: borbs727

Hey borbs727,

 

I really appreciate the diligence you went through to explain your process. However, it still doesn't work. You script -does- create a panel next to the channel box, but that panel is still empty.

 

Personally, I think I should just give up on the matter. I am a student and I've spent way too many hours being OCD about my layout and not getting work done. I'll just have to accept that there isn't a way to do it and move on.

 

Thank you though - at least I brushed up on the little Python and Mel I learned from rigging assignments a few years back. *thumbs up*

Message 7 of 8
borbs727
in reply to: jordanjs

Are there any errors? Sounds like it is working, but the plugin just isn't showing the UI. If you're comfortable supplying the plugin I can give it a shot. Curious to see if I can get it to work.

Message 8 of 8
jordanjs
in reply to: borbs727

Hey there, 

 

Yeah, there were errors in the callback line:

 

import maya.cmds as mc, plugin_path="C:/Program Files/Autodesk/Maya2018/bin/plug-ins/AnimSchoolPicker.mll", mc.pluginInfo(plugin_path), mc.loadPlugin("AnimSchoolPicker")
# Error: line 1: invalid syntax # 

I think other times the command worked, but the control did not dock, as I said earlier.

 

I am grateful for your desire to solve this problem, even though it is not yours, haha. 🙂  I have no problems supplying the plugin. It is publicly available on AnimSchool's website:

 

https://www.animschool.com/pickerInfo.aspx

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report