1. 命令通常从selection list中得到input, 调用MGlobal::getActiveSelectionList(MSelectionList &dest, bool orderedSelectionIfAvailabel=false).得到MSelectionList和MItSelectionList来编辑选择列表。

2. 一个打印所有DAG nodes的例子:

#include <maya/MSimple.h>
#include <maya/MGlobal.h>
#include <maya/MString.h>
#include <maya/MDagPath.h>
#include <maya/MFnDagNode.h>
#include <maya/MSelectionList.h>
#include <maya/MIOStream.h>
MStatus pickExample::doIt( const MArgList& )
{
MDagPath node;
MObject component;
MSelectionList list;
MFnDagNode nodeFn;
MGlobal::getActiveSelectionList( list );
for ( unsigned int index = ; index < list.length(); index++ )
{
list.getDagPath( index, node, component );
nodeFn.setObject( node );
cout << nodeFn.name().asChar() << " is selected" << endl;
}
return MS::kSuccess;
}
DeclareSimpleCommand( pickExample, "Autodesk", "1.0" );

如果你建造几何体,然后选中它,这个例子会打印出它的名字。

The setObject() method on MFnDagNode is inherited by all function sets from MFnBase and is used to set the object the function set will operate on. 如果一个function set要操作不同的object,使用这个办法。

如果你选择了一个object的很多component,这个object也只会输出一次。

如果你选择了两个object的components, components多的那个object会在selection list appear两次。

3.MItSelectionList: lets you filter the objects on the selection list to only see objects of a particular type.

MGlobal::getActiveSelectionList( list );
for ( MItSelectionList listIter( list ); !listIter.isDone(); listIter.next() )
{
listIter.getDagPath( node, component );
nodeFn.setObject( node );
cout << nodeFn.name().asChar() << "%s is selected” << endl;
}

第二部分的代码可以被这段代码取代。

如果你只想Iterator查看具体某一种object:

  MItSelectionList listIter( list, MFn::kNurbsSurface )

4. The MFn::Type enumeration is used throughout the API to indicate item types.

5. Another way is to use MGlobal::selectByName(). This finds all objects matching a pattern and adds them to the active selection list. For example:

MGlobal::selectByName( "*Sphere*" );

五、selecting with the API的更多相关文章

  1. 数字货币比特币以太坊买卖五档行情数据API接口

    数字货币比特币以太坊买卖五档行情数据API接口       数字货币一般包含比特币BTC.以太坊ETH.瑞波币XRP.泰达币USDT.比特币现金BCH.比特币SV.莱特币LTC.柚子币EOS.OKB. ...

  2. Html5 学习系列(五)Canvas绘图API快速入门(2)

    Canvas绘图API Demos 上一篇文章中,笔者已经给大家演示了怎么快速用Canvas的API绘制一个矩形出来.接下里我会在本文中给各位介绍Canvas的其他API:绘制线条.绘制椭圆.绘制图片 ...

  3. Kafka(五)Kafka的API操作和拦截器

    一 kafka的API操作 1.1 环境准备 1)在eclipse中创建一个java工程 2)在工程的根目录创建一个lib文件夹 3)解压kafka安装包,将安装包libs目录下的jar包拷贝到工程的 ...

  4. Web API(五):Web API跨域问题

    一.什么是跨域问题 跨域:指的是浏览器不能执行其他网站的脚本.是由浏览器的同源策略造成的,是浏览器施加的安全限制.(服务端可以正常接收浏览器发生的请求,也可以正常返回,但是由于浏览器的安全策略,浏览器 ...

  5. 使用ASP.NET Web Api构建基于REST风格的服务实战系列教程【五】——在Web Api中实现Http方法(Put,Post,Delete)

    系列导航地址http://www.cnblogs.com/fzrain/p/3490137.html 前言 在Web Api中,我们对资源的CRUD操作都是通过相应的Http方法来实现——Post(新 ...

  6. Html5 学习系列(五)Canvas绘图API快速入门(1)

    引言:Canvas绘图API快速入门 在接触HTML5的初学者包括我都在很多地方见到非常炫的一些页面,甚至好多学习HTML5的开发者都是冲着Web端的页游去的,那么HTML5那么绚丽的页面效果以及游戏 ...

  7. Struts2学习笔记(五)——Action访问Servlet API

    在Strut2中访问Servlet API有三种方式: 1.通过ActionContext访问Servlet API,推荐使用这种,但是这种方案它获取的不是真正的事Servlet API. 步骤: 1 ...

  8. (十五)The Search API

    Now let’s start with some simple searches. There are two basic ways to run searches: one is by sendi ...

  9. [转]你可能不知道的五个强大HTML5 API

    一.全屏 // 找到适合浏览器的全屏方法 function launchFullScreen(element) { if(element.requestFullScreen) { element.re ...

随机推荐

  1. java eclipse环境搭建环境

    开发环境搭建: JDK的安装 http://www.oracle.com/technetwork/java/javase/downloads 下载文件:jdk-8u101-windows-x64.ex ...

  2. 动态获取Android权限

    @TargetApi(23)private void showPhotoDialog() { if (dialog != null && dialog.isShowing()) { d ...

  3. fopen和fopen_s用法的比较 【zz】

    在定义FILE * fp 之后,fopen的用法是: fp = fopen(filename,"w").而对于fopen_s来说,还得定义另外一个变量errno_t err,然后e ...

  4. CSS实现垂直水平居中

    HTML结构: <div class="wrapper"> <div class="content"></div> < ...

  5. Bower安装Bootstrap

    1.Bower简介 官网:https://bower.io/ Bower can manage components that contain HTML, CSS, JavaScript, fonts ...

  6. ACE - ACE_Task源码剖析及线程池实现

    原文出自http://www.cnblogs.com/binchen-china,禁止转载. 上篇提到用Reactor模式,利用I/O复用,获得Socket数据并且实现I/O层单线程并发,和dispa ...

  7. HttpContext.Current.Cache 和HttpRuntime.Cache的区别

    先看MSDN上的解释:      HttpContext.Current.Cache:为当前 HTTP 请求获取Cache对象.      HttpRuntime.Cache:获取当前应用程序的Cac ...

  8. Unity3D 发布无边框exe

    关于:Unity3D 发布无边框exe,Unity3D Build exe无边框 Unity发布windows版本 总是带着边框,很想给它去掉,笔者在网上查了一番,常见的有3中. 1:通过unity3 ...

  9. sass安装 使用

    一 什么是sass      sass是一种css开发工具.提供了很多便利的写法,使得css开发变得简单  易维护       sass有两种后缀名文件:一种后缀名为sass,不使用大括号和分号:另一 ...

  10. 2015GitWebRTC编译实录13

    2015.07.21 libboringssl.a 编译通过主要是生成路径,去除test文件比较啰嗦,后继测试需要重点跟进下 CC obj/third_party/boringssl/boringss ...