

def doIt(self, args):
    try:
        argData = OM.MArgDatabase(self.syntax(), args)
    except:
        pass
    else:
        sel = OM.MSelectionList()
        argData.getObjects(sel)
        if (not (sel.length() == 1)):
            if (argData.isEdit() or argData.isQuery()):
                raise Exception(('This command requires exactly 1 argument to be specified or selected;  found %i.' % sel.length()))
            else:
                isShoulderSpecified = argData.isFlagSet(AM_ShoulderConstraintCmd.kShoulderObjectFlag)
                isSpineSpecified = argData.isFlagSet(AM_ShoulderConstraintCmd.kSpineObjectFlag)
                if (sel.length() == 2):
                    if (not (isShoulderSpecified or isSpineSpecified)):
                        raise Exception('Selection list of length 2 requires either a spine or a shoulder be specified with a flag.')
                    else:
                        if isSpineSpecified:
                            sel.add(argData.flagArgumentString(AM_ShoulderConstraintCmd.kSpineObjectFlag, 0))
                            sel.getDagPath((sel.length() - 1), self.__spineObjectArg)
                        else:
                            sel.getDagPath(0, self.__spineObjectArg)
                        if isShoulderSpecified:
                            sel.add(argData.flagArgumentString(AM_ShoulderConstraintCmd.kShoulderObjectFlag, 0))
                            sel.getDagPath((sel.length() - 1), self.__shoulderObjectArg)
                        else:
                            sel.getDagPath(0, self.__shoulderObjectArg)
                        sel.getDagPath(1, self.__constrainedObjectArg)
                elif (sel.length() == 3):
                    if isSpineSpecified:
                        sel.add(argData.flagArgumentString(AM_ShoulderConstraintCmd.kSpineObjectFlag, 0))
                        sel.getDagPath((sel.length() - 1), self.__spineObjectArg)
                    else:
                        sel.getDagPath(0, self.__spineObjectArg)
                    if isShoulderSpecified:
                        sel.add(argData.flagArgumentString(AM_ShoulderConstraintCmd.kSpineObjectFlag, 0))
                        sel.getDagPath((sel.length() - 1), self.__shoulderObjectArg)
                    else:
                        sel.getDagPath(1, self.__shoulderObjectArg)
                    sel.getDagPath(2, self.__constrainedObjectArg)
                else:
                    raise Exception(('This command requires 3 or fewer arguments to be specified or selected;  found %i.' % sel.length()))
        else:
            iter = OM.MItSelectionList(sel, OM.MFn.kDependencyNode)
            while (not iter.isDone()):
                if (argData.isEdit() or argData.isQuery()):
                    iter.getDependNode(self.__shoulderConstraintNodeArg)
                    self.__shoulderConstraintNodeFn.setObject(self.__shoulderConstraintNodeArg)
                    if (not (self.__shoulderConstraintNodeFn.typeId() == AM_ShoulderConstraintNode.kPluginNodeId)):
                        raise Exception(('The provided dependency node %s is not of type %s.' % (self.__shoulderConstraintNodeFn.name(), AM_ShoulderConstraintNode.kPluginNodeTypeName)))
                else:
                    selectedObject = OM.MObject()
                    iter.getDependNode(selectedObject)
                    if selectedObject.hasFn(OM.MFn.kTransform):
                        OM.MDagPath.getAPathTo(selectedObject, self.__constrainedObjectArg)
                    else:
                        selectedObjectFn = OM.MFnDependencyNode(selectedObject)
                        raise Exception(('%s is not a valid transform node.' % selectedObjectFn.name()))
                    if ((not argData.isFlagSet(AM_ShoulderConstraintCmd.kShoulderObjectFlag)) or (not argData.isFlagSet(AM_ShoulderConstraintCmd.kSpineObjectFlag))):
                        raise Exception('When only one argument is specified in create mode, shoulder and spine flags must be present.')
                iter.next()
        if argData.isQuery():
            self.__shoulderObjectArg = argData.isFlagSet(AM_ShoulderConstraintCmd.kShoulderObjectFlag)
            self.__spineObjectArg = argData.isFlagSet(AM_ShoulderConstraintCmd.kSpineObjectFlag)
            self.__raisedAngleArg = argData.isFlagSet(AM_ShoulderConstraintCmd.kRaisedAngleFlag)
            self.__shoulderAimAxisArg = argData.isFlagSet(AM_ShoulderConstraintCmd.kShoulderAimFlag)
            self.__shoulderFrontAxisArg = argData.isFlagSet(AM_ShoulderConstraintCmd.kShoulderFrontFlag)
            self.__spineAimAxisArg = argData.isFlagSet(AM_ShoulderConstraintCmd.kSpineAimFlag)
            self.__spineFrontAxisArg = argData.isFlagSet(AM_ShoulderConstraintCmd.kSpineFrontFlag)
            self.doItQuery()
        else:
            if argData.isFlagSet(AM_ShoulderConstraintCmd.kNameFlag):
                self.__shoulderConstraintNodeName = argData.flagArgumentString(AM_ShoulderConstraintCmd.kNameFlag, 0)
                if ((len(self.__shoulderConstraintNodeName) < 1) or (self.__shoulderConstraintNodeName[0].isalpha() is False) or (len(re.split('\\W+', self.__shoulderConstraintNodeName)) > 1)):
                    raise Exception(('%s is not a valid node name. Did you type it correctly?' % self.__shoulderConstraintNodeName))
            sel = OM.MSelectionList()
            if argData.isFlagSet(AM_ShoulderConstraintCmd.kShoulderObjectFlag):
                sel.clear()
                try:
                    sel.add(argData.flagArgumentString(AM_ShoulderConstraintCmd.kShoulderObjectFlag, 0))
                    sel.getDagPath(0, self.__shoulderObjectArg)
                except:
                    raise Exception(('%s is not a valid node name. Did you type it correctly?' % argData.flagArgumentString(AM_ShoulderConstraintCmd.kShoulderObjectFlag, 0)))
            if argData.isFlagSet(AM_ShoulderConstraintCmd.kSpineObjectFlag):
                sel.clear()
                try:
                    sel.add(argData.flagArgumentString(AM_ShoulderConstraintCmd.kSpineObjectFlag, 0))
                    sel.getDagPath(0, self.__spineObjectArg)
                except:
                    raise Exception(('%s is not a valid node name. Did you type it correctly?' % argData.flagArgumentString(AM_ShoulderConstraintCmd.kSpineObjectFlag, 0)))
            if argData.isFlagSet(AM_ShoulderConstraintCmd.kRaisedAngleFlag):
                self.__raisedAngleArg = argData.flagArgumentString(AM_ShoulderConstraintCmd.kRaisedAngleFlag, 0)
            else:
                self.__raisedAngleArg = None
            if argData.isFlagSet(AM_ShoulderConstraintCmd.kShoulderAimFlag):
                self.__shoulderAimAxisArg = OM.MVector(argData.flagArgumentDouble(AM_ShoulderConstraintCmd.kShoulderAimFlag, 0), argData.flagArgumentDouble(AM_ShoulderConstraintCmd.kShoulderAimFlag, 1), argData.flagArgumentDouble(AM_ShoulderConstraintCmd.kShoulderAimFlag, 2))
            if argData.isFlagSet(AM_ShoulderConstraintCmd.kShoulderFrontFlag):
                self.__shoulderFrontAxisArg = OM.MVector(argData.flagArgumentDouble(AM_ShoulderConstraintCmd.kShoulderFrontFlag, 0), argData.flagArgumentDouble(AM_ShoulderConstraintCmd.kShoulderFrontFlag, 1), argData.flagArgumentDouble(AM_ShoulderConstraintCmd.kShoulderFrontFlag, 2))
            if argData.isFlagSet(AM_ShoulderConstraintCmd.kSpineAimFlag):
                self.__spineAimAxisArg = OM.MVector(argData.flagArgumentDouble(AM_ShoulderConstraintCmd.kSpineAimFlag, 0), argData.flagArgumentDouble(AM_ShoulderConstraintCmd.kSpineAimFlag, 1), argData.flagArgumentDouble(AM_ShoulderConstraintCmd.kSpineAimFlag, 2))
            if argData.isFlagSet(AM_ShoulderConstraintCmd.kSpineFrontFlag):
                self.__spineFrontAxisArg = OM.MVector(argData.flagArgumentDouble(AM_ShoulderConstraintCmd.kSpineFrontFlag, 0), argData.flagArgumentDouble(AM_ShoulderConstraintCmd.kSpineFrontFlag, 1), argData.flagArgumentDouble(AM_ShoulderConstraintCmd.kSpineFrontFlag, 2))
            self.__isEditUsed = argData.isEdit()
            self.__isQueryUsed = False
            self.redoIt()

dataset/ETHPy150Open CountZer0/PipelineConstructionSet/maya/plugins/2014/win64/AM_ShoulderConstraint.py AM_ShoulderConstraintCmd.doIt/original