Actually, even after all of my years (12+) working with Maya, I've got a question on this one too--has anyone found a reliable way to get around maya creating a group with a name which returns only the short path (not even the shortest unique path)? Is the only way to rename the group after the creation? Or, is there an API function that I'm missing that will return the actual long group name? My current workaround is running a cmds.ls on any nodes I create with long=true, but with a group that returns a list of possible nodes; like so:

node = cmds.ls(cmds.group(empty=True, name="testGRP"), long=True)

if I have a group such as "|test|testGRP", node will equal [u'|test|testGRP', u'|testGRP']

Of course, the intention is that node would equal [u'|testGrp'] so that I could use node[0] to reference it, versus arbitrarily guessing which is the correct node. This is one of those cases where I miss using PyMEL currently :)

My current solution is to use something more like this:

node = cmds.group(empty=True, world=True, name="testGRP")
foundNode = cmds.ls("|{0}".format(node), long=True)

But for obvious reasons, that feels fairly silly and highly unpythonic :)

Also, as an update, I talked to Steven Roselle at GDC, and he said that Python API 2.0 is still very high on their list of priorities, but has no updates in 2015 :(

Joe

On 3/19/2014 10:56 AM, Marcus Ottosson wrote:
I see. It's generally a good approach to work with full-paths throughout, and if you do, you should encounter little difficulty in paths across packages. Even duplicate names across hierarchies are unique given a full path.


On 19 March 2014 17:44, Eric Thivierge <[email protected] <mailto:[email protected]>> wrote:

    Thanks Marcus,

    The problem I'm facing currently is that I need to write data to a
    json file that can be read in and interperated by both Softimage
    and Maya. So I have to store object names consistently when
    exporting from Softimage or Maya. I'm probably more in favor of
    mimicking the Maya format at this point since, well you know why.

    Thanks,
    Eric T.


    On Wednesday, March 19, 2014 1:12:25 PM, Marcus Ottosson wrote:

        In Maya, the hierarchy is included in a node's path but gets
        discarded
        most of the time and instead the artist is trusted to keep his
        names
        unique. The reason this is the case is because in Maya, there
        is no
        "hierarchy". Maya is inherently node-based; Softimage on the other
        hand does have the notion of a hierarchy.

        Thus, a full path of a pCube1 may be resolve
        into'|a_group|another_group|pCube1', the | being the separator.

        You can ask for full paths via cmds.ls <http://cmds.ls>
        <http://cmds.ls>(long=True),

        other commands have similar flags, such as
        cmds.listRelatives(fullPath=True) that ultimately do the same
        thing;
        concatenate the depth-first path of a node within a graph.

        Additionally, Maya has the notion of namespaces, which
        encapsulates
        nodes similar to how Models encapsulates nodes in Softimage,
        however I
        would suggest sticking with hungarian notation at first as
        namespaces
        are tricky to understand at first.

        Best,
        Marcus


        On 19 March 2014 15:00, Eric Thivierge <[email protected]
        <mailto:[email protected]>
        <mailto:[email protected]
        <mailto:[email protected]>>> wrote:

            Hah. Well, yeah...  thanks.

            On Wednesday, March 19, 2014 10:59:10 AM, damon shelton wrote:

        cmds.ls <http://cmds.ls> <http://cmds.ls> <http://cmds.ls>
        ('*pCube1', long=True)



                On Mar 19, 2014 7:54 AM, "Eric Thivierge"
                <[email protected]
        <mailto:[email protected]> <mailto:[email protected]
        <mailto:[email protected]>>
                <mailto:[email protected]
        <mailto:[email protected]>

                <mailto:[email protected]
        <mailto:[email protected]>>__>> wrote:

                    Hello all,

                    This may seem like a simple question but my Googling
                didn't return
                    any useful results.

                    I have a name of an object 'pCube1'. I need to
        find it in
                the Maya
                    scene. Problem is, I may have multiple objects in the
                scene that
                    are named the same thing. Even in the same hierarchy
                (Crazy that
                    Maya lets you do this btw). Is there a way to get
        a list
                of all
                    objects that are named 'pCube1'? Once I get that
        list I
                need to
                    find the top most parent in the scene. From there
        I can
                find the
                    one I need.

                    When I try to listRelatives, it throws an error saying
                there is
                    more than one node int he scene that is name 'pCube1'.

                    # PyMel
                    print pm.objExists('pCube1')

                    parents = pm.listRelatives('pCube1', allParents=True)
                    for eachItem in parents:
                        print eachItem.name()

                    Thanks,
                    Eric T.

                    --
                    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]
        <mailto:python_inside_maya%[email protected]>
