// public static Dictionary<string, List<ObjectId>> GetEntities(this Database db) // { // return db.GetEntities(false, false, false); // } // // public static Dictionary<string, List<ObjectId>> GetEntities(this Database db, // bool EvalOffLayers, // bool EvalFrozenLayers) // { // return db.GetEntities(EvalOffLayers, EvalFrozenLayers, false); // } // public static Dictionary<string, List<ObjectId>> GetEntities(this Database db, // bool EvalOffLayers, // bool EvalFrozenLayers, // bool EvalAnonymBlocks) // { // return db.GetEntities(EvalOffLayers, EvalFrozenLayers, EvalAnonymBlocks, false); // } public static Dictionary <string, List <ObjectId> > GetEntities(this Database db, bool EvalOffLayers, bool EvalFrozenLayers, bool EvalAnonymBlocks, bool EvalXrefs, bool EvalLayouts) { Dictionary <string, List <ObjectId> > result = new Dictionary <string, List <ObjectId> >(); using (Transaction tr = db.TransactionManager.StartTransaction()) { BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead); foreach (ObjectId btrId in bt) { BlockTableRecord btr = (BlockTableRecord)tr.GetObject(btrId, OpenMode.ForRead); if (btr.IsFromExternalReference && !EvalXrefs) { continue; } if (btr.IsAnonymous && !EvalAnonymBlocks) { continue; } if (btr.IsLayout && !EvalLayouts) { continue; } foreach (KeyValuePair <string, List <ObjectId> > kvp in btr.GetEntities(EvalOffLayers, EvalFrozenLayers)) { if (!result.ContainsKey(kvp.Key)) { result.Add(kvp.Key, new List <ObjectId>()); } result[kvp.Key].AddRange(kvp.Value); } } } return(result); }
/// <summary> /// Gets the entities. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="btr">The BTR.</param> /// <param name="mode">The mode.</param> /// <param name="includingErased">if set to <c>true</c> [including erased].</param> /// <param name="openObjectsOnLockedLayers">if set to <c>true</c> [open objects on locked layers].</param> /// <returns></returns> public static IEnumerable <T> GetEntities <T>(this BlockTableRecord btr, OpenMode mode = OpenMode.ForRead, bool includingErased = false, bool openObjectsOnLockedLayers = false) where T : Entity { return(btr.GetEntities <T>(btr.Database.TransactionManager.TopTransaction, mode, includingErased, openObjectsOnLockedLayers)); }
/// <summary> /// Gets the attribute definitions. /// </summary> /// <param name="btr">The BTR.</param> /// <param name="trx">The TRX.</param> /// <param name="mode">The mode.</param> /// <param name="includingErased">if set to <c>true</c> [including erased].</param> /// <param name="openObjectsOnLockedLayers">if set to <c>true</c> [open objects on locked layers].</param> /// <returns></returns> public static IEnumerable <AttributeDefinition> GetAttributeDefinitions(this BlockTableRecord btr, Transaction trx, OpenMode mode = OpenMode.ForRead, bool includingErased = false, bool openObjectsOnLockedLayers = false) { return(btr.GetEntities <AttributeDefinition>(trx, mode, includingErased, openObjectsOnLockedLayers)); }
public static Dictionary <string, List <ObjectId> > GetEntities(this BlockTableRecord btr) { return(btr.GetEntities(false, false)); }