Unfortunately, the rebuild subdivision levels functionality isn’t directly exposed through the SDK, but it is possible to call any menu item in Mudbox (including this one) via Qt.
So what you will want to do is:
// build a list of geometries you wish to operate on. QList<mudbox::Geometry *> aGeos ; // you populate this list. // get a pointer to the QMenu widget for the mesh menu QMenu *pQ =Kernel ()->Interface ()->DropDownMenu (Interface::ddmMesh) ; // Enumerate over the menu items. // Find the item that corresponds to the rebuild subd levels item QList<QAction *> pL =pQ->actions () ; QAction *pA =NULL ; for ( int i =0 ; i < pL.size () ; ++i ) { Kernel ()->Log (QString ("action %1").arg (pL [i]->text ())) ; if ( pL [i]->text () == "Rebuild Subdivision Levels" ) { pA =pL [i] ; break ; } } if ( pA ) { for ( int i =0 ; i < aGeos.size () ; ++i ) { // Set the active geometry. This indicates which geometry the rebuild command should operate on. Kernel ()->Scene ()->SetActiveGeometry (aGeos [i]) ; // trigger the rebuild subd menu item. pA->activate (QAction::Trigger) ; } }
However, the DropDownMenu() method is only available in Mudbox 2014, so for previous releases you need to go with pure QT programming. Something like this:
// build a list of geometries you wish to operate on. QList<mudbox::Geometry *> aGeos ; // you populate this list. QWidget *pWidget =Kernel ()->Interface ()->MainWindow () ; QMainWindow *pMW =dynamic_cast<QMainWindow *>(pWidget) ; QAction *pA =NULL ; if ( pMW ) { // get the menu bar of the main widget, and find the mesh menu. // QMenuBar doesn’t seem to expose an API for querying the menus // so inspect all of its children. QMenuBar *pMB =pMW->menuBar () ; QList<QMenu *> pMenus =pMB->findChildren<QMenu *>() ;//QString ("Mesh")) ; for ( int i =0 ; i < pMenus.size () && pA == NULL ; ++i ) { if ( pMenus [i]->title ().contains (QString ("Mesh"), Qt::CaseInsensitive) ) { QMenu *pMenu1 =pMenus [i] ; QList<QAction *> pActions =pMenu1->findChildren<QAction *>() ;//QString ("Rebuild Subdivision Levels")) ; for ( int j =0 ; j < pActions.size () ; ++j ) { Kernel ()->Log (QString ("action %1, %2").arg (i).arg (pActions [j]->text ())) ; if ( pActions [j]->text ().contains (QString ("Rebuild Subdivision Levels"), Qt::CaseInsensitive) ) { pA =pActions [j] ; break ; } } } } } if ( pA ) { for ( int i =0 ; i < aGeos.size () ; ++i ) { // Set the active geometry. This indicates which geometry the rebuild command should operate on. Kernel ()->Scene ()->SetActiveGeometry (aGeos [i]) ; // trigger the rebuild subd menu item. pA->activate (QAction::Trigger) ; } }
Comments
You can follow this conversation by subscribing to the comment feed for this post.