First, like my previous example, you should ditch using strings for your
callbacks when they are just calling your own functions, and just reference
the callable object:
def someCallback(*args):
print "callback!"
mc.button(command=someCallback)
That being said, you can name your polyCube the same way you are generating
a name for the menuItem:
name = 'new%d' % ind
mc.menuItem(name, label=name, c='mc.polyCube(n=%r)' % name)
On Wed Nov 19 2014 at 06:05:40 maya2000 <[email protected]> wrote:
> Thank!
> i dont want query for the last button....
> i write a programe...it create a new menu Item(or button):
> the new menuItem run a function...now the function have a argument...i
> want>>>the argument=menuItem name:
> example:
> import maya.cmds as mc mc.window() mc.frameLayout ('ABC')
> mc.button(label='create1', command="NI()") mc.showWindow() import random
> def NI(): mc.setParent('ABC') mc.symbolButton(image='setKeyframe.png',
> command='pass' ) mc.popupMenu(button=1 ) ind=random.randrange(1,1000)
> mc.menuItem('new'+str(ind),label='new root',c='mc.polyCube(n="new")')##
> new=menuItem Name thet press....<<<<<<<<<
> now i want when press menuItem(example) , my program create new cube
> thet...cube name is menuItem name that press....
>
> --
> 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/3dca7864-bf32-4de0-9ec8-6d8a090ad704%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/3dca7864-bf32-4de0-9ec8-6d8a090ad704%40googlegroups.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/CAPGFgA3mmeyE1C3wb5KEPUHyrLL%2B5UaM44jauAEzn%3D3g_LSBaA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.