problem passing MFn::Type as argument C++


#1

Hi Guys,
need some help updating my old Maya2013 plugins to Maya2017. I want to pass MFn::Type as an argument in a procedure simply like below:

MStatus helperTools::getObjectsOfType(MFn::Type fnType, MObjectArray& result)
{
	..
	if(obj.hasFn(fnType))
		result.append(obj)
};

If i now in Maya2017 call

helperTools::getObjectsOfType(MFn::kMesh, obArray)

nothing happens. As if the variable “fnType” carries nothing to compare with MObject.hasFn()
Up to my actual Maya2013 plugin builts however this worked flawlessly.
Any Ideas?
Thanks


#2

Have you checked the result of this line?

if(obj.hasFn(fnType))

It’s possible the fnType is no longer considered a valid function set between the two Maya versions.
Have you also tried debug statements to check what MFn::Type the object you’re querying is?

#include <iostream>
...
std::cerr << "Object MFn::Type: " << obj.apiTypeStr() << std::endl;


#3

No thats nothing about outdated function sets. Maybe i was a bit unclear:

MStatus someProcedure(MFn::Type marmelade, MObjectArray& obArray){
	..
	if(someMObject.hasFn(MFn::kMesh))
		obArray.append(someMObject);
		// objects of type kMesh gets recognized properly
		
	if(someMObject.hasFn(marmelade))
		obArray.append(someMObject);
		// if "marmelade" is set to MFn::kMesh nothing gets recognized

So this is just about syntax. But checking compatibility for variing function sets should be a quite trivial task, how do we do that??
regards


#4

For the records i solved this weird bug by simply creating a new plugin using the pluginwizard, created all the neccessary classes inside VisualStudio and after that replaced all the .h/.cpp files by the old ones.