using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using System.Reflection;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
 
namespace AutoCAD_CSharp_plug_in1
{
  public class MyCommands
  {
    [CommandMethod("TestMove", CommandFlags.Modal)]
    public void Test()
    {
      Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
      PromptEntityOptions prOpt = 
        new PromptEntityOptions("\nУкажите объект для перемещения: ");
      PromptEntityResult rs = ed.GetEntity(prOpt);
      if (rs.Status != PromptStatus.OK) return;
      PromptPointOptions p1Opt = 
        new PromptPointOptions("\nУкажите первую точку перемещения: ");
      PromptPointResult rs1 = ed.GetPoint(p1Opt);
      if (rs1.Status != PromptStatus.OK) return;
      PromptPointOptions p2Opt =
        new PromptPointOptions("\nУкажите вторую точку перемещения: ");
      PromptPointResult rs2 = ed.GetPoint(p2Opt);
      if (rs2.Status != PromptStatus.OK) return;
      ed.Command("_.MOVE", "_SI", rs.ObjectId, rs1.Value, rs2.Value, "");
    }
  }
}
 
namespace Autodesk.AutoCAD.EditorInput
{
  public static class EditorInputExtensionMethods
  {
    public static PromptStatus Command(this Editor editor, params object[] args)
    {
      if (editor == null)
        throw new ArgumentNullException("editor");
      return runCommand(editor, args);
    }
 
    static Func<Editor, object[], PromptStatus> runCommand = GenerateRunCommand();
 
    static Func<Editor, object[], PromptStatus> GenerateRunCommand()
    {
      MethodInfo method = typeof(Editor).GetMethod("RunCommand",
         BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
      var instance = Expression.Parameter(typeof(Editor));
      var args = Expression.Parameter(typeof(object[]));
      return Expression.Lambda<Func<Editor, object[], PromptStatus>>(
         Expression.Call(instance, method, args), instance, args)
            .Compile();
    }
  }
}