五、selecting with the API
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的更多相关文章
- 数字货币比特币以太坊买卖五档行情数据API接口
数字货币比特币以太坊买卖五档行情数据API接口 数字货币一般包含比特币BTC.以太坊ETH.瑞波币XRP.泰达币USDT.比特币现金BCH.比特币SV.莱特币LTC.柚子币EOS.OKB. ...
- Html5 学习系列(五)Canvas绘图API快速入门(2)
Canvas绘图API Demos 上一篇文章中,笔者已经给大家演示了怎么快速用Canvas的API绘制一个矩形出来.接下里我会在本文中给各位介绍Canvas的其他API:绘制线条.绘制椭圆.绘制图片 ...
- Kafka(五)Kafka的API操作和拦截器
一 kafka的API操作 1.1 环境准备 1)在eclipse中创建一个java工程 2)在工程的根目录创建一个lib文件夹 3)解压kafka安装包,将安装包libs目录下的jar包拷贝到工程的 ...
- Web API(五):Web API跨域问题
一.什么是跨域问题 跨域:指的是浏览器不能执行其他网站的脚本.是由浏览器的同源策略造成的,是浏览器施加的安全限制.(服务端可以正常接收浏览器发生的请求,也可以正常返回,但是由于浏览器的安全策略,浏览器 ...
- 使用ASP.NET Web Api构建基于REST风格的服务实战系列教程【五】——在Web Api中实现Http方法(Put,Post,Delete)
系列导航地址http://www.cnblogs.com/fzrain/p/3490137.html 前言 在Web Api中,我们对资源的CRUD操作都是通过相应的Http方法来实现——Post(新 ...
- Html5 学习系列(五)Canvas绘图API快速入门(1)
引言:Canvas绘图API快速入门 在接触HTML5的初学者包括我都在很多地方见到非常炫的一些页面,甚至好多学习HTML5的开发者都是冲着Web端的页游去的,那么HTML5那么绚丽的页面效果以及游戏 ...
- Struts2学习笔记(五)——Action访问Servlet API
在Strut2中访问Servlet API有三种方式: 1.通过ActionContext访问Servlet API,推荐使用这种,但是这种方案它获取的不是真正的事Servlet API. 步骤: 1 ...
- (十五)The Search API
Now let’s start with some simple searches. There are two basic ways to run searches: one is by sendi ...
- [转]你可能不知道的五个强大HTML5 API
一.全屏 // 找到适合浏览器的全屏方法 function launchFullScreen(element) { if(element.requestFullScreen) { element.re ...
随机推荐
- python 程序构架
http://blog.csdn.net/heyabo/article/details/8806176
- android 缓存Bitmap 使用内存缓存
private LruCache<String, Bitmap> mMemoryCache; /** * 判断内存大小 设置位图的缓存空间 */ private void judgeMem ...
- tinyXML的用法,用于解析gpx文件
tinyxml是一个开源的C++xml解析工具集,简单.轻量而又高效,所以对于处理xml文件是一个非常不错的选择. 由于它开源,所以可以方便地免费下载,下载地址百度一下很容易找到,这里就不多说了. 下 ...
- JavaScript中__proto__与prototype的关系
一.所有构造器/函数的__proto__都指向Function.prototype,它是一个空函数(Empty function) 1 2 3 4 5 6 7 8 9 Number.__proto__ ...
- magento jQuery冲突N种方法
在做修改模板的时候在page中加入jquery库发现原本自带的js冲突 商品无法加入购物车,很多js都没有效果 这是jQuery和magento自带prototype的冲突解决版本有很多种,说个简单点 ...
- 标准库中的-stack
#include <sequence_concepts.h> __STL_BEGIN_NAMESPACE // Forward declarations of operators == a ...
- ucos3的配置文件
1,配置文件,用于系统的裁剪 均有详细的注释 为组件的开关 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ...
- Array函数
array_flip()例子 , , "c" );$trans = array_flip($trans);print_r($trans);?> 答案: Array ( [1] ...
- Objective-c——UI进阶开发第一天(UIPickerView和UIDatePicker)
一.知识点 1.介绍数据选择控件UIPickerView和日期选择控件UIDatePicker控件 * UIPickerView的案例 * 点餐系统 * 城市选择 * 国旗选择 * UIDatePic ...
- Maven学习 (一) 搭建Maven环境
有两种方式可以配置maven的环境配置,本人推荐使用第二种,即使用本地的maven安装文件,个人感觉这样可以方便管理下载jar包的存放位置,错误信息的输出等,可以在dos窗口中可以清晰看到,虽然比 ...