1

Hi!

I'm writing a "simple" Maya command in C++, in witch I need to select from the scene (like the ls command in MEL).

But I don't know how to identify an MFn::Type data based on a string name like "gpuCache".

Actually my (very stupid) parser does a simple if that identify the MFn::Type based on two options: if the node name is "gpuCache" sets the filter using MFn::Type::kPluginShape, otherwise use kDagNode (or kShape, or whatever fits my needs for a broad identification for as many nodes as possible, for a later use of the typeName() of the MFnDagNode class).

This is the "filterByType" function, that I want to use to convert a type defined by String in a type defined by MFn::Type.

MFn::Type Switch::filterByType( MString type )
{
    MFn::Type object_type;

    object_type = MFn::Type::kDagNode;

    MNodeClass node_class( type );
    MGlobal::displayInfo( MString("Type Name: " + node_class.typeName()) );

    return object_type;
}

Can someone help me, or I need to call a MEL/Python command from C++ (a thing that I really don't want to do) to get this thing done?

Thanks!

Andrea Rastelli
  • 617
  • 2
  • 11
  • 26
  • I am not entirely sure what you're asking - what would be the ls commend equivalent? why calling the MEL command from C++ a problem? you surely don't want to call the Python command, because it is a wrapper of the MEL command and will slowdown execution, but it is perfectly valid to do. – cyrille Mar 25 '16 at 14:18
  • Otherwise, don't you want to use lsType() instead? – cyrille Mar 25 '16 at 14:27

1 Answers1

0

you can try get type from number from MFnBase > typeString(int)

at lease you can do it via python

import maya.OpenMaya as om
om.MGlobal.displayInfo(" i| apiType({}) = {}".format(178, om.MFnBase.typeString(178)))
bafly
  • 23
  • 4