Correct, I only know after the fact.

I got it working by running the following: pm.menu(my_menu, q=True,
numberOfItems=True)

I was trying to be more Pythonic via PyMEL by running this:
my_menu.getNumberOfItems() but that method apparently doesn't exist for the
menu item (which is of type commandMenuItem I think). Again I must be
overlooking something silly in my access attempt here.

On Fri, Oct 9, 2015 at 9:57 AM, Marcus Ottosson <konstrukt...@gmail.com>
wrote:

> Just to perhaps state the obvious, I suppose ideally you would look at the
> items you are *about* to create and determine whether or not to create the
> menu in the first place, but maybe that's not an option in this case?
>
> On 9 October 2015 at 18:02, Kenneth Ibrahim <kenibra...@gmail.com> wrote:
>
>> Thx for the response. I had thought that was the case and had tried using
>> PyMEL's 'getNumberOfItems' method to no avail. I'll have a look at your
>> code reference and see what I was doing wrong.
>>
>> Cheers! Ken
>>
>> On Fri, Oct 9, 2015 at 12:03 AM, Robert White <robert.wd.wh...@gmail.com>
>> wrote:
>>
>>> So, subMenus are really just menus, which means you can query the
>>> itemArray value and get a list of their children, if that list is empty,
>>> you've got an empty subMenu.
>>>
>>> I've got an example of how to search a top level menu recursively and
>>> return a list of all the empty subMenus:
>>> https://gist.github.com/bob-white/322e0e77f8d21468b8e2
>>>
>>> One annoyance with the itemArray query, is that it returns the short
>>> name of the menuItem, so you need to combine it with it's parent to query
>>> any of it's children. But otherwise it just works.
>>>
>>> On Thursday, October 8, 2015 at 8:36:32 PM UTC-5, Ken Ibrahim wrote:
>>>>
>>>> Silly question here but I haven't figured this out yet nor come across
>>>> the answer online.
>>>>
>>>> What's the best way to determine the number of submenus a menuItem has
>>>> after it's been created? I have a system that dynamically adds menu items
>>>> based on certain criteria. After that work is done I'd like to disable the
>>>> menu (or remove it) if the total number of children is zero.
>>>>
>>>> Assume that I cannot get the number of items explicitly before creating
>>>> the menu and that I'm using PyMEL's "with" nested structure to create the
>>>> menu hierarchy.
>>>>
>>>> Thx!
>>>>
>>>> Ken
>>>>
>>>> --
>>>> "God is a metaphor for a mystery that absolutely transcends all human
>>>> categories of thought. It's as simple as that!" - Joseph Campbell
>>>>
>>> --
>>> 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+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/ed6170c2-5521-41c3-9c59-45f9b58e1895%40googlegroups.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/ed6170c2-5521-41c3-9c59-45f9b58e1895%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> "God is a metaphor for a mystery that absolutely transcends all human
>> categories of thought. It's as simple as that!" - Joseph Campbell
>>
>> --
>> 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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/CAP_aC5bA%2Bqzbqs0WCe_DrkzJkAWO_qyWtV2fRREDJV%3D8_akHvA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/python_inside_maya/CAP_aC5bA%2Bqzbqs0WCe_DrkzJkAWO_qyWtV2fRREDJV%3D8_akHvA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> *Marcus Ottosson*
> konstrukt...@gmail.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_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAD5YWpvHVZAg3Rfj4BXw_26fQJQWndj%2B6QtnugLZBVaw%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAD5YWpvHVZAg3Rfj4BXw_26fQJQWndj%2B6QtnugLZBVaw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
"God is a metaphor for a mystery that absolutely transcends all human
categories of thought. It's as simple as that!" - Joseph Campbell

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAP_aC5aA9%3DYeVB9z8dNk-cN7kHhFb%3DzpufiUS1GZLd352oBn5g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to