Figured it out. Actually, it makes perfect sense now. I rewrote the whole thing in C++ so I could make sure the logic was sound, and in the process figured out why things weren't working (as well as getting a better understanding of the API as a whole).
For future reference (I know most of you probably understand this, but it's not well documented), Function Sets (like MFnMesh) are seperate entities from the objects they attach to. So, when I set meshObj = meshObj.create(blah blah argument blah), I actually overwrote the function set with a raw MObject. Hence the attribute error (MObjects don't have a function for setFaceVertexNormals). Yet another reason I do like C++ -- it forces me to think about what type each variable is as I work. So, if instead I use meshObj = fnMesh.create() followed by fnMesh.setObject(meshObj), it works. Here's the fixed version (lines 58-74 specifically): http://pastebin.com/TTXK7b7m Joe On Fri, May 30, 2014 at 1:57 AM, Joe Weidenbach <[email protected]> wrote: > Hello again all, > > I'm working on what will eventually be a mesh tool that will handle > mirroring, defining snap points, etc. I'm trying to get the API down as I > go. > > So far, I've got it copying the basics of the mesh just fine (and it drops > down to the object space, so it doesn't need to worry about transforms that > have been applied) > > However, I've started in on setting more options, and when I try to set > the specified normals, I get the following error: > > # Traceback (most recent call last): > # File "d:/Users/weidenba/Documents/maya/scripts\meshtool.py", line 174, > in getInfo > # cObj.create() > # File "d:/Users/weidenba/Documents/maya/scripts\meshtool.py", line73, > in create > # meshObj.setFaceVertexNormals(normalsArr, faceArr, vertArr) > # File > "E:\workspace\bre-maya-2014ext-w7\build\Release\runTime\Python\Lib\site-packages\maya\OpenMaya.py", > line 1539, in <lambda> > # File > "E:\workspace\bre-maya-2014ext-w7\build\Release\runTime\Python\Lib\site-packages\maya\OpenMaya.py", > line 54, in _swig_getattr > # AttributeError: setFaceVertexNormals > > Here's the code: http://pastebin.com/ze8SPvtT > > I also tried meshObj.setNormals with similar results. It doesn't say > anything in the API docs about this not working in Python, and Wing > autocompletes it for me, so not sure what I'm doing wrong. > > I do have a vague recollection of needing to use an MItVertex for changing > attributes in another case, but that might also have been to get more > detailed data, I honestly can't remember now (but then it's late). > > Any ideas would be helpful :) > > Thanks, > > Joe > > > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAM33%3Da6b_9xU%2BEnkOGtCEdRhHZozakTPgrWeeSN3cZxxL22FUA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
