Has anybody got a trick for running an MFnMesh.create() with proper support outside an MPXCommand? I have yet to figure out a way to do this that doesn’t involve creating a plugin command (with attendant hassles) - I’d really like to just do
def api_mesh(verts, faces):
with SomeMagicalUndoContextGoesHere(): # < but how?
vertpoints = [api.MFloatPoint(v) for v in verts]
polyCounts = [len(f) for f in faces]
polyConnects = [i for i in itertools.chain.from_iterable(faces)]
mObj = api.MObject()
mFn = api.MFnMesh(mObj)
return mFn.create(vertpoints, polyCounts, polyConnects)
I’ve tried the obvious (undoInfo, wrapping in a script, etc) but the meshes created this way are not part of the undo queue so their creation cannot be undone (they can still be deleted - just not undone). If i put it all into an MPXCommand it can be made to work but I’m a whiny baby and I don’t want to do that.
Anybody have a magic trick?