private static void ProcessingDwgsEntities(ObjectId btrId, Transaction transaction, Func <Entity, Entity> processFunc, bool toStatic) { if (btrId == ObjectId.Null) { return; } BlockTableRecord blockTableRecord = transaction.GetObject(btrId, OpenMode.ForRead) as BlockTableRecord; if (blockTableRecord == null) { return; } foreach (ObjectId entId in blockTableRecord) { try { if (entId == ObjectId.Null) { return; } Entity entity = transaction.GetObject(entId, OpenMode.ForRead) as Entity; if (entity == null) { continue; } BlockReference blockRef = entity as BlockReference; if (blockRef != null) { if (toStatic) { blockRef.ConvertToStaticBlock(); } ProcessingDwgsEntities(blockRef.BlockTableRecord, transaction, processFunc, toStatic); } else { entity.UpgradeOpen(); entity = processFunc(entity); entity.DowngradeOpen(); } } catch {} } }