In Maya 2017, there are 4 new API’s are exposed in MPxSelectionContext class namely setAllowPreSelectHilight(), setAllowSoftSelect(), setAllowSymmetry(), setAllowDoubleClickAction().
Please go through the following link for how to use the selection tool. https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2017/ENU/Maya/files/GUID-60FD5F79-AC1D-46DE-B66D-2FBE73E15A30-htm.html
In UI method, you can enable/disable and use all the selection methods. However, it is possible to use the same functionalities using MEL and C++ API.
MEL way to enable/disable Soft Selection:
Soft modelling is an option that allows for reflection of basic manipulator actions such as move, rotate, and scale.
// Enable soft selection softSelect -sse on; // Disable soft selection softSelect -sse off;
MEL way to enable/disable symmetry: Symmetric modelling is an option that allows for reflection of basic manipulator actions such as move, rotate, and scale.
// Enable Symmetry symmetricModelling -symmetry on; //Disable Symmetry symmetricModelling -symmetry off;
C++ API for pre selection highlight:
//This method enables the support of pre-selection highlight for this context. MStatus setAllowPreSelectHilight()
C++ API for Soft Selection:
//This method enables the support of soft selection for this context. MStatus setAllowSoftSelect()
C++ API for Symmetry:
//This method enables the support of symmetrical selection for this context. MStatus setAllowSymmetry()
C++ API for Double Click Action:
//This method enables the support of double click smart selection for this context. MStatus setAllowDoubleClickAction()
If you check all the documents in Maya there is no example how to use setAllowPreSelectHilight(), setAllowSoftSelect(), setAllowSymmetry(), setAllowDoubleClickAction() C++ APIs.
Here is the example for selection methods in C++.
Any user-defined class which is inherited from MPxSelectionContext class will have toolOnSetup() virtual method. You can override toolOnSetup() method and add all the above mentioned C++ APIs as below.
void richSelectionContext::toolOnSetup( MEvent &event ) { MPxSelectionContext::toolOnSetup( event ); setAllowPreSelectHilight(); setAllowSoftSelect(); setAllowSymmetry(); setAllowDoubleClickAction(); }
How to test the functionalities of selection methods? Please download the sample from github
Steps to test:
- Build the sample
- Copy richSelectionProperities.mel and richSelectionValues.mel to Maya script folder “/Applications/Autodesk/maya2017/Maya.app/Contents/scripts/others” (OSX)
- Launch Maya 2017
- Load richSelectionTool plug-in
- Run mel scripts:
- richSelectionContext richSelectionContext1;
- setToolTo richSelectionContext1;
- toolPropertyWindow;
- Switch to component selection mode (vertex/edge/face)
- There you should be on this rich selection tool and could change the soft selection and symmetrical selection options. Double clicking to select shell, edge loop/rings should also works.
Comments
You can follow this conversation by subscribing to the comment feed for this post.