helloWorld.py

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

#
# 描述:
# 运行这个程序将会启动一个Maya独立的python程序
#
# 使用方法:
#
# 设置MAYA_LOCATION环境变量到你的Maya安装路径并在Linux(Mac)的shell中执行:
#
# $MAYA_LOCATION/bin/mayapy helloWorld.py
#
# 注意:你必须使用Python可执行文件,才能正常工作。不同的平台它的路径都不一样。
# win系统的是:
#
# $MAYA_LOCATION/bin/mayapy.exe helloWorld.py

# 导入相关模块
import maya.standalone
import maya.OpenMaya as OpenMaya

import sys

def main( argv=None ):
try:
# 尝试启动Maya独立的python程序
maya.standalone.initialize( name='python' )
except:
# 如果无法启动,输出错误信息
sys.stderr.write( "Failed in initialize standalone application" )
raise

# 输出Hello world
sys.stderr.write( "Hello world! (script output)\n" )
# 执行print命令来输出Hello world
OpenMaya.MGlobal().executeCommand( "print \"Hello world! (command script output)\\n\"" )

if __name__ == "__main__":
main()

你可以在maya安装目录下的devkit找到helloWorld.py。
在线版
[url]http://download.autodesk.com/us/maya/2010help/API/hello_world_8py-example.html[/url]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值