五selecting with the API

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了五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 = 0; 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的主要内容,如果未能解决你的问题,请参考以下文章

R语言筛选dataframe分组中值最大的行实战(Select the row with the maximum value in each group)

Entity Framework Configuring Relationships with the Fluent API

angularjs: $http.get with null parameters are not hitting the Web API controller

Get JSON with the jQuery getJSON Method

[Mise] Refetch API data when a state value changes with the `$watch` property in Alpine JS

[Mise] Refetch API data when a state value changes with the `$watch` property in Alpine JS