using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.GraphicsInterface;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.ApplicationServices;
[assembly: ExtensionApplication(typeof(ClassLibrary.Lab8Class))]
[assembly: CommandClass(typeof(ClassLibrary.Lab8Class))]
namespace ClassLibrary
{ public class Lab8Class:IExtensionApplication { public void Initialize() { Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("\n调试程序命令LV");//初始化操作
} public void Terminate() { //清除操作 } public Lab8Class() { // // TODO: Add constructor logic here // } Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; Database db = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase; Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase.TransactionManager; // Define Command "AsdkCmd1" [CommandMethod("LV")] public void getPlPoint() // This method can have any name { try { Transaction trans=tm.StartTransaction();
// BlockTableRecord btr;
// BlockTable bt; using(trans) { PromptEntityResult per = ed.GetEntity("请选择多段线"); if(per.Status == PromptStatus.OK) { DBObject obj = trans.GetObject(per.ObjectId, OpenMode.ForRead); { Polyline PL = obj as Polyline; int vn = PL.NumberOfVertices; for(int i = 0; i<= vn; i++) { Point3d pt3d = PL.GetPoint3dAt(i-1);