protected override bool parseArgs(MArgList argList) { MArgDatabase argData; argData = new MArgDatabase(_syntax, argList); // Settings only work at creation time. Would need an // attribute on the node in order to push this state // into the node at any time. ConstraintType typ; if (argData.isFlagSet(kConstrainToLargestWeightFlag)) { typ = GeometrySurfaceConstraintCommand.ConstraintType.kLargestWeight; } else if (argData.isFlagSet(kConstrainToSmallestWeightFlag)) { typ = GeometrySurfaceConstraintCommand.ConstraintType.kSmallestWeight; } else { typ = GeometrySurfaceConstraintCommand.ConstraintType.kLargestWeight; } weightType = typ; // Need parent to process return(false); }
public override void doIt(MArgList args) { MArgDatabase argData = new MArgDatabase(syntax, args); if (argData.isFlagSet(deregisterFlag)) { string eventName = argData.flagArgumentString(deregisterFlag, 0); MUserEventMessage.deregisterUserEvent(eventName); } else if (argData.isFlagSet(registerFlag)) { // Register the new event and add two fixed callbacks to it. string eventName = argData.flagArgumentString(registerFlag, 0); if (!MUserEventMessage.isUserEvent(eventName)) { MUserEventMessage.registerUserEvent(eventName); userCB cb1 = new userCB(); cb1.clientData = "Sample Client Data (an MString object)"; MUserEventMessage.UserEvent[eventName] += cb1.userCallback1; MUserEventMessage.UserEvent[eventName] += cb1.userCallback2; } } else if (argData.isFlagSet(postFlag)) { string eventName = argData.flagArgumentString(postFlag, 0); MUserEventMessage.postUserEvent(eventName); } else if (argData.isFlagSet(testFlag)) { runTests(); } return; }
public override void doIt(MArgList args) { MArgDatabase argData = new MArgDatabase(syntax, args); bool creating = true; if (argData.isFlagSet(kCreateFlag)) { creating = true; } else if (argData.isFlagSet(kDeleteFlag)) { creating = false; } else { throw new ArgumentException("Command Syntax is incorrect", "args"); } if (creating) { lineManipObj = modifier.createNode("simpleLineManipCSharp", MObject.kNullObj); } else { if (lineManipObj != null) { modifier.deleteNode(lineManipObj); } lineManipObj = null; } redoIt(); }
bool flipGlobal = false; // Flip globally or per shell public override void parseSyntax(MArgDatabase argData) { if (argData.isFlagSet(horizFlag)) horizontal =argData.flagArgumentBool(horizFlag, 0); if (argData.isFlagSet(globalFlag)) flipGlobal = argData.flagArgumentBool(globalFlag, 0); if (argData.isFlagSet(extendFlag)) extendToShell = argData.flagArgumentBool(extendFlag, 0); return; }
public override void doIt(MArgList args) { string fileName; MArgDatabase argData = new MArgDatabase(syntax, args); if (argData.isFlagSet(kFileNameFlag)) { fileName = argData.flagArgumentString(kFileNameFlag, 0); if (fileName != null) { string currFile = MFileIO.fileCurrentlyLoading; MStringArray pathDirectories = new MStringArray(currFile.Split('/')); if (pathDirectories.length > 0) { string expandedFileName = ""; for (int i = 0; i < pathDirectories.length - 1; i++) { expandedFileName += pathDirectories[i]; expandedFileName += "/"; } expandedFileName += fileName; MGlobal.sourceFile(expandedFileName); } } } return; }
public void parse(ref MArgDatabase argDb, String name) { fIsSet = argDb.isFlagSet(name); if (fIsSet == false) return; argDb.getFlagArgument(name, 0, out fArg); fIsArgValid = fArg.Length > 0; }
public void parse(ref MArgDatabase argDb, String name) { fIsSet = argDb.isFlagSet(name); if (fIsSet == false) { return; } argDb.getFlagArgument(name, 0, out fArg); fIsArgValid = fArg.Length > 0; }
bool flipGlobal = false; // Flip globally or per shell public override void parseSyntax(MArgDatabase argData) { if (argData.isFlagSet(horizFlag)) { horizontal = argData.flagArgumentBool(horizFlag, 0); } if (argData.isFlagSet(globalFlag)) { flipGlobal = argData.flagArgumentBool(globalFlag, 0); } if (argData.isFlagSet(extendFlag)) { extendToShell = argData.flagArgumentBool(extendFlag, 0); } return; }
public override void checkArgs(MArgDatabase argsDb) { if (argsDb.isFlagSet(kFileNameFlag)) { fileName = argsDb.flagArgumentString(kFileNameFlag, 0); if (fileName == null) { throw new System.ApplicationException("ExportMetadataCmd: You must specify the output path ex: -fn c:/mypath/thefile.meta."); } } base.checkArgs(argsDb); }
private void parseArgs(MArgList args) { const string kMessageFlag = "m"; MArgDatabase argData = new MArgDatabase(syntax, args); if (argData.isFlagSet(kMessageFlag)) { bool flag = false; try { flag = argData.flagArgumentBool(kMessageFlag, 0); } catch (Exception) { throw new ArgumentException("could not parse message flag", "args"); } if (flag) { addMessage = true; } else { delMessage = true; } } try { argData.getObjects(conditions); } catch (Exception) { displayError("could not parse condition names"); } // If there are no conditions specified, operate on all of them // if (conditions.length == 0) { // conditionNames is set in initializePlugin to all the // currently available condition names. // conditions = conditionNames; } }
private void parseArgs(MArgList args) { MArgDatabase argData = new MArgDatabase(syntax, args); if (argData.isFlagSet(kMessageFlag)) { bool flag; try { flag = argData.flagArgumentBool(kMessageFlag, 0); } catch (System.Exception) { throw new ArgumentException("could not parse message flag", "args"); } addMessage = flag; delMessage = !flag; } MStringArray evts; try { evts = argData.objects; if (evts.length == 0) { events = eventNames.ToArray(); } else { evts.get(out events); } } catch (System.Exception) { displayError("could not parse condition names"); } }
public override void doIt(MArgList args) { string fileName; MArgDatabase argData = new MArgDatabase(syntax, args); if (argData.isFlagSet(kFileNameFlag)) { fileName = argData.flagArgumentString(kFileNameFlag, 0); if (fileName != null) { string currFile = MFileIO.fileCurrentlyLoading; MStringArray pathDirectories = new MStringArray(currFile.Split('/')); if (pathDirectories.length > 0) { string expandedFileName = ""; for (int i = 0; i < pathDirectories.length-1; i++) { expandedFileName += pathDirectories[i]; expandedFileName += "/"; } expandedFileName += fileName; MGlobal.sourceFile(expandedFileName); } } } return; }
public override void doIt(MArgList args) { MArgDatabase argData = new MArgDatabase(syntax, args); bool creating = true; if ( argData.isFlagSet( kCreateFlag ) ) creating = true; else if ( argData.isFlagSet( kDeleteFlag ) ) creating = false; else throw new ArgumentException("Command Syntax is incorrect", "args"); if (creating) { lineManipObj = modifier.createNode("simpleLineManipCSharp", MObject.kNullObj); } else { if (lineManipObj != null) { modifier.deleteNode(lineManipObj); } lineManipObj = null; } redoIt(); }
public override void doIt(MArgList args) { MSelectionList list = new MSelectionList(); MArgDatabase argData; argData = new MArgDatabase(syntax, args); argData.getObjects(list); // Get the flags // bool allDagUsed = argData.isFlagSet(kAllDagFlag); bool parentAddedUsed = argData.isFlagSet(kParentAddedFlag); bool parentRemovedUsed = argData.isFlagSet(kParentRemovedFlag); bool childAddedUsed = argData.isFlagSet(kChildAddedFlag); bool childRemovedUsed = argData.isFlagSet(kChildRemovedFlag); bool childReorderedUsed = argData.isFlagSet(kChildReorderedFlag); bool helpUsed = argData.isFlagSet(kHelpFlag); bool nothingSet = (!allDagUsed && !parentAddedUsed && !parentRemovedUsed && !childAddedUsed && !childRemovedUsed && !childReorderedUsed && !helpUsed); if (nothingSet) { throw new ArgumentException("-A flag must be used. dagMessage -help for available flags.", "args"); } if (argData.isFlagSet(kHelpFlag)) { MGlobal.displayInfo("dagMessage -help"); MGlobal.displayInfo("\tdagMessage adds a callback to the selected nodes,"); MGlobal.displayInfo("\tor if no nodes are selected, to all nodes. The callback"); MGlobal.displayInfo("\tprints a message when called. When the plug-in is unloaded"); MGlobal.displayInfo("\tthe callbacks are removed."); MGlobal.displayInfo(""); MGlobal.displayInfo("\t-h -help : This message is printed"); MGlobal.displayInfo("\t-ad -allDag : parent changes and child reorders"); MGlobal.displayInfo("\t-pa -parentAdded : A parent is added"); MGlobal.displayInfo("\t-pr -parentRemoved : A parent is removed"); MGlobal.displayInfo("\t-ca -childAdded : A child is added (only for individual nodes)"); MGlobal.displayInfo("\t-cr -childRemoved : A child is removed (only for individual nodes)"); MGlobal.displayInfo("\t-cro -childReordered : A child is reordered"); MGlobal.displayInfo(""); } uint nObjs = list.length; if (nObjs == 0) { // Add the callback for all changes of the specified type. // if (allDagUsed) { try { MDagMessage.AllDagChangesEvent += userDAGGenericCB; } catch (Exception) { throw new ApplicationException("Could not add a -allDag callback"); } } if (parentAddedUsed) { addGenericCallback(null, MDagMessage.DagMessage.kParentAdded, " parent added "); } if (parentRemovedUsed) { addGenericCallback(null, MDagMessage.DagMessage.kParentRemoved, " parent removed "); } if (childAddedUsed) { throw new ArgumentException("-childAdded can only be used when a node is selected", "args"); } if (childRemovedUsed) { throw new ArgumentException("-childRemoved can only be used when a node is selected", "args"); } if (childReorderedUsed) { addGenericCallback(null, MDagMessage.DagMessage.kChildReordered, " child reordered "); } } else { for (uint i = 0; i < nObjs; i++) { MDagPath dagPath = new MDagPath(); list.getDagPath(i, dagPath); if (!dagPath.isValid) { continue; } // Add the callback for all changes of the specified type. // if (allDagUsed) { // we don't use obsolete function // addAllDagChangesCallback // use addAllDagChangesDagPathCallback instead try { dagPath.AllDagChangesDagPath += userDAGGenericCB; string infoStr = string.Format("Added a callback for all Dag changes on {0}", dagPath.fullPathName); MGlobal.displayInfo(infoStr); } catch (Exception) { throw new ApplicationException("Could not add a -allDag callback"); } } if (parentAddedUsed) { addGenericCallback(dagPath, MDagMessage.DagMessage.kParentAdded, " parent added "); } if (parentRemovedUsed) { addGenericCallback(dagPath, MDagMessage.DagMessage.kParentRemoved, " parent removed "); } if (childAddedUsed) { addGenericCallback(dagPath, MDagMessage.DagMessage.kChildAdded, " child added "); } if (childRemovedUsed) { addGenericCallback(dagPath, MDagMessage.DagMessage.kChildRemoved, " child removed "); } if (childReorderedUsed) { addGenericCallback(dagPath, MDagMessage.DagMessage.kChildReordered, " child reordered "); } } } return; }
public override void doIt(MArgList argList) { MArgDatabase argData = new MArgDatabase(syntax, argList); // Retrieve pass Id. The pass flag must be set. string passId = argData.isFlagSet(PassFlag[0]) ? argData.flagArgumentString(PassFlag[0], 0) : ""; if (passId.Length <= 0) { throw new System.ArgumentException("The pass flag is not set", "argList"); } MRenderPassDef def = null; try { def = MRenderPassRegistry.getRenderPassDefinition(passId); } catch (System.Exception) { setResult(false); return; } // implementation information string renderer = argData.isFlagSet(RendererFlag[0]) ? argData.flagArgumentString(RendererFlag[0], 0) : ""; if (renderer.Length > 0) { MPxRenderPassImpl impl = null; try { impl = def.getImplementation(renderer); } catch (System.Exception) { // impl info requested but does not exist, stop here setResult(false); return; } if (argData.isFlagSet(TypesFlag[0])) { uint types = impl.typesSupported(); string result = getTypeStrings(types); setResult(result); } else if (argData.isFlagSet(DefaultTypeFlag[0])) { uint type = (uint)impl.getDefaultType(); string result = getTypeStrings(type); setResult(result); } else if (argData.isFlagSet(NumChannelsFlag[0])) { uint result = impl.getNumChannels(); setResult(result); } else if (argData.isFlagSet(SemanticFlag[0])) { string result = getSemanticString(impl.frameBufferSemantic()); setResult(result); } else if (argData.isFlagSet(PerLightFlag[0])) { bool result = impl.perLightPassContributionSupported(); setResult(result); } else if (argData.isFlagSet(CompatFlag[0])) { string fCompat = argData.flagArgumentString(CompatFlag[0], 0); bool result = impl.isCompatible(fCompat); setResult(result); } else { // just indicate the implementation exists setResult(true); } } else { // pass information if (argData.isFlagSet(NameFlag[0])) { setResult(def.getName()); } else if (argData.isFlagSet(GroupFlag[0])) { setResult(def.getGroup()); } else if (argData.isFlagSet(DescriptionFlag[0])) { setResult(def.getDescription()); } else { // just indicate the definition exists setResult(true); } } return; }
public override void doIt(MArgList argList) { MArgDatabase argData = new MArgDatabase(syntax, argList); // Retrieve pass Id. The pass flag must be set. string passId = argData.isFlagSet(PassFlag[0]) ? argData.flagArgumentString(PassFlag[0], 0) : ""; if (passId.Length <= 0) throw new System.ArgumentException("The pass flag is not set", "argList"); MRenderPassDef def = null; try { def = MRenderPassRegistry.getRenderPassDefinition(passId); } catch (System.Exception) { setResult(false); return; } // implementation information string renderer = argData.isFlagSet(RendererFlag[0]) ? argData.flagArgumentString(RendererFlag[0], 0) : ""; if (renderer.Length > 0) { MPxRenderPassImpl impl = null; try { impl = def.getImplementation(renderer); } catch (System.Exception) { // impl info requested but does not exist, stop here setResult(false); return; } if (argData.isFlagSet(TypesFlag[0])) { uint types = impl.typesSupported(); string result = getTypeStrings(types); setResult(result); } else if (argData.isFlagSet(DefaultTypeFlag[0])) { uint type = (uint)impl.getDefaultType(); string result = getTypeStrings(type); setResult(result); } else if (argData.isFlagSet(NumChannelsFlag[0])) { uint result = impl.getNumChannels(); setResult(result); } else if (argData.isFlagSet(SemanticFlag[0])) { string result = getSemanticString(impl.frameBufferSemantic()); setResult(result); } else if (argData.isFlagSet(PerLightFlag[0])) { bool result = impl.perLightPassContributionSupported(); setResult(result); } else if (argData.isFlagSet(CompatFlag[0])) { string fCompat = argData.flagArgumentString(CompatFlag[0], 0); bool result = impl.isCompatible(fCompat); setResult(result); } else { // just indicate the implementation exists setResult(true); } } else { // pass information if (argData.isFlagSet(NameFlag[0])) { setResult(def.getName()); } else if (argData.isFlagSet(GroupFlag[0])) { setResult(def.getGroup()); } else if (argData.isFlagSet(DescriptionFlag[0])) { setResult(def.getDescription()); } else { // just indicate the definition exists setResult(true); } } return; }
public override void doIt(MArgList args /*, MPxCommandClass cmd*/) { // This method is called from script when this command is called. // It should set up any class data necessary for redo/undo, // parse any given arguments, and then call redoIt. MArgDatabase argData = new MArgDatabase(/*cmd.*/ syntax, args); __isIndex = argData.isFlagSet(kIndexFlag); // Get the plug specified on the command line. MSelectionList slist = argData.SelectionObjects; if (slist.length == 0) { throw new ArgumentException("Must specify an array plug in the form <nodeName>.<multiPlugName>.", "args"); } __fPlug = slist.getPlug(0); if (__fPlug == null) { throw new ArgumentException("Must specify an array plug in the form <nodeName>.<multiPlugName>.", "args"); } // Construct a data handle containing the data stored in the plug. MDataHandle dh = new MDataHandle(); try { __fPlug.getValue(dh); } catch (Exception) { throw new ApplicationException("Could not get the plug value."); } MArrayDataHandle adh; uint indx = 0; try { adh = new MArrayDataHandle(dh); } catch (Exception) { __fPlug.destructHandle(dh); throw new ApplicationException("Could not create the array data handle."); } // Iterate over the values in the multiPlug. If the index flag has been used, just return // the logical indices of the child plugs. Otherwise, return the plug values. string errorMsg = null; for (uint i = 0; i < adh.elementCount(); i++, adh.next()) { try { indx = adh.elementIndex(); } catch (Exception) { continue; } if (__isIndex) { appendToResult((int)indx); } else { MDataHandle h = adh.outputValue(); if (h.isNumeric) { switch (h.numericType) { case MFnNumericData.Type.kBoolean: appendToResult(h.asBool); break; case MFnNumericData.Type.kShort: appendToResult(h.asShort); break; case MFnNumericData.Type.kInt: appendToResult(h.asInt); break; case MFnNumericData.Type.kFloat: appendToResult(h.asFloat); break; case MFnNumericData.Type.kDouble: appendToResult(h.asDouble); break; default: errorMsg = string.Format("{0}This sample command only supports boolean, integer, and floating point values. Not {1}.\n", errorMsg != null ? errorMsg : "", h.numericType.ToString()); break; } } } } __fPlug.destructHandle(dh); if (errorMsg != null) { throw new ApplicationException(errorMsg); } ; return; }
private void parseArgs(MArgList args) { const string kMessageFlag = "m"; MArgDatabase argData = new MArgDatabase(syntax, args); if (argData.isFlagSet(kMessageFlag)) { bool flag = false; try { flag = argData.flagArgumentBool(kMessageFlag, 0); } catch (Exception) { throw new ArgumentException("could not parse message flag", "args"); } if (flag) { addMessage = true; } else { delMessage = true; } } try { argData.getObjects(conditions); } catch(Exception) { displayError("could not parse condition names"); } // If there are no conditions specified, operate on all of them // if (conditions.length == 0) { // conditionNames is set in initializePlugin to all the // currently available condition names. // conditions = conditionNames; } }
private void parseArgs(MArgList args) { MArgDatabase argData = new MArgDatabase(syntax, args); if(argData.isFlagSet(kMessageFlag)) { bool flag; try { flag = argData.flagArgumentBool(kMessageFlag, 0); } catch (System.Exception) { throw new ArgumentException("could not parse message flag", "args"); } addMessage = flag; delMessage = !flag; } MStringArray evts; try { evts = argData.objects; if (evts.length == 0) events = eventNames.ToArray(); else evts.get(out events); } catch (System.Exception) { displayError("could not parse condition names"); } }
public override void doIt(MArgList args/*, MPxCommandClass cmd*/) { // This method is called from script when this command is called. // It should set up any class data necessary for redo/undo, // parse any given arguments, and then call redoIt. MArgDatabase argData = new MArgDatabase(/*cmd.*/syntax, args); __isIndex = argData.isFlagSet(kIndexFlag); // Get the plug specified on the command line. MSelectionList slist = argData.SelectionObjects; if ( slist.length == 0 ) { throw new ArgumentException("Must specify an array plug in the form <nodeName>.<multiPlugName>.", "args"); } __fPlug = slist.getPlug (0) ; if ( __fPlug == null ) { throw new ArgumentException("Must specify an array plug in the form <nodeName>.<multiPlugName>.", "args"); } // Construct a data handle containing the data stored in the plug. MDataHandle dh = new MDataHandle() ; try { __fPlug.getValue(dh); } catch (Exception) { throw new ApplicationException("Could not get the plug value."); } MArrayDataHandle adh ; uint indx =0 ; try { adh = new MArrayDataHandle(dh); } catch (Exception) { __fPlug.destructHandle(dh) ; throw new ApplicationException("Could not create the array data handle."); } // Iterate over the values in the multiPlug. If the index flag has been used, just return // the logical indices of the child plugs. Otherwise, return the plug values. string errorMsg = null; for (uint i = 0; i < adh.elementCount(); i++, adh.next()) { try { indx = adh.elementIndex() ; } catch (Exception) { continue ; } if ( __isIndex ) { appendToResult ((int)indx) ; } else { MDataHandle h = adh.outputValue () ; if (h.isNumeric) { switch (h.numericType) { case MFnNumericData.Type.kBoolean: appendToResult (h.asBool) ; break; case MFnNumericData.Type.kShort: appendToResult (h.asShort) ; break; case MFnNumericData.Type.kInt: appendToResult (h.asInt) ; break; case MFnNumericData.Type.kFloat: appendToResult (h.asFloat) ; break; case MFnNumericData.Type.kDouble: appendToResult (h.asDouble) ; break; default: errorMsg = string.Format("{0}This sample command only supports boolean, integer, and floating point values. Not {1}.\n", errorMsg != null ? errorMsg : "", h.numericType.ToString()); break; } } } } __fPlug.destructHandle (dh) ; if (errorMsg != null) throw new ApplicationException(errorMsg); ; return; }
protected override bool parseArgs( MArgList argList) { MArgDatabase argData; argData = new MArgDatabase(_syntax, argList); // Settings only work at creation time. Would need an // attribute on the node in order to push this state // into the node at any time. ConstraintType typ; if (argData.isFlagSet(kConstrainToLargestWeightFlag)) typ = GeometrySurfaceConstraintCommand.ConstraintType.kLargestWeight; else if (argData.isFlagSet(kConstrainToSmallestWeightFlag)) typ = GeometrySurfaceConstraintCommand.ConstraintType.kSmallestWeight; else typ = GeometrySurfaceConstraintCommand.ConstraintType.kLargestWeight; weightType = typ; // Need parent to process return false; }