home *** CD-ROM | disk | FTP | other *** search
/ Learning Maya 3 / Learning_Maya_3.iso / docs / mel_scripts / includes / clipFX.mel < prev    next >
Encoding:
Text File  |  2000-05-17  |  2.9 KB  |  85 lines

  1. //
  2. // Copyright (C) 1997-2000 Alias|Wavefront,
  3. // a division of Silicon Graphics Limited.
  4. //
  5. // The information in this file is provided for the exclusive use of the
  6. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  7. // and incorporate this code into other products for purposes authorized
  8. // by the Alias|Wavefront license agreement, without fee.
  9. //
  10. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  11. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  12. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  13. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  14. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. // PERFORMANCE OF THIS SOFTWARE.
  17. //
  18. // Alias|Wavefront Script File
  19. // MODIFY THIS AT YOUR OWN RISK
  20. //
  21. // Creation Date:  8 Dec 1997
  22. //
  23. //
  24. //  Procedure Name:
  25. //
  26. //      clipFX
  27. //
  28. //  Description:
  29. //    This script adds a menu called ClipFX and then scans a directory called
  30. //    ClipFX which must be located in your scripts directory. The ClipFX menu
  31. //    contains items that execute any scripts found in the ClipFX directory.
  32. //
  33. //    Warning:  You must create a directory called ClipFX
  34. //        and placed it in your ~/maya/scripts/ directory.  You should
  35. //        move or symbolically link any scripts that you'd like to have
  36. //        listed in the ClipFX menu into this directory.
  37. //
  38. //
  39. //      Tip:      An easy way to set up your ClipFX directory is by executing
  40. //                the following commands:
  41. /*
  42.                       mkdir ~/maya/scripts/ClipFX/
  43.                       cd ~/maya/scripts/ClipFX/
  44.                       ln -s ../*.mel .
  45. */
  46. //
  47. //
  48. global proc clipFX()
  49. {
  50.     // If the ClipFX menu exists then delete it so we can make a new one.
  51.     //
  52.     global string $clipFXmenu;
  53.     if (`menu -exists $clipFXmenu`)
  54.         deleteUI $clipFXmenu;
  55.  
  56.     // Create the ClipFX menu and build the name of the ClipFX directory.
  57.     //
  58.     string $name = "ClipFX";
  59.     global string $gMainWindow;
  60.     $clipFXmenu = `menu -p $gMainWindow -to true -l $name`;
  61.     string $directory = `getenv("HOME")` + "/maya/scripts/" + $name + "/";
  62.  
  63.     // Make an array of the script files in the ClipFX directory but remove
  64.     // the .mel from the script file names.
  65.     //
  66.     string $scripts[];
  67.     string $listing = `system("ls " + $directory + "*.mel | " +
  68.         "sed -e 's/.*\\///' -e 's/.mel//'")`;
  69.     tokenize($listing, "\n", $scripts);
  70.  
  71.     // If there were no scripts found then print an error message.
  72.     //
  73.     if (size($scripts) < 1)
  74.         error("No scripts found in " + $directory + "\n");
  75.  
  76.     // Make a menu item for each script file that sources that script file and
  77.     // then executes it.
  78.     //
  79.     string $script;
  80.     for ($script in $scripts)
  81.         menuItem -p $clipFXmenu -l $script
  82.             -c ("source \"" + $name + "/" + $script + ".mel\"; " + $script);
  83. }
  84.  
  85.