What is not said, put the code
namespace JoinBox { public enum XrefEnum { /// <summary> /// 卸载 /// </summary> UnloadXrefs, /// <summary> /// 重载 /// </summary> ReloadXrefs, /// <summary> /// 拆离 /// </summary> DetachXref, /// <summary> /// 绑定 /// </summary> BindXrefs, } public static classXrefTool { /// <Summary> /// modified xref /// </ Summary> /// <param name = "DB"> Database </ param> /// <param name = "XE"> set enumeration status </ param> /// <param name = "names"> name of the reference to be treated with, null reference to handle all </ param> public static void SetXref ( the this Database DB, XrefEnum XE, the IEnumerable < String > = names null ) { db.ResolveXrefs ( to false , to true ); // resolve external references (using linear engine,Only new) var= IDS new new ObjectIdCollection (); var XG = db.GetHostDwgXrefGraph ( to true ); // Shenma zombie reference for ( int I = 0 ; I <xg.NumNodes; I ++ ) { var XNode = xg.GetXrefNode (I) AS XrefGraphNode; // IF (! = xNode.XrefStatus XrefStatus.Resolved) // status determination IF (xNode.BlockTableRecordId.IsOk ()) { IF (! names = null ) { the foreach ( var Itemin names) { // only added to the same name IF (item.ToUpper () == xNode.Name.ToUpper ()) { ids.Add (xNode.BlockTableRecordId); } } } the else { // each added ids .add (xNode.BlockTableRecordId); } } } // btRec.IsFromOverlayReference // is covered? // XrefStatus external reference status //GetXrefDatabase external reference database IF (ids.Count == 0 ) { return ; } Switch (XE) { Case XrefEnum.BindXrefs: // Binds automatically detached { db.BindXrefs (IDS, to true ); } BREAK ; Case XrefEnum.DetachXref: // detached { the foreach (the ObjectId Item in IDS) { db.DetachXref (Item); } } BREAK ; Case XrefEnum.UnloadXrefs: // unloading { db.UnloadXrefs (IDS); } BREAK ; Case XrefEnum.ReloadXrefs: // Overload { db.ReloadXrefs (IDS); } BREAK ; } } } } /// <the Summary> /// the above mentioned id valid, not deleted /// </ the Summary> /// <param name="id"></param> /// <returns></returns> public static bool IsOk(this ObjectId id) { return !id.IsNull && id.IsValid && !id.IsErased && !id.IsEffectivelyErased && id.IsResident; }