Thursday, April 12, 2012

Hair Script - Progress #3 / MEL info

I've been bad about labeling my posts.

Anyway.

I wanted to learn how to put tabs on the side of a window and make it a part of Maya.  I thought there was some hidden way to do this with a tabLayout, come to find out this wasn't a tabLayout, but were several windows with dock controls.  I'd never heard of dock controls until today.

dockControl
Create a dockable control, also known as tool palette or utility window. Dock controls are secondary windows placed in the dock area around the central control in a main window. Dock windows can be moved inside their current area, moved into new areas and floated (e.g. undocked). Dock control consists of a title bar and the content area. The titlebar displays the dock control window title, a float button and a close button. Depending on the state of the dock control, the float and close buttons may be either disabled or not shown at all.


(Pardon my sloppy mouse writing.  My tablet is downstairs and I'm too lazy to get it so...)

I'd wanted to do this with my hair script since day 1 but I just couldn't figure out how.

I found out dockControl was something introduced in Maya 2011 (figures.  I've been using Maya 2010 until a few months ago).  So, I can do this, but if someone wants to use this script in Maya 2010 or an earlier version, it will error out.  I've decided to use dockControl, and build a second UI for users who have Maya 2010 and earlier.

But how will my script know?!

The handy command:

getApplicationVersionAsFloat
Return the application version number as a float value. If you use the "about -version" command you get a string value containing the application version. Strings of course may not be used in comparisons like: if ($version > 3.5) { ... }; This procedure will return a float value containing the major and minor version number. The major version will be separated from the minor version by a decimal. For example, 4.0.3 will return a float value of 4.03.


So I can do:

global proc $ss_hairDo(){
     if (getApplicationVersionAsFloat() >= 2011){
          do my dockable window;
     }else{
          do the safe window;
     }
}


Sad thing is, this command is only available in MEL.  I guess my tool will end up being a blend of Python and MEL, which isn't so bad.  There are a lot of things I'm going to gut out and replace with Python since it does things more efficiently.

Anyway, it shouldn't be too bad creating a second window, just ignore all of the dockControl stuff, and it should be fine.

*famous last words*

~Melissa


No comments:

Post a Comment