Database db = HostApplicationServices.WorkingDatabase;
List list = new List();
using (Transaction trans = db.TransactionManager.StartTransaction())
{
LayerTable layertable = (LayerTable)trans.GetObject(db.LayerTableId,
OpenMode.ForWrite); //得到所有的层表
if (layertable != null)
{
foreach (ObjectId id in layertable) //遍历层表
{
LayerTableRecord tr=trans.GetObject(id,OpenMode.ForRead)
as LayerTableRecord; //获得层表记录
list.Add(tr); //将所有的图层放入一个集合中
}