<mailto:python_inside_maya%[email protected]
        <mailto:python_inside_maya%[email protected]>>

<mailto:python_inside_maya%[email protected]
        <mailto:python_inside_maya%[email protected]>
<mailto:python_inside_maya%[email protected]
        <mailto:python_inside_maya%[email protected]>>__>.



                    To view this discussion on the web visit
        
https://groups.google.com/d/____msgid/python_inside_maya/____5329AFAD.5080403%40hybride.com
<https://groups.google.com/d/__msgid/python_inside_maya/__5329AFAD.5080403%40hybride.com>

<https://groups.google.com/d/__msgid/python_inside_maya/__5329AFAD.5080403%40hybride.com <https://groups.google.com/d/msgid/python_inside_maya/5329AFAD.5080403%40hybride.com>__>__.
                    For more options, visit
        https://groups.google.com/d/____optout
                <https://groups.google.com/d/__optout>

                    <https://groups.google.com/d/__optout
                <https://groups.google.com/d/optout>>.


                --
                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]
        <mailto:python_inside_maya%[email protected]>
<mailto:python_inside_maya%[email protected]
        <mailto:python_inside_maya%[email protected]>>
<mailto:[email protected]
        <mailto:python_inside_maya%[email protected]>

<mailto:python_inside_maya%[email protected]
        <mailto:python_inside_maya%[email protected]>>>.

                To view this discussion on the web visit
        
https://groups.google.com/d/__msgid/python_inside_maya/__CAM9RXoLb37cQR4QB8R6eshN1PmT95__n3uGY9qJicLtHFoEhQjLw%40mail.__gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAM9RXoLb37cQR4QB8R6eshN1PmT95n3uGY9qJicLtHFoEhQjLw%40mail.gmail.com> <https://groups.google.com/d/__msgid/python_inside_maya/__CAM9RXoLb37cQR4QB8R6eshN1PmT95__n3uGY9qJicLtHFoEhQjLw%40mail.__gmail.com?utm_medium=email&__utm_source=footer <https://groups.google.com/d/msgid/python_inside_maya/CAM9RXoLb37cQR4QB8R6eshN1PmT95n3uGY9qJicLtHFoEhQjLw%40mail.gmail.com?utm_medium=email&utm_source=footer>>.

                For more options, visit
        https://groups.google.com/d/__optout
                <https://groups.google.com/d/optout>.


            --
            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]
        <mailto:python_inside_maya%[email protected]>
            <mailto:python_inside_maya%[email protected]
        <mailto:python_inside_maya%[email protected]>>.
            To view this discussion on the web visit
        
https://groups.google.com/d/__msgid/python_inside_maya/__5329B11D.4040200%40hybride.com
<https://groups.google.com/d/msgid/python_inside_maya/5329B11D.4040200%40hybride.com>__.



            For more options, visit https://groups.google.com/d/__optout
            <https://groups.google.com/d/optout>.




        --
        *Marcus Ottosson*
        [email protected] <mailto:[email protected]>
        <mailto:[email protected] <mailto:[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]
        <mailto:python_inside_maya%[email protected]>
        <mailto:[email protected]
        <mailto:python_inside_maya%[email protected]>>.
        To view this discussion on the web visit
        
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCB%2BTeeUmXjjM2eBYbnFLDELt%2BZB-gBfH8L2L1QChnE-w%40mail.gmail.com
        
<https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCB%2BTeeUmXjjM2eBYbnFLDELt%2BZB-gBfH8L2L1QChnE-w%40mail.gmail.com?utm_medium=email&utm_source=footer>.


        For more options, visit https://groups.google.com/d/optout.





--
*Marcus Ottosson*
[email protected] <mailto:[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] <mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODcD4zs%3DKJhAYr2e4DKcvhtZ%2BQMXwYRbKPz2M2zP7rXSg%40mail.gmail.com <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODcD4zs%3DKJhAYr2e4DKcvhtZ%2BQMXwYRbKPz2M2zP7rXSg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
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/532D3739.7010301%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to