五、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 ...
随机推荐
- [NOI2007 Day1] 货币兑换 Cash
vijos P1508 / BZOJ 1492 膜拜了这么久的cdq分治,终于有机会亲自来写了.虽然这个思想很好理解,先做前一半,计算前一半对后一半的影响,再做后一半.但是由于我这个傻Ⅹ,以前既没有做 ...
- Jupyter notebook 安装,初步使用
在学习算法,图像处理过程中,理论结合实际的时候总要写一些程序,我用的是PYTHON.这时候,选择一款称手的工具比较重要.之前我用自带的IDLE,也还可以,但是操作不够便捷,文件组织也不是很好.后来想用 ...
- ubuntu install wine
1 install sUdo add-apt-repository ppa:wine/wine-builds sudo apt-get update sudo apt-get install wine ...
- iOS去除导航栏和tabbar的横线
导航[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetri ...
- php大力力 [044节] PHP的POST语句一定要大写!!if(!empty($_POST['id'])) {
早上花了几个小时,寻找错误!!! 不应该这样写 if(!empty($_Post['id'])) { 应该这样写 if(!empty($_POST['id'])) { 万万不能小谢!
- iOS 利用 Framework 进行动态更新
http://nixwang.com/2015/11/09/ios-dynamic-update/ 前言 目前 iOS 上的动态更新方案主要有以下 4 种: HTML 5 lua(wax)hotpat ...
- 关于项目使用可配置的properties 文件的实现
maven项目在项目install的时候配置如下 注意value的\ 之后利用spring3.0 以后的读取properties 配置如下 然后我们就可以在setter方法 ...
- Java 设计一个贷款计算器 简易
import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.border.*; publi ...
- cocos2d-x 3.2 listview scorllview 等容器在小米华为等部分手机显示泛白解决
感觉记不住,代码贴上以免以后难找 在proj.android\src\org\cocos2dx\cpp\AppActivity.java 中的 public class AppActivity ext ...
- popwindow设置背景半透明
WindowManager.LayoutParams lp = getWindow().getAttributes(); lp.alpha = 0.5f; //0.0-1.0 getWindow(). ...