Adverti horiz upsell
List Connections in the Hypergraph
List Connections in the Hypergraph
Nihilists, updated 2007-08-06 13:50:46 UTC 16,618 views  Rating:
(1 rating)
Page 1 of 1

List Connections in the Hypergraph
Software Needed: Maya 8.x Skill: Basic MEL

 

When editing the connections of a gven node can be confusing in the hypergraph. The hypergraph will get very complex depending on the amount of connections. As you can see there is only 4 custom channels. Now, if I wanted to edit the "Lf Eye" and "Rt Eye" connections, we will use the Hypergraph: Connections. Located at Window->Hypergraph: Connections. Using "Input and output Connections" in the hypergraph will produce the same results.

The results is a very comply hierarchy that is not very user friendly to edit. If you notice the outputs of the "cn_head_CTRL", there is a long list of outputs (that is only a small snap shot of the output list), this is causing all the problems.
click for larger version

A new menu option will be added when you RMC over the "Channel Box" unfortunately, "Print Screen" does not capture the menu. The new option is called "Graph Selected Channels". The following results is the product of the new code that will be used.

click for larger version


In order to get access to change the "Channel Box" menu, we need to know the location. Open up the file generateChannelMenu.mel located on a windows based machine at: C:/Program Files/Autodesk/Maya8.5/scripts/startup/

Important Note:
Please read the disclaimer at the top of the page, by following the rest of the tutorial you are bound by the license agreement with Autodesk since you will be editing the file, rather then downloading the full version here. Therefore, granting me (meljunky) no responsibility of any damages that may occur from using the new version of the script.

To prevent any problems that may occur with editing Maya's startup scripts. Please save the file in your scripts directory, this will create a backup, for example: C:/Documents and Settings/Admin/My Documents/maya/8.5/scripts

When Maya starts, the generateChannelMenu.mel located in your scrips directory will take precedence over the file located in the startup directory. If you make any mistakes, the original file is backed up safely.

At the beginning of the file for for a global procedure called channelBoxCommand. Add the following code to the existing switch statement. The new switch statement will now include a new case called "-graphSelected". The code will be executed when the new option "Graph Selected Nodes" is executed.

  case "-graphSelected":
    string $connections[];
    string $sel[] = `ls -sl`;
    if ( size(`ls -sl`) == 0 ){
            warning "No nodes are selected.";
            return;
    }
    string $channels[] = `channelBox -q -sma mainChannelBox`;
    select -cl; //Clear Selection
    for ($do in $channels){
    select -tgl `listConnections ($sel[0] + "." + $do)`;
    }
    if ( size(`ls -sl`) ){
            hyperGraphWindow "" DG; //Opens a new Hypergraph
            $whichPanel = getHyperGraphPanel("DG"); //Determine which panel is selected
            string $hyperGraphEd = ($whichPanel + "HyperGraphEd");
            hyperGraphDepthSet($hyperGraphEd, 1); //Change depth to 1
    }else{
            warning "No input connections for selected channels";
            select -r $sel;
    }

    break;


Now, the new option needs to be created. Find the global procedure callled generateChannelMenu, near the bottom of the script. Inside that procedure is the following line:

menuItem -label (uiRes("m_generateChannelMenu.kKeySelected")) -c "channelBoxCommand -key" keyItem;

 

Add the following line above:

 

menuItem -label "Graph Selected Channels" -c "channelBoxCommand -graphSelected" graphSelected;

It will now look like:

 

menuItem -label "Graph Selected Channels" -c "channelBoxCommand -graphSelected" graphSelected;
menuItem -label (uiRes("m_generateChannelMenu.kKeySelected")) -c "channelBoxCommand -key" keyItem;

 

The new change will not take in effect until after you restart Maya. Congratulations, you edited the RMC menu for the "Channel Box". This should get you on your way to adding new menu options to Maya's RMC "Channel Box" Menu.

 

To keep more tutorials coming from www.meljunky.com please send me your comments and suggestions at: brian@meljunky.com