0

Im writing an exporter that exports the subdivision preview mesh via the 'generateSmoothMesh()' method like this:

MFnMesh mesh(mesh_dag_path);

MFnMesh subdiv_mesh(mesh.generateSmoothMesh());

but after the export finishes the new subdivided geometry is left in my maya scene. How should i deal with this geometry, or is this even the right way to be doing this export?

my first instinct is to delete the geometry after the export is finished, if this is the correct thing to do does anybody know he correct way to delete the geometry from the api

jonathan topf
  • 7,897
  • 17
  • 55
  • 85

1 Answers1

0

Saying you need to do it from the API makes me think this is a command plugin. Correct me if I'm wrong. One way to do it is to run MEL code from your plugin with MGlobal .

MGlobal::executeCommand(MString("delete meshTransform;"));

Where meshTransform is the transform of the newly created mesh. You can get it by having parentOrOwner be MObject::kNullObj.

Or you can directly use:

MGlobal::deleteNode()

scroll_lock
  • 143
  • 2
  • 11
  • Or use MGlobal::deleteNode(). – Andreas Haferburg Apr 26 '13 at 06:43
  • Correct. I will include this in the answer aswell. – scroll_lock Apr 26 '13 at 15:33
  • it is indeed a command plugin, in fact its designed to be a more feature complete .obj exporter. Does this behaviour sound correct, that a temporary piece of geometry gets created in the scene during export? – jonathan topf Apr 30 '13 at 09:13
  • I think it is fine as long as you make sure to restore the scene in the original state. – scroll_lock Apr 30 '13 at 21:50
  • Most of the time you don't just call a function and get a result, but instead add nodes to the dependency graph, make connections, let Maya evaluate the graph, then fetch the result. Given the way Maya is designed, yes, it does sound correct. – Andreas Haferburg May 01 '13 at 11:53