Adding Custom mel Functions into Maya. When writing plug-ins for Maya, there are a number of different proxy classes you can inherit from. Within any one plugin, you may register one or more of these types with Maya.
I would generally recommend only using one plugin for your full maya toolset - it makes it much easier to distribute toolset updates to your Art Department. Another un-avoidable aspect of using the Maya API, is that at some point, you will end up requiring a few mel scripts. These are usually required to create any custom user interfaces that may be needed, or simply provide custom menus or user interfaces.
In this tutorial we will focus on creating our own mel functions, and how mel interfaces with the rest of maya. We will then proceed to make use of these mel functions to create an automated graphics build process. Essentially, adding our own mel function into Maya involves deriving our own class, from the proxy class MPxCommand. This contains a virtual function doIt which we need to overload to perform our required actions.
This may seem straight-forward infact it ishowever there is an even easier way to create a simple function - we can use MSimple. The DeclareSimpleCommand macro essentually takes away a lot of the hassle of setting up a simple mel function, however in practical terms it is often only useful in 'quickfix' situations since it only allows a single mel function to be registered in each plugin.
Therefore, as mentioned earlier, we have to derive a class from MPxCommand. In Addition, we also have to export two functions, one to initialise the plugin, the other to un-initialise it. These functions should use the MFnPlugin function set to register and deregister any mel commands, nodes, file translators etc. For example. Writing A Plugin File Translator. Rob Bateman . What Next?FBXExport -f [filename] [-s]. Exports the specified file. For example:. Use this script to export only animation.
See Animation for more information. This is the script equivalent of the Constant Key Reducer. This command lets you set an export conversion method. See Axis conversion for more information. This command is the script equivalent of the Bake animation option.
See Bake Animation. This command is the script equivalent of the End field in the Bake animation option. The passed value is an integer number. See Bake Animation for more information.
This command is the script equivalent of the Start field in the Bake animation option. This command is the script equivalent of the Step field in the Bake animation option.
See Resample All. See Geometry Cache File s. FBXExportCameras -v [true false]. FBXExportCameras -q. Use this function to either include or exclude cameras in your FBX export.
See Cameras for more information. This function is the script equivalent of the Collada option. This command is the script equivalent of the Collada Single matrix option. This command is the script equivalent of the Collada Triangulate option. FBXExportConstraints -v [true false].You have been detected as being from. Where applicable, you can see country-specific product information, offers, and pricing. Work faster and more efficiently by using the Autodesk Maya Keyboard Shortcuts below.
Below, you'll find the Maya one-key shortcuts.
Click on the image for a larger view. The following commands change based on specific editor pane you are actively using. Download a free day trial and try it out.
Purchase options include flexible subscription terms to fit your needs. Autodesk is a leader in 3D design, engineering and entertainment software. All rights reserved. Worldwide Sites You have been detected as being from. Autodesk Maya Keyboard Shortcuts. Jump to a section. Subscribe now. Try it now. Free for 30 days.
One-key shortcuts. Shortcut commands by category. Below, you'll find an abbreviated list of commands that can be used in Maya.
MEL Command Syntax
Pane specific commands. Get it now. Download free trial. Animation Operations. Display Settings. Displaying Objects Show, Hide. Edit Operations. Hotbox Display.
Modeling Operations. Moving Selected Objects. Painting Operations. Playback Control. Selecting Menus. Selecting Objects and Components. Snapping Operations. Tool Operations. Tumble, Track or Dolly. Window and View Operations. Graph Editor.MEL includes a wide variety of commands for all aspects of using Maya.
Some typical examples of using MEL commands include quickly creating objects, precisely moving objects, and working more efficiently with objects. For example, you can use a MEL command to create a sphere named bigBoy with a radius of exactly As another example, if you are creating a joint with the joint tool and you want to move the joint 5 units in an X-axis direction, you can execute the following MEL command without having to interrupt the joint creation:.
By convention, most commands operate on an object if you specify its name, otherwise they operate on the current selection. You can use MEL commands in two ways: imperative syntax and function syntax.
The imperative style is a complete statement and should end with a semicolon. See Using return values: function syntax and backquotes below. When you use this imperative command syntax as opposed to the function syntax explained belowyou can optionally leave off quotation marks around single-word strings. So you could write the sphere command like this:. You will often see this in scripts, especially for strings such as node and attribute names which are always one word.
However, as a beginner, you may want to avoid using this feature because it makes strings less distinct from keywords and commands.
Function syntax looks like a standard function call in a computer language. Flags modify how a command works. A flag comes after the command name, is proceeded by a dash -and is followed by a parameter. Many commands have different behavior based on a pair of special flags: -edit and -query. The Maya Help for each command lists which flags are available in create, edit, and query modes.
When you use the function syntax of a command, the command returns a value. When you use the imperative syntax, the command simply prints its return value to the Script Editorit does not provide a usable return value. Using imperative syntax in an expression will cause a syntax error:.
To use imperative command syntax in an expression you must surround the command with backquotes:. You will use backquotes often to use the return value of a command in query mode inside an expression:.How to Create Basic MEL Scripting in Maya 2017
Imperative syntax The imperative command syntax looks like a command in a UNIX or DOS shell, with optional flags and arguments after the command name: sphere -name "martha" -radius 10; The imperative style is a complete statement and should end with a semicolon. Unquoted strings When you use this imperative command syntax as opposed to the function syntax explained belowyou can optionally leave off quotation marks around single-word strings.
So you could write the sphere command like this: sphere -name martha -radius 10; You will often see this in scripts, especially for strings such as node and attribute names which are always one word. Function syntax Function syntax looks like a standard function call in a computer language. Imperative syntax Function syntax attributeExists visibility mySphere; attributeExists "visibility","mySphere" ; abs ; abs .These scripts can affect Render Settings, attributes on nodes, your workspace, and even specific passes.
Release Notes PRMan NOTE: parameters offset by asterisks are optional, e. Render -r rman. Then, return the substituted string. The optional parameter -all will replace all occurrences. If -matchOnly or -mo is passed as an argument, the command will return 1 if there are any matches and 0 otherwise.
If -stringArray or -sa is passed as an argument, the command will return the matches in a string array. Example: rman regexp -matchOnly "-v" "file-v You can also query for the version number of other components by passing in a name for the third argument nmwhere nm can be one of the following: about, mayaAPI, prman, platform, os, osVersion.
The result will be printed to the Maya Script Editor window, e. All rights reserved. The attribute names can then be added to the user's objects with rmanAddAttr. This can be more advantageous than using Maya's setAttr as the data type of the attribute does not need to be known, and the value can be supplied as a string.
It may be more desirable to use this procedure as these menus usually add more than one attribute. They're typically created when the Render Settings window is raised. Example: rmanCreateEnvLight.MEL offers a method of speeding up complicated or repetitive tasks, as well as allowing users to redistribute a specific set of commands to others that may find it useful. MEL is syntactically similar to Perl and Tcl. It provides some memory management and dynamic array-allocation, and offers direct access to functions specific to Maya.
MEL is fairly limited compared to mainstream scripting languages. Mel is primarily a language meant to journal the Maya session [ citation needed ]thus lacks many advanced features such as associative arrays.
Still MEL offers some advantages to Python:. MEL is often criticized for its lack of programming features, and object orientation. In practice, however, MEL is used as a metaprogramming language where MEL just instructs Maya's node architecture to solve the problem. Since nodes form the actual computational core of Maya using a more robust readily apparent programming method would be a very inefficient approach. This makes MEL harder to learn and fully understand.
Maya also offers an expression language that is a super-set of MEL, and results in nodes that are executed as part of Maya's dependency graph. Expressions are developed with Maya's expression editorand allow scripts to trigger while Maya evaluates the scene file at each change in time, to simulate complex behaviors or perform other useful tasks. From Wikipedia, the free encyclopedia. The references in this article are unclear because of a lack of inline citations.
Help Wikipedia improve by adding precise citations! July Learn how and when to remove this template message. Mark R. Categories : Scripting languages. Hidden categories: Pages using deprecated source tags Articles lacking in-text citations from July All articles lacking in-text citations All articles with unsourced statements Articles with unsourced statements from October Namespaces Article Talk.
MEL and Python communicate by calling commands in the other language and evaluating the results of the last executed command. Python communicates with MEL using the eval command. Unlike the other Python commands in this lesson, the eval function does not belong to the Maya commands module maya. The eval function belongs to the maya. Multiple MEL commands can be called in the string by separating the commands with semi-colons. The Python eval function returns the results of the last executed MEL script or command within the eval brackets.
MEL communicates with Python using the python command. The python command accepts a string as its only argument. The string is sent to Python to be evaluated, and the result is returned to MEL. As Python has a more descriptive type system, some results from Python commands returned to MEL have their data type modified. To call MEL commands from Python.
The maya. A sphere of radius three is created at the origin, just as if you had used the Python command. Only global MEL procedures, variables and scripts are accessible from within Python. When transferring variables between MEL and Python, the functions return the value of the statement.
MEL syntax does not allow you to return the value of a variable by using the variable as a command string. Within the eval statement, you assign the value of the global MEL variable to a temporary variable. To call Python commands from MEL. A sphere is created at the origin, just as if you had typed the command in the Python tab. Evaluation back quotes are used in MEL to use the return value of a command in assignment, when the return value is normally returned to the Script Editor history window.
Show in Contents. Tip Transferring values between Python and Maya can also be accomplished by using invisible user interface elements.