下面的代码代码是反射调用Com的代码
当然,你也可以先引用AutoCad的类型库,
然后直接调用Application.AcadApplication.ZoomExtents()方法
-
- using System;
- using System.Reflection;
- using Autodesk.AutoCAD.ApplicationServices;
- using Autodesk.AutoCAD.DatabaseServices;[assembly: CommandClass(typeof(TlsCad.TlsTest))]namespace TlsCad
- {
- class TlsTest
- {
- [CommandMethod("zet")]
- public static void ZoomExtents()
- {
- object app = Application.AcadApplication;
- Type acApp = Type.GetTypeFromHandle(Type.GetTypeHandle(app));
- acApp.InvokeMember(
- "ZoomExtents",
- BindingFlags.InvokeMethod,
- null,
- app,
- new object[0]);
- }
- }
- }
|