用C#写一个autocad插件,可以快速闭合所有多段线
using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.Runtime; namespace ClosePolyline { public class Commands { [CommandMethod("CloseAll")] public void CloseAll() { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; PromptSelectionResult psr = ed.GetSelection(); if (psr != null) { SelectionSet ss = psr .Value ; foreach (ObjectId id in ss .GetObjectIds()) { using (Transaction trans = db .TransactionManager .StartTransaction()) { Entity ent = trans .GetObject(id, OpenMode .ForWrite) as Entity ; if (ent is Polyline) { Polyline pline = ent as Polyline ; pline .Closed=true ; } trans .Commit() ; } } } else ed .WriteMessage("No objects selected.") ; } } }
创作工场
免责声明:
以上内容除特别注明外均来源于网友提问,创作工场回答,未经许可,严谨转载。
点击这里>>使用🔥专业版,更聪明、更完整、更原创!