删除扩展数据

mac2022-06-30  161

1 public static void RemoveXData(Entity EntObject, string XDataName) 2 { 3 Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; 4 Database db = HostApplicationServices.WorkingDatabase; 5 6 using (DocumentLock docLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument()) 7 { 8 try 9 {10 using (Transaction tr = db.TransactionManager.StartTransaction())11 {12 DBObject obj = tr.GetObject(EntObject.ObjectId, OpenMode.ForWrite);13 ResultBuffer rb = obj.XData;14 if (rb != null)15 {16 TypedValue[] values = rb.AsArray();17 for (int i = 0; i < values.Length; i++)18 {19 if (values[i].TypeCode == (int)DxfCode.ExtendedDataRegAppName && values[i].Value.ToString() == XDataName)20 {21 //移除之 22 TypedValue[] values_New = { new TypedValue((int)DxfCode.ExtendedDataRegAppName, values[i].Value.ToString()) };23 ResultBuffer rb_New = new ResultBuffer(values_New);24 obj.UpgradeOpen();25 obj.XData = rb_New;26 obj.DowngradeOpen();27 }28 }29 }30 tr.Commit();31 }32 }33 catch (System.Exception exc)34 {35 ed.WriteMessage(exc.Message);36 }37 }38 }

转载于:https://www.cnblogs.com/chinaHunk/archive/2011/11/09/2242212.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)