Created
February 26, 2018 16:41
-
-
Save rondreas/e610c76cf2464b98456e94c678ce311a to your computer and use it in GitHub Desktop.
MEL Command for selecting hard edges,
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // Copyright (C) Andreas Rånman | |
| // | |
| // File: selectHardEdgesCmd.cpp | |
| // | |
| // MEL Command: selectHardEdges | |
| // | |
| // Author: Maya Plug-in Wizard 2.0 | |
| // | |
| #include "selectHardEdgesCmd.h" | |
| #include <maya/MArgList.h> | |
| #include <maya/MObject.h> | |
| #include <maya/MGlobal.h> | |
| #include <maya/MItMeshEdge.h> | |
| #include <maya/MString.h> | |
| #include <maya/MDagPath.h> | |
| #include <maya/MSelectionList.h> | |
| MStatus selectHardEdges::doIt(const MArgList& args) | |
| // | |
| // Description: | |
| // Select all hard edges for specified object, | |
| // | |
| // Return Value: | |
| // MStatus success/failed, | |
| // | |
| { | |
| MStatus status = MStatus::kSuccess; | |
| // Check that we gotten one argument, | |
| if (args.length() != 1) | |
| { | |
| MGlobal::displayError("Need 1 item!"); | |
| return MStatus::kFailure; | |
| } | |
| // Add the specified object to a selection list, if it can be found. | |
| MSelectionList list; | |
| MString strCurrSelection; | |
| status = args.get(0, strCurrSelection); | |
| if (MStatus::kSuccess == status) list.add(strCurrSelection); | |
| // Get the DAG Path to object, and iterate through all it's edges, appending each hard edge to selection | |
| MDagPath dagPath; | |
| MObject edge; | |
| list.getDagPath(0, dagPath); | |
| for (MItMeshEdge edges(dagPath); !edges.isDone(); edges.next()) { | |
| if (!edges.isSmooth()) { | |
| edge = edges.currentItem(); | |
| MGlobal::select(dagPath, edge, MGlobal::kAddToList); | |
| } | |
| } | |
| return MS::kSuccess; | |
| } | |
| void* selectHardEdges::creator() | |
| // | |
| // Description: | |
| // this method exists to give Maya a way to create new objects | |
| // of this type. | |
| // | |
| // Return Value: | |
| // a new object of this type | |
| // | |
| { | |
| return new selectHardEdges(); | |
| } | |
| selectHardEdges::selectHardEdges() | |
| // | |
| // Description: | |
| // selectHardEdges constructor | |
| // | |
| {} | |
| selectHardEdges::~selectHardEdges() | |
| // | |
| // Description: | |
| // selectHardEdges destructor | |
| // | |
| {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef _selectHardEdgesCmd | |
| #define _selectHardEdgesCmd | |
| // | |
| // Copyright (C) Andreas Rånman | |
| // | |
| // File: selectHardEdgesCmd.h | |
| // | |
| // MEL Command: selectHardEdges | |
| // | |
| // Author: Maya Plug-in Wizard 2.0 | |
| // | |
| #include <maya/MPxCommand.h> | |
| class MArgList; | |
| class selectHardEdges : public MPxCommand | |
| { | |
| public: | |
| selectHardEdges(); | |
| virtual ~selectHardEdges(); | |
| MStatus doIt( const MArgList& args); | |
| static void* creator(); | |
| }; | |
| #endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment