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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to