SCENE.locator1 would return an instance of a PyNode which no longer
provides you with the dot-notation for grabbing children, so daisy-chining
them wouldn't work.

>>> SCENE.a.b.locator1  # <-- won't work

The '|' is a bitwise operator and unless implemented will return a bitwise
OR from its left- and right-hand sides.

>>> SCENE.a | b | locator1  # <-- won't work, b isn't defined and |
wouldn't know what to do with it if it was

As for duplicate names.. the only possibly solution SCENE could offer you,
other than throw an exception, would be to hide duplicates and only return
one of the possible matches. This would lead to some unpredictable code on
your end.

Why not stick with pm.PyNode('|a|b|locator1')?

To make it hide duplicates, you could do:

def SCENE(name):
    single_result = (pm.ls(name) + [None])[0]
    return pm.PyNode(single_result) if single_result else None

>>> SCENE('locator1')

Or

SCENE = lambda name: pm.PyNode((pm.ls(name) + [None])[0])

>>> SCENE('locator1')

Or

class SCENE(object):
   def __getattr__(self, name):
        single_result = (pm.ls(name) + [None])[0]
        return pm.PyNode(single_result) if single_result else None

>>> SCENE.locator1


On 28 March 2014 00:56, Matt Estela <[email protected]> wrote:

> If I'm being lazy for quick 5 line scripts I'll use something like
>
> important_thing = SCENE.hero_curve_shape
>
> I've had a few occasions where the thing I want is a few groups down, and
> I haven't been able to use the 'SCENE.' syntax.
>
> Anyone know what the trick is?
>
> Eg, I have locator1, and a|b|locator1:
>
> SCENE.locator1
> # Error: MayaNodeError: file C:\Program
> Files\Autodesk\Maya2014\Python\lib\site-packages\pymel\core\general.py line
> 1754: Multiple maya Nodes existed: u'locator1' #
>
> SCENE.a|b|locator1
> # Error: NameError: file <maya console> line 1: name 'b' is not defined #
>
> SCENE.'a|b|locator1'
> # Error: invalid syntax #
>
>  --
> 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/CAGCWdhki%2BzyvaJhVwR%2BbK%3D71LPvSti-2xVJbo80XC6_w23C5qg%40mail.gmail.com<https://groups.google.com/d/msgid/python_inside_maya/CAGCWdhki%2BzyvaJhVwR%2BbK%3D71LPvSti-2xVJbo80XC6_w23C5qg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*Marcus Ottosson*
[email protected]

-- 
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/CAFRtmOD%2B9MyROKGe6AOnHGgKVGxf4otHvDTM3DjFvqp4h-0%3DnQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to