In this example renderLayerNode is inside of foo's scope so you can
not use that variable outside of it unless it is a global. I dont use
pymel, I use Maya Python and it would look like this:


def foo():
        global renderLayerNode
        global scpt
        renderLayerNode = "foo"
        renderLayerNodeB = "foobar"

        scpt = 'print renderLayerNode'
        scptB = 'print renderLayerNodeB'

foo()

# this works
exec( scpt, globals() )

# this will fail
exec( scptB, globals() )

What does the scpt variable string look like? What scope is it being
called from? Are you calling variables from other scopes that are not
global?

-RyanT

On Mar 31, 11:46 am, King <[email protected]> wrote:
> Every thing is inside a function.
>
> def foo:
>     renderLayerNode = PyNode( "deaultRenderLayer" )
>     scpt = node.myScript.get()
>
> Suppose script on string attribute on node is:
> print renderLayerNode.name()
> val = renderLayerNode.myAttrib.get()
>
> Using this:
> exec( scpt, globals() )
>
> I get en error:
>
> #   File "D:\maya2008\Python\lib\site-packages\pymel\core\pmcmds.py",
> line 91, in wrappedCmd
> #     res = new_cmd(*new_args, **new_kwargs)
> # RuntimeError: name 'renderLayerNode' is not defined
> # # Traceback (most recent call last):
> # #   File "<maya console>", line 1, in <module>
> # # NameError: name 'renderLayerNode' is not defined
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---

Reply via email to