MFnNurbsSurface constructor appears to be private in the C++ API.

MFnNurbsSurface constructor appears to be private in the C++ API.

jmreinhart
Advisor Advisor
694 Views
2 Replies
Message 1 of 3

MFnNurbsSurface constructor appears to be private in the C++ API.

jmreinhart
Advisor
Advisor

I am converting a custom deformer that I wrote using the Python API into C++. One error that I have not been able to resolve is this one.

 

Error C2248 'Autodesk::Maya::OpenMaya20180000::MFnNurbsSurface::MFnNurbsSurface': cannot access private member declared in class 'Autodesk::Maya::OpenMaya20180000::MFnNurbsSurface' Project3 c:\users\xxx\source\repos\test_node\project3\xxx.cpp 163

 

I've looked through some similar forum posts and it seems as though this is happening because the constructor for MFnNurbsSurface is private for some reason.  I've updated to the most recent devkit for maya 2018 but that does not resolve it. Is this a known bug, and if so are there any workarounds? Below are what I think are the relevant parts of the code. 

 

inputSurface = tAttr.create("inputSurface", "is", MFnNurbsSurfaceData::kNurbsSurface);

V

V

MDataHandle inputSurface_data = dataBlock.inputValue(inputSurface, &status);
McheckErr(status, "Error getting inputSurface data handle\n");
MObject inputSurface_val = inputSurface_data.asNurbsSurface();

V

V

MFnNurbsSurface mFnSurface = MFnNurbsSurface(inputSurface_val); <<<THIS IS THE LINE THAT CAUSE THE ERRORS

 

Any help or insight would be greatly appreciated.

0 Likes
Accepted solutions (1)
695 Views
2 Replies
Replies (2)
Message 2 of 3

zewt
Collaborator
Collaborator
Accepted solution

It's the copy constructor that's private. You're creating an MFnNurbsSurface and then assigning it to another MFnNurbsSurface.  Just initialize it directly, with no copy:

 

MFnNurbsSurface mFnSurface(inputSurface_val);

 

That's how you usually want to initialize objects in C++.

 

Message 3 of 3

jmreinhart
Advisor
Advisor

Thank you so much. That makes perfect sense and works perfectly. I guess the Autodesk example I had was just very outdated.

0 Likes