Maya2018 + VS2017 环境搭建见 博客

1. 项目:

VS 新建了一个 MEL Command类型的项目(MayaProject)

2. HelloWorld代码

#include<maya/MSimple.h>

// Use helper macro to register a command with Maya.  It creates and
// registers a command that does not support undo or redo. The
// created class derives off of MPxCommand.
//
DeclareSimpleCommand( MayaProject, "", ""); MStatus sayHello::doIt(const MArgList& args )
{ MStatus stat = MS::kSuccess; displayInfo("Hello World!"); // Since this class is derived off of MPxCommand, you can use the // inherited methods to return values and set error messages // setResult( "sayHello command executed!/n" ); return stat; }

3.  运行,debug文件夹中出现了一个mll文件

4. 把mll文件拷贝到C:\MyProgram\AutoDesk\Maya2018\bin\plug-ins目录下,然后重新打开maya

菜单->窗口->设置/首选项->插件管理器

MayaProject插件加载进来

5. 在maya底部的MEL脚本编辑器中输入脚本,对插件进行测试

6. 脚本编辑器显示 结果

附一个创建球模型的代码:(我还没有运行出来)

//
// Copyright (C)
//
// File: MayaProjectCmd.cpp
//
// MEL Command: MayaProject
//
// Author: Maya Plug-in Wizard 2.0
// // Includes everything needed to register a simple MEL command with Maya.
//
#include <maya/MSimple.h>
#include <maya/MGlobal.h>
#include <maya/MDagPath.h>
#include <maya/MSelectionList.h>
#include <maya/MFnDagNode.h>
#include <maya/MIOStream.h>
#include <maya/MFnMesh.h>
#include <maya/MFloatPointArray.h>
#include <maya/MString.h>
#include <maya/MItSelectionList.h>
#include <maya/MItMeshVertex.h>
#include <maya/MStringArray.h> // Use helper macro to register a command with Maya. It creates and
// registers a command that does not support undo or redo. The
// created class derives off of MPxCommand.
//
DeclareSimpleCommand( MayaProject, "", ""); MStatus MayaProject::doIt( const MArgList& args )
//
// Description:
// implements the MEL MayaProject command.
//
// Arguments:
// args - the argument list that was passes to the command from MEL
//
// Return Value:
// MS::kSuccess - command succeeded
// MS::kFailure - command failed (returning this value will cause the
// MEL script that is being run to terminate unless the
// error is caught using a "catch" statement.
//
{
MStatus stat = MS::kSuccess;
MSelectionList selection; MGlobal::getActiveSelectionList(selection);
MDagPath dagPath, dagPath_1;
MObject component, component_1;
MItSelectionList iter(selection); selection.getDagPath(, dagPath, component);
MItMeshVertex meshIter(dagPath, component, &stat);
MStringArray verIndexArray;
if (stat == MS::kSuccess)
{
for (; !meshIter.isDone(); meshIter.next())
{
MPoint pt = meshIter.position(MSpace::kObject);
MItMeshVertex meshIter_1(dagPath);
for (; !meshIter_1.isDone(); meshIter_1.next())
{
MPoint pt_1 = meshIter_1.position(MSpace::kObject);
if (abs(-pt.x - pt_1.x) < 0.01
&& abs(pt.y - pt_1.y) < 0.01
&& abs(pt.z - pt_1.z) < 0.01)
{
verIndexArray.append(MString("") + meshIter_1.index());
break;
}
}
}
} // Since this class is derived off of MPxCommand, you can use the
// inherited methods to return values and set error messages
//
setResult(verIndexArray ); return stat;
}

参考:

https://blog.csdn.net/xdhstc/article/details/40355155(球模型代码来源)

https://blog.csdn.net/huadingjin/article/details/8083277

https://blog.csdn.net/mincau/article/details/7925520

https://baijiahao.baidu.com/s?id=1608682630689528579&wfr=spider&for=pc(github/WendyAndAndy/MayaDev)

Maya+VS编程入门初体验(HelloWorld)的更多相关文章

  1. javaWeb快速入门+——初体验-HelloWorld

    文章转载自 https://www.cnblogs.com/1906859953Lucas/p/10821840.html 练习成品下载 https://www.lanzous.com/i9fljkj ...

  2. gulp快速入门&初体验

    前言 一句话先 gulp 是一个可以简单和自动化"管理"前端文件的构建工具 先说我以前的主要工作,我主要是做游戏服务端的,用c++/python,所以我对东西的概念理解难免要套到自 ...

  3. Scala 深入浅出实战经典 第66讲:Scala并发编程实战初体验

    王家林亲授<DT大数据梦工厂>大数据实战视频 Scala 深入浅出实战经典(1-87讲)完整视频.PPT.代码下载:百度云盘:http://pan.baidu.com/s/1c0noOt6 ...

  4. Android开发学习之路--网络编程之初体验

    一般手机都是需要上网的,一般我们的浏览器就是个webview.这里简单实现下下功能,先编写Android的layout布局: <?xml version="1.0" enco ...

  5. Netty 入门初体验

    Netty简介 Netty是一款异步的事件驱动的网络应用程序框架,支持快速开发可维护的高性能的面向协议的服务器和客户端.Netty主要是对java 的 nio包进行的封装 为什么要使用 Netty 上 ...

  6. Node.js入门初体验

    今天有一个类似网络爬虫的需求,本来打算用我还算熟悉的asp或者asp.NET来做这个事情,但是写了这么长时间js,asp的语法实在不喜欢,VS又早被我卸掉了,思来想去打算用一下最近比较火的Node.j ...

  7. Spring入门初体验

    Spring其实就是一个容器,让我们更方便的拿到想要的对象. 1.编写一个service // userService.java public interface userService { publ ...

  8. angularjs入门初体验

    1. http://www.zouyesheng.com/angular.html#toc39

  9. 我的Go语言学习之旅二:入门初体验 Hello World

    好吧,全部的程序猿们都已经习惯了.学习不论什么一门语言,我们都会以Hello World实例開始我们的学习,我也不例外.先来一个简单的样例 打开编辑器 (能够用记事本,我已经习惯 Notepad++了 ...

随机推荐

  1. 一个兼容IE7\IE8,H5的多功能视频播放器,H5视频播放器兼容Flash视频播放器

    这里记录一个视频播放器,免费可适当修改:名称:ckplayer视频播放器(免费) 官网地址:http://www.ckplayer.com/ 下载地址:http://www.ckplayer.com/ ...

  2. php中的Exception

    如果定制的EXCEPTION搞定了,默认的,就自然不在话下罗. 直接上最曲折的过程. InvalidIdException.php <?php namespace Bookstore\Excep ...

  3. Kotlin匿名函数与闭包详解

    Lambda表达式实例演练: 继续先来编写一些Lambda表达式相关的代码: 接下来想从上面的字符串数组中找到带有"h"的字符串并打印出来: 如果学习了Java8的Lambda表达 ...

  4. nameof 运算符

    0. 目录 C#6 新增特性目录 1. 老版本的代码 1 using System; 2 namespace csharp6 3 { 4 internal class Program 5 { 6 pr ...

  5. c#每天生成漂亮桌面背景、英文名言、翻译

    阅读目录 一.1. 下载bing.com壁纸查询API 二.2. 解析返回的壁纸JSON信息 三.3. 下载完成的壁纸图片 阅读目录 .NET生成漂亮桌面背景 .NET生成漂亮桌面背景 总结 回到目录 ...

  6. ECHO命令输出空行的11种方法和效率

    标题: 批处理技术内幕:ECHO命令作者: Demon链接: http://demon.tw/reverse/cmd-internal-echo.html版权: 本博客的所有文章,都遵守“署名-非商业 ...

  7. 原生js的常用方法总结

    =============== 通知: 博主已迁至<掘金>码字,博客园可能以后不再更新,掘金地址:https://juejin.im/post/5a1a6a6551882534af25a8 ...

  8. iis站点设置错误页面返回http状态码为404而不是302或其他

    今天一位客户说网站错误页面返回的状态码是302而不是404,问ytkah要如何处理.这个应该是设置没有正确的原因.我们一步步来排查一下.1.首先打开iis管理器,左侧选择具体的站点,在右侧窗口中点击4 ...

  9. DSL的概念

    DSL:以极其高效的方式描述特定领域的对象.规则和运行方式的语言. 需要有特定的解释器与其配合. 高效简洁的领域语言,与通用语言相比能极大降级理解和使用难度,同时极大提高开发效率的语言. 能够描述特定 ...

  10. 工作拾记 - 关于easyui模板后台改为vue-element

    图1: 数据接口,模拟实现一些基本的数据条目 图2: 获取数据,接口都在src/api中 TODO LIST: 接下来要做的呢: 1. 完善此demo,基本的CURD,现在只有getAll,需要将增加 ...