Extracting Face with the Python API

227 views
Skip to first unread message

br...@meljunky.com

unread,
Oct 26, 2008, 2:47:49 AM10/26/08
to python_inside_maya
I wrote some API code that I have been testing in the script editor:

It is suppose to separate the first 10 polygons of a 10*10 plane.

import maya.OpenMaya as OpenMaya
selection = OpenMaya.MSelectionList()
OpenMaya.MGlobal.getActiveSelectionList( selection )
dagPath = OpenMaya.MDagPath()
component = OpenMaya.MObject()
iter = OpenMaya.MItSelectionList( selection )
iter.getDagPath( dagPath, component )
meshFn = OpenMaya.MFnMesh( dagPath )
trans = OpenMaya.MFloatVector()
faces = OpenMaya.MIntArray()
for i in range (10):
    faces.append(i)
meshFn.extractFaces( faces, trans )
meshFn.updateSurface()

After executing the code the 10 faces show up in Polygons->Border Edges which is expected.

If I try to separate the polygons using Mesh->Separate it does not work.
If you try to move the separated faces, Maya freaks out in the view port (That is the technical term).

For it to work I have to delete history on the plane then use Mesh->Separate. Don't think I should have to delete history for it to work. ( I am assuming separate command is heavily involved in MFnMesh since their is no function for separate). 

I notice strange results from a couple other functions like duplicateFaces.

Thanks in advance,
-Brian

Dean Edmonds

unread,
Oct 26, 2008, 3:42:48 AM10/26/08
to python_in...@googlegroups.com
I see the odd behaviour but don't know what's causing it. Please log a
bug with Autodesk.

--
-deane

Reply all
Reply to author
Forward
0 new messages