Wordpress - Hide main div if wp_nav_menu is empty

Assign the menu to a string:

$menu = wp_nav_menu(
    array (
        'echo' => FALSE,
        'fallback_cb' => '__return_false'

if ( ! empty ( $menu ) )
    echo '<div class="navmain2">' . $menu . '</div>';

If you wanted to check there is a menu assigned you could use has_nav_menu(). Passing through the registered menu id as registered via register_nav_menu()

 <?php if ( has_nav_menu( 'primary' ) ) { ?>

    <div class="navmain2">


 <?php }

Note: This function will output the div if the location primary has a menu assigned, it will also output the div if the menu is assigned and empty