title: Using Editor class in AutoCAD to execute commands
body: <p>I'm trying to create a button that, when pressed, marks the position of the drawing. Right now the method looks like this.</p>
  
  <pre><code>[CommandMethod("MARKPOS", CommandFlags.Session)]
  public void MarkPosition()
  {
      Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
      ed.Command("UNDO", "M");
  }
  </code></pre>
  
  <p>However, when I try and execute the method I get the error pictured below and cannot determine why.</p>
  
  <p><img src="https://i.stack.imgur.com/djWJx.png" alt="enter image description here"></p>
  
  <p>************** Exception Text **************
  Autodesk.AutoCAD.Runtime.Exception: eInvalidInput
  at Autodesk.AutoCAD.EditorInput.Editor.Command(Object[] parameter)
  at AutoCAD_Adapter.MyCommands.MarkPosition() in c:\Users\nickg\Documents\All Code\autocad-adapter\IOAutoCADHandler\myCommands.cs:line 186
  at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorker(MethodInfo mi, Object commandObject, Boolean bLispFunction)
  at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorkerWithExceptionFilter(MethodInfo mi, Object commandObject, Boolean bLispFunction)
  at Autodesk.AutoCAD.Runtime.PerDocumentCommandClass.Invoke(MethodInfo mi, Boolean bLispFunction)
  at Autodesk.AutoCAD.Runtime.CommandClass.CommandThunk.Invoke()</p>