// // Takes the nodes that are on the active selection list and adds an // attribute changed callback to each one. // public override void doIt(MArgList args) { MObject node = new MObject(); MSelectionList list = new MSelectionList(); // Register node callbacks for all nodes on the active list. // MGlobal.getActiveSelectionList( list ); for ( uint i=0; i<list.length; i++ ) { list.getDependNode( i, node ); try { node.AttributeChanged += userCB; } catch (Exception) { MGlobal.displayInfo("MNodeMessage.addCallback failed\n"); continue; } // C# SDK will cleanup events, when this plugin is unloaded // callbacks.append(node); } return; }
public override void doIt(MArgList args) { uint last = args.length; if (last > 0) { for (uint i = 0; i < last; i++) { string argStr = args.asString(i); if (argStr == "add") { if (added) continue; MEventMessage.Event[UndoString] += undoCB; MEventMessage.Event[RedoString] += redoCB; } else if (argStr == "remove") { if (added) { MEventMessage.Event[UndoString] -= undoCB; MEventMessage.Event[RedoString] -= redoCB; added = false; } } else { throw new ArgumentException("Failure condition", "args"); } } } return; }
public override void doIt(MArgList args) // // Takes the nodes that are on the active selection list and adds an // attribute changed callback to each one. // { MObject node = new MObject(); MSelectionList list = new MSelectionList(); // Register node callbacks for all nodes on the active list. // MGlobal.getActiveSelectionList(list); for (uint i = 0; i < list.length; i++) { list.getDependNode(i, node); try { node.AttributeChanged += userCB; } catch (Exception) { MGlobal.displayInfo("MNodeMessage.addCallback failed\n"); continue; } // C# SDK will cleanup events, when this plugin is unloaded // callbacks.append(node); } return; }
public override void doIt(MArgList argl) { SubscribeAssemblyResolvingEvent(); if (!String.IsNullOrEmpty(wpfTitle)) { // Check the existence of the window int wndExist = int.Parse(MGlobal.executeCommandStringResult($@"format -stringArg `control -q -ex ""{wpfTitle}""` ""^1s""")); if (wndExist > 0) { MGlobal.executeCommand($@"catch (`workspaceControl -e -visible true ""{hostTitle}""`);"); return; } } if (dynStartUp != null) { if (dynStartUp.DynView != null) { if (dynStartUp.DynView.IsVisible) { MGlobal.displayWarning("Dynamo is already open"); return; } else { dynWnd.Show(); } } } else { newDmStartup(); dynWnd = dynStartUp.DynView; // Create the window to dock dynWnd.Show(); // Extract the window handle of the window we want to dock IntPtr mWindowHandle = new System.Windows.Interop.WindowInteropHelper(dynWnd).Handle; int width = (int)dynWnd.Width; int height = (int)dynWnd.Height; var title = dynWnd.Title; wpfTitle = title + " Internal"; hostTitle = title; dynWnd.Title = wpfTitle; mayaWnd = new MForeignWindowWrapper(mWindowHandle, true); uint flagIdx = argl.flagIndex(flagName); if (flagIdx == MArgList.kInvalidArgIndex) { // Create a workspace-control to wrap the native window wrapper, and use it as the parent of this WPF window CreateWorkspaceControl(wpfTitle, hostTitle, width, height, false); } } }
override public void doIt(MArgList args) { MSyntax syntax = new MSyntax(); syntax.addArg(MSyntax.MArgType.kDouble); syntax.addArg(MSyntax.MArgType.kDouble); syntax.addArg(MSyntax.MArgType.kDouble); MArgDatabase argData = new MArgDatabase(syntax, args); MVector vector = MVector.xAxis; if (args.length == 1) { vector.x = args.asDouble(0); } else if (args.length == 2) { vector.x = args.asDouble(0); vector.y = args.asDouble(1); } else if (args.length == 3) { uint i = 0; vector = args.asVector(ref i); } __delta = vector; __action(MoveToolAction.kDoIt); return; }
public override void doIt(MArgList args) { MTypeId id = new MTypeId(0x0008106c); MObject setNode = fDGMod.createNode(id); fDGMod.doIt(); MSelectionList selList = new MSelectionList(); MGlobal.getActiveSelectionList(selList); if (selList.length > 0) { try { MFnSet setFn = new MFnSet(setNode); setFn.addMembers(selList); } catch (System.Exception) { } } MFnDependencyNode depNodeFn = new MFnDependencyNode(setNode); setResult(depNodeFn.name); return; }
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(); }
public override void doIt(MArgList args) { // Draw a circle and get its dagPath // using an iterator MGlobal.executeCommand("circle"); MFnNurbsCurve circle = new MFnNurbsCurve(); MDagPath dagPath = new MDagPath(); MItDependencyNodes iter = new MItDependencyNodes( MFn.Type.kNurbsCurve); for (iter.reset(); !iter.isDone; iter.next()) { MObject item = iter.item; if (item.hasFn(MFn.Type.kNurbsCurve)) { circle.setObject(item); circle.getPath(dagPath); MGlobal.displayInfo("DAG_PATH is " + dagPath.fullPathName); if (dagPath.isValid) { // register callback for instance add AND remove // dagPath.InstanceAddedDagPath += userDAGChildAddedCB; dagPath.InstanceRemovedDagPath += userDAGChildRemovedCB; // C# SDK will cleanup events, when this plugin is unloaded // callbacks.append(node); MGlobal.displayInfo("CALLBACK ADDED FOR INSTANCE ADD/REMOVE"); } } } }
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) { 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) { // Draw a circle and get its dagPath // using an iterator MGlobal.executeCommand("circle"); MFnNurbsCurve circle = new MFnNurbsCurve(); MDagPath dagPath = new MDagPath(); MItDependencyNodes iter = new MItDependencyNodes(MFn.Type.kNurbsCurve); for (iter.reset(); !iter.isDone; iter.next()) { MObject item = iter.item; if (item.hasFn(MFn.Type.kNurbsCurve)) { circle.setObject(item); circle.getPath(dagPath); MGlobal.displayInfo("DAG_PATH is " + dagPath.fullPathName); if (dagPath.isValid) { // register callback for instance add AND remove // dagPath.InstanceAddedDagPath += userDAGChildAddedCB; dagPath.InstanceRemovedDagPath += userDAGChildRemovedCB; // C# SDK will cleanup events, when this plugin is unloaded // callbacks.append(node); MGlobal.displayInfo("CALLBACK ADDED FOR INSTANCE ADD/REMOVE"); } } } }
public override void doIt(MArgList args) { MSceneMessage.AfterNew += addMyIK2BsolverCallbacks.createIK2BsolverAfterNew; MSceneMessage.AfterOpen += addMyIK2BsolverCallbacks.createIK2BsolverAfterOpen; return; }
override public void doIt(MArgList args) { MSceneMessage.AfterNew += addMyIK2BsolverCallbacks.createIK2BsolverAfterNew; MSceneMessage.AfterOpen += addMyIK2BsolverCallbacks.createIK2BsolverAfterOpen; return; }
// // Description // Gets the zoomCamera for the current 3d view and calls // the redoIt command to set the focal length. // // Note // The doit method should collect whatever information is // required to do the task, and store it in local class data. // It should finally call redoIt to make the command happen. // public override void doIt(MArgList args) { // Get the current zoomCamera // M3dView.active3dView.getCamera( camera ); redoIt(); return; }
public override void doIt(MArgList args) { MSelectionList list = new MSelectionList(); MGlobal.getActiveSelectionList(list); iter = new MItSelectionList(list, MFn.Type.kInvalid); redoIt(); }
public override void doIt(MArgList args) { DomainManager.CreateDomain( ApplicationBase, AssemblyName, DoIt_Class, DoIt_Method); }
////////////////////////////////////////////////////////////////// // // Overrides from MPxData // ////////////////////////////////////////////////////////////////// public override void readASCII(MArgList argList, ref uint index) // // Description // NOT IMPLEMENTED // { MGlobal.displayInfo("apiMeshData.readASCII is called."); return; }
////////////////////////////////////////////////////////////////// // // Overrides from MPxData // ////////////////////////////////////////////////////////////////// public override void readASCII(MArgList argList, ref uint index) // // Description // NOT IMPLEMENTED // { MGlobal.displayInfo("apiMeshData.readASCII is called."); return; }
public override void doIt(MArgList args) { MSelectionList list = new MSelectionList(); MGlobal.getActiveSelectionList(list); iter = new MItSelectionList(list, MFn.Type.kInvalid); redoIt(); }
void parseArgs(MArgList args) { string arg = ""; MSelectionList list = new MSelectionList(); bool charNameUsed = false; string charName; const string charFlag = "-c"; const string charFlagLong = "-char"; for (uint i = 0; i < args.length; i++) { arg = args.asString(i); if (arg == charFlag || arg == charFlagLong) { // get the char name // if (i == args.length - 1) { arg += ": must specify a character name"; throw new ArgumentException(arg, "args"); } i++; charName = args.asString(i); list.add(charName); charNameUsed = true; } else { arg += ": unknown argument"; throw new ArgumentException(arg, "args"); } } if (charNameUsed) { // get the character corresponding to the node name // MItSelectionList iter = new MItSelectionList(list); for (; iter.isDone; iter.next()) { MObject node = new MObject(); iter.getDependNode(node); if (node.apiType == MFn.Type.kCharacter) { fCharacter = node; break; } } if (fCharacter.isNull) { throw new ApplicationException("Unable to get the character corresponding to the node name."); } } }
void parseArgs(MArgList args) { string arg = ""; MSelectionList list = new MSelectionList(); bool charNameUsed = false; string charName; const string charFlag = "-c"; const string charFlagLong = "-char"; for (uint i = 0; i < args.length; i++) { arg = args.asString(i); if (arg == charFlag || arg == charFlagLong) { // get the char name // if (i == args.length - 1) { arg += ": must specify a character name"; throw new ArgumentException(arg, "args"); } i++; charName = args.asString(i); list.add(charName); charNameUsed = true; } else { arg += ": unknown argument"; throw new ArgumentException(arg, "args"); } } if (charNameUsed) { // get the character corresponding to the node name // MItSelectionList iter = new MItSelectionList(list); for (; iter.isDone; iter.next()) { MObject node = new MObject(); iter.getDependNode(node); if (node.apiType == MFn.Type.kCharacter) { fCharacter = node; break; } } if (fCharacter.isNull) { throw new ApplicationException("Unable to get the character corresponding to the node name."); } } }
public override void doIt(MArgList args) { MItDag.TraversalType traversalType = MItDag.TraversalType.kDepthFirst; MFn.Type filter = MFn.Type.kInvalid; bool quiet = false; parseArgs(args, ref traversalType, filter, ref quiet); doScan(traversalType, filter, quiet); }
public override void doIt(MArgList args) { MItDag.TraversalType traversalType = MItDag.TraversalType.kDepthFirst; MFn.Type filter = MFn.Type.kInvalid; bool quiet = false; parseArgs(args, ref traversalType, filter, ref quiet); doScan(traversalType, filter, quiet); }
public override void readASCII(MArgList argList, ref uint endOfTheLastParsedElement) { if (argList.length == 0) { throw new System.ArgumentException("The MArgList argument is empty", "argList"); } value = argList.asDouble(endOfTheLastParsedElement++); return; }
/// <summary> /// Entry point of the plug in /// Write "toBabylon" in the Maya console to start it /// </summary> /// <param name="argl"></param> public override void doIt(MArgList argl) { MGlobal.displayInfo("Start Maya Plugin\n"); ExporterForm BabylonExport = new ExporterForm(); BabylonExport.Show(); BabylonExport.BringToFront(); BabylonExport.WindowState = FormWindowState.Normal; // DoExport(); }
public override void readASCII(MArgList argList, ref uint endOfTheLastParsedElement) { if (argList.length == 0) { throw new System.ArgumentException("The MArgList argument is empty", "argList"); } value = argList.asDouble(endOfTheLastParsedElement++); return; }
public override void doIt(MArgList argl) { MGlobal.displayInfo("Hello World\n"); _dagModifier = new MDagModifier(); _transform = _dagModifier.createNode("camera"); _dagModifier.renameNode(_transform, "motionCamera"); redoIt(); }
public override void doIt(MArgList args) { MGlobal.displayInfo("Garbage Collection begin."); GC.Collect(); GC.WaitForPendingFinalizers(); MGlobal.displayInfo("Garbage Collection complete."); return; }
public override void doIt(MArgList args) { MGlobal.displayInfo("Garbage Collection begin."); GC.Collect(); GC.WaitForPendingFinalizers(); MGlobal.displayInfo("Garbage Collection complete."); return; }
override public void doIt(MArgList args) { // Create the window to dock wnd = new wpfexamples.DAGExplorer(); wnd.Show(); // Extract the window handle of the window we want to dock IntPtr mWindowHandle = new System.Windows.Interop.WindowInteropHelper(wnd).Handle; // Dock it in Maya using the docking station mI = new MDockingStation(mWindowHandle, true, MDockingStation.BottomDock | MDockingStation.TopDock, MDockingStation.BottomDock); }
public override void doIt(MArgList args) { // Create the window to dock wnd = new wpfexamples.DAGExplorer(); wnd.Show(); // Extract the window handle of the window we want to dock IntPtr mWindowHandle = new System.Windows.Interop.WindowInteropHelper(wnd).Handle; // Dock it in Maya using the docking station mI = new MDockingStation(mWindowHandle, true, MDockingStation.BottomDock | MDockingStation.TopDock, MDockingStation.BottomDock); }
public override void doIt(MArgList args) { if (animationForm == null) { animationForm = new AnimationForm(); animationForm.On_animationFormClosed += On_animationFormClosed; } animationForm.Show(); animationForm.BringToFront(); animationForm.WindowState = FormWindowState.Normal; }
public override void doIt(MArgList args) { MArgDatabase argsDb = new MArgDatabase(syntax, args); checkArgs(argsDb); clearResult(); switch (fMode) { case CommandMode.kCreate: doCreate(); break; case CommandMode.kEdit: doEdit(); break; case CommandMode.kQuery: doQuery(); break; } }
private void parseArgs(MArgList args, ref MItDag.TraversalType traversalType, MFn.Type filter, ref bool quiet) { string arg = ""; const string breadthFlag = "-b"; const string breadthFlagLong = "-breadthFirst"; const string depthFlag = "-d"; const string depthFlagLong = "-depthFirst"; const string cameraFlag = "-c"; const string cameraFlagLong = "-cameras"; const string lightFlag = "-l"; const string lightFlagLong = "-lights"; const string nurbsSurfaceFlag = "-n"; const string nurbsSurfaceFlagLong = "-nurbsSurfaces"; const string quietFlag = "-q"; const string quietFlagLong = "-quiet"; for (uint i = 0; i < args.length; i++) { arg = args.asString(i); if (arg == breadthFlag || arg == breadthFlagLong) { traversalType = MItDag.TraversalType.kBreadthFirst; } else if (arg == depthFlag || arg == depthFlagLong) { traversalType = MItDag.TraversalType.kDepthFirst; } else if (arg == cameraFlag || arg == cameraFlagLong) { filter = MFn.Type.kCamera; } else if (arg == lightFlag || arg == lightFlagLong) { filter = MFn.Type.kLight; } else if (arg == nurbsSurfaceFlag || arg == nurbsSurfaceFlagLong) { filter = MFn.Type.kNurbsSurface; } else if (arg == quietFlag || arg == quietFlagLong) { quiet = true; } else { arg += ": unknown argument"; throw new ArgumentException(arg, "args"); } } }
public override void finalize() { MArgList command = new MArgList(); command.addArg(commandString); command.addArg(__delta.x); command.addArg(__delta.y); command.addArg(__delta.z); // This call adds the command to the undo queue and sets // the journal string for the command. base._doFinalize(command); return; }
/// <summary> /// Entry point of the plug in /// Write "toBabylon" in the Maya console to start it /// </summary> /// <param name="argl"></param> public override void doIt(MArgList argl) { if (form == null) { form = new ExporterForm(); } form.Show(); form.BringToFront(); form.WindowState = FormWindowState.Normal; form.closingByUser = () => { return(disposeForm()); }; // TODO - save states - FORM: checkboxes and inputs. MEL: reselected meshes / nodes? form.closingByShutDown = () => { return(disposeForm()); }; // form.closingByCrash = () => { return disposeForm(); }; }
public override void doIt(MArgList args) { MArgDatabase argsDb = new MArgDatabase(syntax, args); checkArgs(argsDb); clearResult(); switch (fMode) { case CommandMode.kCreate: doCreate(); break; case CommandMode.kEdit: doEdit(); break; case CommandMode.kQuery: doQuery(); break; } }
public void parseArgs(MArgList args) { string arg; string fileName = ""; string fileFlag = "-f"; string fileFlagLong = "-file"; // Parse the arguments. for ( uint i = 0; i < args.length; i++ ) { try { arg = args.asString(i); } catch (Exception e) { MGlobal.displayInfo(e.Message); continue; } if ( arg == fileFlag || arg == fileFlagLong ) { // get the file name // if (i == args.length - 1) { arg += ": must specify a file name"; throw new ArgumentException(arg, "args"); } i++; fileName = args.asString(i); } else { arg += ": unknown argument"; throw new ArgumentException(arg, "args"); } } file = File.Open(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite); if (file == null) { string openError = "Could not open: "; openError += fileName; throw new InvalidOperationException(openError); } }
public void parseArgs(MArgList args) { string arg; string fileName = ""; string fileFlag = "-f"; string fileFlagLong = "-file"; // Parse the arguments. for (uint i = 0; i < args.length; i++) { try { arg = args.asString(i); } catch (Exception e) { MGlobal.displayInfo(e.Message); continue; } if (arg == fileFlag || arg == fileFlagLong) { // get the file name // if (i == args.length - 1) { arg += ": must specify a file name"; throw new ArgumentException(arg, "args"); } i++; fileName = args.asString(i); } else { arg += ": unknown argument"; throw new ArgumentException(arg, "args"); } } file = File.Open(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite); if (file == null) { string openError = "Could not open: "; openError += fileName; throw new InvalidOperationException(openError); } }
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; } }
/// <summary> /// /// </summary> /// <param name="args">order: windowName, lineIndex , buttonIndex</param> public override void doIt(MArgList args) { //Debug.Log("at least do it...."); if (args.length != 3) { //Debug.Log("param count error:" + args.length); return; } string wName = args.asString(0); int lineIndex = args.asInt(1); int buttonIndex = args.asInt(2); //Debug.Log("name:" + wName + ",line:" + lineIndex + ",btn:" + buttonIndex); BasicWindow.ExcuteInDic(wName, lineIndex, buttonIndex); }
public override void doIt(MArgList args) { CSharpInterpreter.MayaRootPath = @"D:\Program Files\Autodesk\Maya2015"; var script = args.asString(0); MGlobal.displayInfo(script); var scriptArgs = new string[args.length]; for (uint i = 1; i < args.length; ++i) { scriptArgs[i - 1] = args.asString(i); MGlobal.displayInfo(scriptArgs[i - 1]); } new CSharpInterpreter(script).Execute(scriptArgs); }
public MArgList arg(ref MArgList defValue) { if (isSet()) { if (isArgValid() == true) { MArgList argList = new MArgList(); argList.addArg(fArg); return(argList); } return(null); } else { return(defValue); } }
public override void doIt(MArgList args) // // Description // Gets the zoomCamera for the current 3d view and calls // the redoIt command to set the focal length. // // Note // The doit method should collect whatever information is // required to do the task, and store it in local class data. // It should finally call redoIt to make the command happen. // { // Get the current zoomCamera // M3dView.active3dView.getCamera( camera ); redoIt(); return; }
override public void doIt(MArgList args) { MGlobal.displayInfo("doIt..."); MSelectionList selectList = MGlobal.activeSelectionList; foreach( MObject node in selectList.DependNodes() ) { MFnDependencyNode depFn = new MFnDependencyNode(); depFn.setObject(node); MGlobal.displayInfo("Name: " + depFn.name); MGlobal.displayInfo("Type: " + node.apiTypeStr); MGlobal.displayInfo("Function Sets: "); foreach (string st in MGlobal.getFunctionSetList(node)) MGlobal.displayInfo(st + ", "); MGlobal.displayInfo(""); } return; }
private void parseArgs( MArgList args,ref MItDag.TraversalType traversalType, MFn.Type filter, ref bool quiet) { string arg = ""; const string breadthFlag = "-b"; const string breadthFlagLong = "-breadthFirst"; const string depthFlag = "-d"; const string depthFlagLong = "-depthFirst"; const string cameraFlag = "-c"; const string cameraFlagLong = "-cameras"; const string lightFlag = "-l"; const string lightFlagLong = "-lights"; const string nurbsSurfaceFlag = "-n"; const string nurbsSurfaceFlagLong = "-nurbsSurfaces"; const string quietFlag = "-q"; const string quietFlagLong = "-quiet"; for (uint i = 0; i < args.length; i++) { arg = args.asString(i); if ( arg == breadthFlag || arg == breadthFlagLong ) traversalType = MItDag.TraversalType.kBreadthFirst; else if ( arg == depthFlag || arg == depthFlagLong ) traversalType = MItDag.TraversalType.kDepthFirst; else if ( arg == cameraFlag || arg == cameraFlagLong ) filter = MFn.Type.kCamera; else if ( arg == lightFlag || arg == lightFlagLong ) filter = MFn.Type.kLight; else if ( arg == nurbsSurfaceFlag || arg == nurbsSurfaceFlagLong ) filter = MFn.Type.kNurbsSurface; else if ( arg == quietFlag || arg == quietFlagLong ) quiet = true; else { arg += ": unknown argument"; throw new ArgumentException(arg, "args"); } } }
override public void doIt(MArgList args) { MSyntax syntax = new MSyntax(); syntax.addArg(MSyntax.MArgType.kDouble); syntax.addArg(MSyntax.MArgType.kDouble); syntax.addArg(MSyntax.MArgType.kDouble); MArgDatabase argData = new MArgDatabase(syntax, args); MVector vector = MVector.xAxis ; if ( args.length == 1 ) { vector.x =args.asDouble (0) ; } else if ( args.length == 2 ) { vector.x =args.asDouble (0) ; vector.y =args.asDouble (1) ; } else if ( args.length == 3 ) { uint i =0 ; vector = args.asVector(ref i); } __delta = vector; __action (MoveToolAction.kDoIt) ; return; }
public override void doIt(MArgList args) { MTypeId id = new MTypeId(0x0008106c); MObject setNode = fDGMod.createNode(id); fDGMod.doIt(); MSelectionList selList = new MSelectionList(); MGlobal.getActiveSelectionList( selList ); if( selList.length > 0 ) { try { MFnSet setFn = new MFnSet(setNode); setFn.addMembers(selList); } catch (System.Exception) { } } MFnDependencyNode depNodeFn = new MFnDependencyNode( setNode ); setResult( depNodeFn.name ); return; }
//====================================================================== // // Do the metadata creation. The metadata will be randomly initialized // based on the channel type and the structure specified. For recognized // components the number of metadata elements will correspond to the count // of components in the selected mesh, otherwise a random number of metadata // elements between 1 and 100 will be created (at consecutive indices). // // The previously existing metadata is preserved for later undo. // override public void doIt(MArgList args) { MArgDatabase argsDb = new MArgDatabase(syntax, args); checkArgs(ref argsDb); clearResult(); uint numNodes = fNodes.length; int i; for (i = 0; i < numNodes; ++i) { // fNodes[i] is the transform not the shape itself MFnDagNode dagNode = new MFnDagNode(fNodes[i]); MObject obj = dagNode.child(0); // obj is the shape, which is where we can add the meta data MFnDependencyNode node = new MFnDependencyNode(obj); // Get the current metadata (empty if none yet) Associations newMetadata = new Associations(node.metadata); Channel newChannel = newMetadata.channel(fChannelType); // Check to see if the requested stream name already exists Stream oldStream = newChannel.dataStream(fStreamName); if (oldStream != null) { string fmt = MStringResource.getString(MetaDataRegisterMStringResources.kCreateMetadataHasStream); string msg = String.Format(fmt, fStreamName); MGlobal.displayError( msg ); continue; } Stream newStream = new Stream(fStructure, fStreamName); string strmName = newStream.name; int indexCount = 0; MFnMesh mesh = null; Random rndIndexCount = new Random(); // Treat the channel type initializations different for meshes if (obj.hasFn(MFn.Type.kMesh)) { mesh = new MFnMesh(obj); // Get mesh-specific channel type parameters if (fChannelType == "face") { indexCount = mesh.numPolygons; } else if (fChannelType == "edge") { indexCount = mesh.numEdges; } else if (fChannelType == "vertex") { indexCount = mesh.numVertices; } else if (fChannelType == "vertexFace") { indexCount = mesh.numFaceVertices; } else { // Set a random number between 1 to 100 indexCount = rndIndexCount.Next(1, 100); } } else { // Create generic channel type information indexCount = rndIndexCount.Next(1, 100); } // Fill specified stream ranges with random data int structureMemberCount = fStructure.memberCount; uint m,n,d; Random rnd = new Random(); for (m = 0; m < indexCount; ++m) { // Walk each structure member and fill with random data // tailored to the member data type. Handle handle = new Handle(fStructure); for (n = 0; n < structureMemberCount; ++n) { handle.setPositionByMemberIndex(n); switch (handle.dataType) { case Member.eDataType.kBoolean: { bool[] data = new bool[handle.dataLength]; for (d = 0; d < handle.dataLength; ++d) { int randomInt = rnd.Next(0, 2); bool randomBool = randomInt == 1 ? true : false; data[d] = randomBool; } handle.asBooleanArray = data; break; } case Member.eDataType.kDouble: { double[] data = new double[handle.dataLength]; for (d = 0; d < handle.dataLength; ++d) { // Set a random number between -2000000000.0.0 and 2000000000.0.0 data[d] = rnd.NextDouble()*4000000000.0 - 2000000000.0 ; } handle.asDoubleArray = data; break; } case Member.eDataType.kDoubleMatrix4x4: { double[] data = new double[handle.dataLength * 16]; for (d = 0; d < handle.dataLength; ++d) { data[d*16+0] = rnd.NextDouble()*4000000000.0 - 2000000000.0 ; data[d*16+1] = rnd.NextDouble()*4000000000.0 - 2000000000.0 ; data[d*16+2] = rnd.NextDouble()*4000000000.0 - 2000000000.0 ; data[d*16+3] = rnd.NextDouble()*4000000000.0 - 2000000000.0 ; data[d*16+4] = rnd.NextDouble()*4000000000.0 - 2000000000.0 ; data[d*16+5] = rnd.NextDouble()*4000000000.0 - 2000000000.0 ; data[d*16+6] = rnd.NextDouble()*4000000000.0 - 2000000000.0 ; data[d*16+7] = rnd.NextDouble()*4000000000.0 - 2000000000.0 ; data[d*16+8] = rnd.NextDouble()*4000000000.0 - 2000000000.0 ; data[d*16+9] = rnd.NextDouble()*4000000000.0 - 2000000000.0 ; data[d*16+10] = rnd.NextDouble()*4000000000.0 - 2000000000.0 ; data[d*16+11] = rnd.NextDouble()*4000000000.0 - 2000000000.0 ; data[d*16+12] = rnd.NextDouble()*4000000000.0 - 2000000000.0 ; data[d*16+13] = rnd.NextDouble()*4000000000.0 - 2000000000.0 ; data[d*16+14] = rnd.NextDouble()*4000000000.0 - 2000000000.0 ; data[d*16+15] = rnd.NextDouble()*4000000000.0 - 2000000000.0 ; } handle.asDoubleMatrix4x4 = data; break; } case Member.eDataType.kFloat: { float[] data = new float[handle.dataLength]; for (d = 0; d < handle.dataLength; ++d) { // Set a random number between -2000000.0 and 2000000.0 data[d] = (float)rnd.NextDouble()*4000000.0f - 2000000.0f ; } handle.asFloatArray = data; break; } case Member.eDataType.kFloatMatrix4x4: { float[] data = new float[handle.dataLength * 16]; for (d = 0; d < handle.dataLength; ++d) { // Set a random number between -2000000.0 and 2000000.0 data[d*16+0] = (float)rnd.NextDouble()*4000000.0f - 2000000.0f ; data[d*16+1] = (float)rnd.NextDouble()*4000000.0f - 2000000.0f ; data[d*16+2] = (float)rnd.NextDouble()*4000000.0f - 2000000.0f ; data[d*16+3] = (float)rnd.NextDouble()*4000000.0f - 2000000.0f ; data[d*16+4] = (float)rnd.NextDouble()*4000000.0f - 2000000.0f ; data[d*16+5] = (float)rnd.NextDouble()*4000000.0f - 2000000.0f ; data[d*16+6] = (float)rnd.NextDouble()*4000000.0f - 2000000.0f ; data[d*16+7] = (float)rnd.NextDouble()*4000000.0f - 2000000.0f ; data[d*16+8] = (float)rnd.NextDouble()*4000000.0f - 2000000.0f ; data[d*16+9] = (float)rnd.NextDouble()*4000000.0f - 2000000.0f ; data[d*16+10] = (float)rnd.NextDouble()*4000000.0f - 2000000.0f ; data[d*16+11] = (float)rnd.NextDouble()*4000000.0f - 2000000.0f ; data[d*16+12] = (float)rnd.NextDouble()*4000000.0f - 2000000.0f ; data[d*16+13] = (float)rnd.NextDouble()*4000000.0f - 2000000.0f ; data[d*16+14] = (float)rnd.NextDouble()*4000000.0f - 2000000.0f ; data[d*16+15] = (float)rnd.NextDouble()*4000000.0f - 2000000.0f ; } handle.asFloatMatrix4x4 = data; break; } case Member.eDataType.kInt8: { sbyte[] data = new sbyte[handle.dataLength]; for (d = 0; d < handle.dataLength; ++d) { data[d] = (sbyte)rnd.Next(SByte.MinValue, SByte.MaxValue+1); } handle.asInt8Array = data; break; } case Member.eDataType.kInt16: { short[] data = new short[handle.dataLength]; for (d = 0; d < handle.dataLength; ++d) { data[d] = (short)rnd.Next(Int16.MinValue, Int16.MaxValue+1); } handle.asInt16Array = data; break; } case Member.eDataType.kInt32: { int[] data = new int[handle.dataLength]; for (d = 0; d < handle.dataLength; ++d) { // rnd.Next returns a number between [arg1,arg2[ // but unfortunately I can't pass Int32.MaxValue+1 here.... data[d] = rnd.Next(Int32.MinValue, Int32.MaxValue); } handle.asInt32Array = data; break; } case Member.eDataType.kInt64: { long[] data = new long[handle.dataLength]; for (d = 0; d < handle.dataLength; ++d) { // rnd.Next() gives a number between [0,Int32 data[d] = (long)rnd.Next(Int32.MinValue, Int32.MaxValue); if( data[d] >= 0 ) data[d] *= Int64.MaxValue / Int32.MaxValue; else data[d] *= Int64.MinValue / Int32.MinValue; } handle.asInt64Array = data; break; } case Member.eDataType.kUInt8: { byte[] data = new byte[handle.dataLength]; for (d = 0; d < handle.dataLength; ++d) { data[d] = (byte)rnd.Next(0, Byte.MaxValue + 1); } handle.asUInt8Array = data; break; } case Member.eDataType.kUInt16: { ushort[] data = new ushort[handle.dataLength]; for (d = 0; d < handle.dataLength; ++d) { data[d] = (ushort)rnd.Next(0, UInt16.MaxValue + 1); } handle.asUInt16Array = data; break; } case Member.eDataType.kUInt32: { uint[] data = new uint[handle.dataLength]; for (d = 0; d < handle.dataLength; ++d) { data[d] = (uint)rnd.Next(); } handle.asUInt32Array = data; break; } case Member.eDataType.kUInt64: { ulong[] data = new ulong[handle.dataLength]; for (d = 0; d < handle.dataLength; ++d) { data[d] = ((ulong)rnd.Next()) * UInt64.MaxValue / UInt32.MaxValue; } handle.asUInt64Array = data; break; } case Member.eDataType.kString: { string[] randomStrings = new string[] { "banana", "tomatoe", "apple", "pineapple", "apricot", "pepper", "olive", "grapefruit" }; string[] data = new string[handle.dataLength]; for (d = 0; d < handle.dataLength; ++d) { int index = rnd.Next( randomStrings.Length ); data[d] = randomStrings[index]; } handle.asStringArray = data; break; } default: { Debug.Assert(false, "This should never happen"); break; } } } newStream.setElement(new Index(m), handle); } newChannel.setDataStream(newStream); newMetadata.setChannel(newChannel); // Note: the following will not work if "obj" is a shape constructed by a source object // You need to delete the history of the shape before calling this... fDGModifier.setMetadata(obj, newMetadata); fDGModifier.doIt(); // Set the result to the number of actual metadata values set as a // triple value: // (# nodes, # metadata elements, # members per element) // MIntArray theResult = new MIntArray(); theResult.append( (int) fNodes.length ); theResult.append( (int) indexCount ); theResult.append( (int) structureMemberCount ); setResult( theResult ); } }
public override void doIt(MArgList argl) { wnd =new WpfThemeTestWindow () ; //MayaTheme.SetMayaIcon (wnd); wnd.Show () ; }
public override bool doIt(MArgList argList) { parseArgs(argList); return false; // we're not done yet }
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) { MGlobal.displayInfo("PLUGIN LOADED"); if (added) return; // add the function call backs // and store call back ids for removal later MSceneMessage.BeforeOpen += preOpenFunc; MSceneMessage.BeforeImport += preImportFunc; MSceneMessage.BeforeSave += preSaveFunc; MSceneMessage.BeforeExport += preExportFunc; // kBeforeReference is deprecated // we use AfterCreateReference/kAfterCreateReferenceAndRecordEdits to instead MSceneMessage.AfterCreateReference += preReferenceFunc; return; }
public override void doIt(MArgList args) { // parse args to get the file name from the command-line // parseArgs(args); uint count = 0; // Iterate through graph and search for skinCluster nodes // MItDependencyNodes iter = new MItDependencyNodes( MFn.Type.kInvalid); for ( ; !iter.isDone; iter.next() ) { MObject obj = iter.item; if (obj.apiType == MFn.Type.kSkinClusterFilter) { count++; // For each skinCluster node, get the list of influence objects // MFnSkinCluster skinCluster = new MFnSkinCluster(obj); MDagPathArray infs = new MDagPathArray(); uint nInfs; try { nInfs = skinCluster.influenceObjects(infs); } catch (Exception) { MGlobal.displayInfo("Error getting influence objects."); continue; } if (0 == nInfs) { MGlobal.displayInfo("Error: No influence objects found."); continue; } // loop through the geometries affected by this cluster // uint nGeoms = skinCluster.numOutputConnections; for (uint ii = 0; ii < nGeoms; ++ii) { uint index; try { index = skinCluster.indexForOutputConnection(ii); } catch (Exception) { MGlobal.displayInfo("Error getting geometry index."); continue; } // get the dag path of the ii'th geometry // MDagPath skinPath = new MDagPath(); try{ skinCluster.getPathAtIndex(index,skinPath); } catch (Exception) { MGlobal.displayInfo("Error getting geometry path."); continue; } // iterate through the components of this geometry // MItGeometry gIter = new MItGeometry(skinPath); // print out the path name of the skin, vertexCount & influenceCount // UnicodeEncoding uniEncoding = new UnicodeEncoding(); string res = String.Format("{0} {1} {2}\n",skinPath.partialPathName,gIter.count,nInfs); file.Write(uniEncoding.GetBytes(res),0,uniEncoding.GetByteCount(res)); // print out the influence objects // for (int kk = 0; kk < nInfs; ++kk) { res = String.Format("{0} ", infs[kk].partialPathName); file.Write(uniEncoding.GetBytes(res),0,uniEncoding.GetByteCount(res)); } res = "\n"; file.Write(uniEncoding.GetBytes(res), 0, uniEncoding.GetByteCount(res)); for ( /* nothing */ ; !gIter.isDone; gIter.next() ) { MObject comp; try { comp = gIter.component; } catch (Exception) { MGlobal.displayInfo("Error getting geometry path."); continue; } // Get the weights for this vertex (one per influence object) // MDoubleArray wts = new MDoubleArray(); uint infCount = 0; try { skinCluster.getWeights(skinPath, comp, wts, ref infCount); } catch (Exception) { displayError("Error getting weights."); continue; } if (0 == infCount) { displayError("Error: 0 influence objects."); } // Output the weight data for this vertex // res = String.Format("{0} ",gIter.index); file.Write(uniEncoding.GetBytes(res), 0, uniEncoding.GetByteCount(res)); for (int jj = 0; jj < infCount ; ++jj ) { res = String.Format("{0} ", wts[jj]); file.Write(uniEncoding.GetBytes(res), 0, uniEncoding.GetByteCount(res)); } file.Write(uniEncoding.GetBytes("\n"), 0, uniEncoding.GetByteCount("\n")); } } } } if (0 == count) { displayError("No skinClusters found in this scene."); } file.Close(); return; }
//====================================================================== // // Do the metadata creation. The metadata will be randomly initialized // based on the channel type and the structure specified. For recognized // components the number of metadata elements will correspond to the count // of components in the selected mesh, otherwise a random number of metadata // elements between 1 and 100 will be created (at consecutive indices). // // The previously existing metadata is preserved for later undo. // override public void doIt(MArgList args) { MArgDatabase argsDb = new MArgDatabase(syntax, args); checkArgs(ref argsDb); clearResult(); uint numNodes = fNodes.length; for ( int i = 0; i < numNodes; ++i) { // fNodes[i] is the transform not the shape itself MFnDagNode dagNode = new MFnDagNode(fNodes[i]); MObject obj = dagNode.child(0); // obj is the shape, which is where we can add the meta data MFnDependencyNode node = new MFnDependencyNode(obj); Console.WriteLine( "METADATA for node " + dagNode.fullPathName ); Console.WriteLine( "=====================================================================" ); foreach( Channel chn in node.metadata) { Console.WriteLine("Channel: type = {0}, nbStreams = {1}", chn.nameProperty, chn.dataStreamCount); foreach (Stream strm in chn) { Console.WriteLine("Stream: name = {0}, nbElements = {1}", strm.name, strm.elementCount() ); Structure strct = strm.structure; Console.WriteLine("Structure: name = {0}, nbMembers = {1}", strct.name, strct.memberCount ); string[] memberNames = new string[strct.memberCount]; int memberID = -1; foreach( Member member in strct ) { ++memberID; Console.WriteLine("Structure member: name = {0}, type = {1}, array size = {2}", member.nameProperty, member.typeProperty.ToString(), member.lengthProperty ); memberNames[memberID] = member.nameProperty; } int k = -1; foreach (Handle handle in strm) { ++k; for (uint n = 0; n < strct.memberCount; ++n) { handle.setPositionByMemberIndex(n); Array data = handle.asType; if( data.Length < 1 ) throw new ApplicationException( "Handle data seems corrupted" ); string line = string.Format( "Handle #{0}, member = {1}, data = {2}", k, memberNames[n], data.GetValue(0).ToString() ); if( data.Length > 1 ) { for( int d = 1; d < data.Length; ++d ) { line = line + "," + data.GetValue(d).ToString(); } } Console.WriteLine( line ); } } } } } }
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) { 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(); }
override public void doIt(MArgList args) { Console.WriteLine("lineManipContainerContextCommand..."); return; }