Mfnmesh Split And Update

@rob-bateman
Tue, 26 Sep 2006 16:49:18 +0000

@rob-bateman wrote:

QUOTE(palmtree3141 @ 09/26/06, 05:15 AM) [snapback]248568[/snapback]
I do not want the history retained. I just want to call MFnMesh::split on this mesh and then be able to call split on polygons that are newly created by this original split...

The thing is, you do want the history to be maintained - whether or not history is generated for a scene is not something, you the plug-in developer, has the ability to define. The user determines that, so tough, you have no choice but to retain the history

QUOTE
....but now I cannot, as it appears that any MFnMesh is not in sync with its mesh data after the split. Is there any way to "force" a sync?

It is perfectly in sync, it's just that you've mis-understood what you're actually doing. Currently you have the knife to cut the mesh (MFnMesh::split), but each time you cut it, you are throwing the results away! Remember, each time you access an MObject mesh, it is not a mesh!! It is merely the state of some data at a certain point in the DG, at some given moment in time. You can manipulate that mesh data, however you are only manipulating temporary data - since the next time the DG gets evaluated, it will obliterate the changes that you made to that (temporary) Data.

To do this properly, you need to modify the DG graph so that your operations are stored entirely as a set of connected nodes in the Dependency Graph (so that on the next frame, the same operations are performed again and you still have some split polys). This is basically the crux of what history is in Maya, and everything you do to manipulate Maya's data from the API needs to be part of this history. There is no way around that i'm afraid, you've just got to bite the bullet and go with it.....

You'll notice for example that if you perform a poly split in mel, it inserts a node into the hierarchy. Within the API you need to do the same thing, it's just that the MFnMesh function set is operating on the raw data in the mesh node, as apposed to manipulating the connections between nodes to give you that result. So either, create a polyModifier node type in the API to perform the polySplit on an input mesh and write the result to an output mesh attr - or just use the relevant mel command which will be far simpler.....

QUOTE
Thanks for all your insights so far. Rob, I was a fan of your website when I was learning the API. Very helpful.

no probs