Basic for MEL, command line modes

Maya MEL 脚本编辑与执行
本文介绍了 Maya 中使用 MEL (Maya Embedded Language) 编写和执行脚本的方法,包括通过命令行、命令壳、脚本编辑器等不同方式执行 MEL 命令。此外还探讨了如何创建货架按钮、保存脚本文件以及 MEL 命令的不同模式。
Script Editor

1

 

MEL (Ctrl+Enter, or Enter from numeric keypad to run)
  sphere
textCurves -t "Hello World"
Shelf button

To create a shelf button, just select lines of code you would like to contain in that button from history panel. Drag the code lines to the shelf and a new shelf button is created.

 

Execute MEL

3

1. Command Line

Used to write and execute simple commands that are typically one line in length. It is possible to write more than one command in the Command Line using semicolons to separate each one, though in practice this becomes cumbersome for all but the simplest set of commands.

2. Command Shell

The Command Shell is a window that operates like a Unix shell window. MEL
commands can be executed from this window. Those familiar with Unix shells
may be more comfortable using the Command Shell. To access it, select
Windows [ General Editors... I Command Shell... from the main Maya menu.

3. Script Editor

The Script Editor allows you to write multiline scripts. Once executed, the
script is listed in the History Panel. You can copy and paste the script back into
the Command Input Panel for further editing and refinement. This is the main
method of creating simple, yet functional scripts. Once they are tested and
debugged in the Script Editor, they can then be saved to a script file for later
reuse.

4. Shelf

Once you have finished writing and testing your commands, they can be
assigned to an item in the Shelf control. You can edit the commands for the
item by using the Shelf Editor.

5. Script Files

Saving your scripts to files is the main method for defining a series of commands
that you want to keep between Maya sessions. Once stored to a script file, the
commands can be used in different scenes and projects.

6. Others

There are other ways of executing MEL commands including hotkeys, expressions,
and Script Nodes.

Execute the Mel script in the command line, to keep the cursor still in the command line after current script is executed, use Ctrl+Enter/ Enter of the numeric keypad. If using only Enter of the main pad, the focus will change to the scene.
Command line query (Creation Mode vs. Query Mode) One query for one attribute

sphere -radius 1.5 -name MySphere;

sphere -query -radius MySphere;

//Result: 1.5

Command Edit (Edit Mode) One Edit for many attributes

sphere -edit -radius 3 MySphere;

sphere -edit -radius 4 -degree 1 MySphere;

Command Modes

In conclusion, there are three modes: create, query, edit.

Different modes cannot be mixed into a single call!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值