latour_g 发表于 2015-12-7 11:21:27

EditorInput扩展方法,2014到2016问题

嗨,
我有一个在Autocad 2014上运行良好的问题,但在Autocad 2016上出现了异常。当我使用以下命令时出现问题:
ed.Command("_measure", ent.ObjectId, "_block", "SMBVD11", "_yes", MB.MecaEchelle);
    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 runCommand = GenerateRunCommand();
      static Func GenerateRunCommand()
      {
            MethodInfo method = typeof(Editor).GetMethod("RunCommand",
            BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
            ParameterExpression instance = Expression.Parameter(typeof(Editor), "editor");
            ParameterExpression args = Expression.Parameter(typeof(object[]), "args");
            return Expression.Lambda>(Expression.Call(instance, method, args), instance, args).Compile();
      }
    }

我不知道需要做些什么才能使它正常工作。
(我使用的是Visual Studio 2010,目标框架是。Net Framework 4)谢谢

**** Hidden Message *****

gile 发表于 2015-12-7 12:12:00

嗨,
由于AutoCAD 2015 Autodesk.AutoCAD.EditorInput.Editor.Command()方法是在AcCoreMgd.dll中定义的公共方法,因此我们不需要使用任何扩展方法。
你可以阅读thi :
http://through-the-interface.typepad.com/through_the_interface/2014/03/autocad-2015-calling-commands.html
和 this:
http://www.theswamp.org/index.php?topic=49124

latour_g 发表于 2015-12-7 15:30:11

真的非常感谢!
页: [1]
查看完整版本: EditorInput扩展方法,2014到2016问题