long name

19 views
Skip to first unread message

Adynsky

unread,
Jun 28, 2018, 7:09:07 AM6/28/18
to Python Programming for Autodesk Maya


Hi guys,

I have been creating the script for ctrl. Everything working well, except if there is same name in hierarchy. Here is part of the script:

def createControl(suffix='ctrl',
                  groups=['Zro', 'offset],
                  gimbal=None,
                  gimbalSize=0.5,
                  shape=SQUARE,
                  connect=['parentCons']):

    for obj in mc.ls(sl=1):
        ctrl     = controller(shape)
        renCtrl  = mc.rename(ctrl,'%s_%s' % (prefixName(obj), suffix))
        grpPrnt  = groupParent(groups, '%s' % prefixName(obj), suffix.title())
        parCtrl  = mc.parent(renCtrl, grpPrnt[-1])
        cnntCtrl = renCtrl
        lockAttrObj(cnntCtrl, 'visibility')

....


and the result as is on the image attachment. 

So, I have googling it and I found the answer that I need to query the long name first. I have tried but unfortunately I'm stuck to solve that. Any solution or insight?! Thanks in advance!


Capture.JPG

Fuzes Marcell

unread,
Jun 28, 2018, 7:19:05 AM6/28/18
to python_in...@googlegroups.com
The list command has a flag "long" so this should work
mc.ls(sl=1, long = 1)

Adien Dendra

unread,
Jun 28, 2018, 7:28:28 AM6/28/18
to python_in...@googlegroups.com
​Hi,

I have tried that, but still doesn't work.​

On Thu, Jun 28, 2018 at 6:19 PM, Fuzes Marcell <fuzes....@gmail.com> wrote:
The list command has a flag "long" so this should work
mc.ls(sl=1, long = 1)

--
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 python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CANC2f3RKR_2NhTCGnSrC9X5gooon9kZ-azS92iKx5swuZEvwRQ%40mail.gmail.com.

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

Chad Fox

unread,
Jun 28, 2018, 9:59:07 AM6/28/18
to Python Programming for Autodesk Maya
We'd likely need to see what your functions " controller()" and "groupParent()" are doing. Or if you can provide more details such as where your script fails when there's a duplicate name we might be able to clear up this issue.



-Chad



On Thu, Jun 28, 2018 at 4:28 AM Adien Dendra <adien....@gmail.com> wrote:
​Hi,

I have tried that, but still doesn't work.​
On Thu, Jun 28, 2018 at 6:19 PM, Fuzes Marcell <fuzes....@gmail.com> wrote:
The list command has a flag "long" so this should work
mc.ls(sl=1, long = 1)

--
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 python_inside_m...@googlegroups.com.

--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAE5XL931wBfwMAFmutC4EQ9WQhV480NjZ_TnxeAxC2wL%3DeV%3DfA%40mail.gmail.com.

Adynsky

unread,
Jun 28, 2018, 11:36:40 AM6/28/18
to Python Programming for Autodesk Maya
Hi there,

The problem is when the script working the loop with the same name object on selection of hierarchy. As you can see on the image attachment that the arm01_ctrl won't be parented to arm02CtrlOffset_grp. I think this is caused by two of arm02CtrlOffset_grp, and the curve of arm01_ctrl (belongs to arm02CtrlZro_grp1) woudn't identify the base (top) of parent name. Here is the groupParent function

def groupParent(groups, prefix, suffix):
    grps = []
    for i in range(len(groups)):
        grps.append(mc.createNode('transform', n="%s%s%s_%s" % (prefix, suffix, groups[i], GROUP)))

        if i > 0:
            mc.parent(grps[i], grps[i-1])
    return grps

Thanks!

Reply all
Reply to author
Forward
0 new messages