Thanks a lot! It's not very easy to understand the way of using the api... Now I will try to use a proc with api features in a pre render script, ,I don't know if it is possible, as I don't know if API is "reachable" outside maya environment.
I'm wondering about pymel, as it seem to be powerful and much more "pythonic", but I've a few questions: -is pymel easy to install and use? -is there a documentation to find all the functionalities as with the api? -can I do everything with pymel as I could (if I knew ;) ) with the API? Thank you for your help. Philippe. On 25 mar, 20:32, Paul Molodowitch <[email protected]> wrote: > Your proplem is that lsFn.listAllRenderLayers doesn't actually return > a value - instead, it stores it's result in objArr. > > You have to do this. > > import maya.OpenMaya as om > import maya.OpenMayaRender as omRender > > objArr = om.MObjectArray() > lsFn = omRender.MFnRenderLayer() > lsFn.listAllRenderLayers (objArr ) > for i in xrange(objArr.length()): > print omRender.MFnRenderLayer(objArr[i]).name() > > Unfortunately, the API was designed with C++ in mind, so it doesn't > behave very 'pythonically'. If you want a way to interact with the > api that behaves more like you expect, try pymel. > > The same task in pymel: > > from pymel import * > print RenderLayer.listAllRenderLayers() > > Done. =) > > -Paul > > On Wed, Mar 25, 2009 at 10:06 AM, kzax <[email protected]> wrote: > > > Hello, I'm trying to learn how to use the API to solve a problem with > > render layers with pre render script. > > To begin to learn I'm trying to make a list of render layers wich are > > in my scene : > > > import maya.OpenMaya as om > > import maya.OpenMayaRender as omRender > > > objArr = om.MObjectArray() > > lsFn = omRender.MFnRenderLayer() > > l = lsFn.listAllRenderLayers (objArr ) > > print l > > > and the answer is always 'None', but there are render layers in the > > scene! > > What's wrong? > > Thanks, > > Philippe. > > --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/python_inside_maya -~----------~----~----~----~------~----~------~--~---
