Delete Face Maya API

707 views
Skip to first unread message

Dilen Shah

unread,
Jun 8, 2015, 5:29:02 AM6/8/15
to python_in...@googlegroups.com
Hey guys,

I am trying to delete faces from my Mfnmesh using MFnMesh.deleteFace() command but it seems to be not working.

Here is my code:

import maya.OpenMaya as OpenMaya

name = "outputShape"

list = OpenMaya.MSelectionList()
node = OpenMaya.MObject()
list.add(name)
list.getDependNode(0, node)

meshFn = OpenMaya.MFnMesh(node)

meshFn.deleteFace(14)
meshFn.updateSurface()

It does absolutely nothing, can anyone tell me if there is another way to do it in API or am I doing something wrong?

Thank you.

D.

Janos Hunyadi

unread,
Jun 9, 2015, 2:28:26 PM6/9/15
to python_in...@googlegroups.com
Works for me in Maya 2016. I just replaced the outputShape with a simple subdivided plane-s output shape "pPlaneShape1" and it deleted it. It might be something with Viewport 2.0. What maya version are you using? 2015 If I recall correctly might have some update issues with VP 2.0 in python.

J

Dilen Shah

unread,
Jun 10, 2015, 11:45:34 AM6/10/15
to python_in...@googlegroups.com
Hey Janos,

I am using Maya 2014, and it doesnt do it for me, I tried it on a plane and tried to deleteFace, deleteEdge but it didnt do it for me and I am using normal viewport and not viewport 2.0. I am using Python API.

I got no clue why it isnt doing it for me.

D.

Janos Hunyadi

unread,
Jun 11, 2015, 9:59:10 AM6/11/15
to python_in...@googlegroups.com
What you can do it is put it into a plugin. Compute it inside your plugin and output the mesh as a plug. It should work that way.
J

Dilen Shah

unread,
Jun 11, 2015, 10:29:03 AM6/11/15
to python_in...@googlegroups.com
Hey Janos,

Hahahahah, you know what I just did try it couple of hours that, but it still doesn't do anything.

D.

Janos Hunyadi

unread,
Jun 12, 2015, 7:26:32 AM6/12/15
to python_in...@googlegroups.com
Ok I think I remember now. I checked one of my plugins where I had to delete some faces. And the API does seem to be bugged. Here's how I did it :D
Little hack but it should work.

Extract the faces with MFnMesh extractfaces, than use MFnMesh collapseFaces on the extracted faces. After you collapsed them and do an Updatesurface maya "deletes" those faces.

:D

Cheers,
J

Dilen Shah

unread,
Jun 12, 2015, 8:12:16 AM6/12/15
to python_in...@googlegroups.com
Hey Janos,

Thought so, it seems bugged so that's a relief. Well I actually tried that already which was working but was not giving me the result I needed.

So well I chose a safer path of reconstructing the mesh without those faces and thus have a cleaner mesh.

Thanks for your help!

D.

Francesco Leacche

unread,
Oct 6, 2015, 7:19:09 AM10/6/15
to Python Programming for Autodesk Maya
Hello Dilen, 
sorry for rising this old post, anyway I am encountering the same problem: I have to iteratively eliminate group of faces from a mesh. Using MFnMesh.deleteFaces() is horribly slow for each face and using extractFaces doesn't work properly (faces eliminated in the last iteration re-appear in the next iteration). So how did you reconstruct the mesh using only the faces that you needed?

Dilen Shah

unread,
Oct 6, 2015, 2:14:03 PM10/6/15
to Python Programming for Autodesk Maya
Hey Francesco,

Well i went the hard way building the whole mesh without the faces i didnt need, thus getting all the vertices in order and using MfnMesh.create() to build the whole mesh from scratch actually.

I dont know if this is what you wanted but this is how i did it and its faster than deleteFaces() function for sure. 

Hope this helps, reply if you need any more help :)

D.
Reply all
Reply to author
Forward
0 new messages