//https://blog.csdn.net/qq_21489689?t=1
[CommandMethod("CREATELY")] public void CreateLayer() { Document acDoc = Application.DocumentManager.MdiActiveDocument; Database acCurDb = acDoc.Database;//获取当前数据库 using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) { //以读的方式打开图层表 LayerTable acLyrTbl = acTrans.GetObject(acCurDb.LayerTableId,OpenMode.ForRead) as LayerTable; string sLayerName = "Layer Name";//设定一个图层名称 if (acLyrTbl.Has(sLayerName) == false) { using (LayerTableRecord acLyrTblRec = new LayerTableRecord()) { acLyrTblRec.Color = Color.FromColorIndex(ColorMethod.ByAci, 3);// 指定图层颜色 acLyrTblRec.Name = sLayerName;// 指定图层名称 acLyrTbl.UpgradeOpen();//修改图层打开方式为写 acLyrTbl.Add(acLyrTblRec);//将新图层追加到图层表 acTrans.AddNewlyCreatedDBObject(acLyrTblRec, true); } } acTrans.Commit(); } }

 

相关文章:

  • 2021-05-07
  • 2021-09-12
  • 2021-12-27
  • 2022-12-23
  • 2022-01-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-14
  • 2022-12-23
相关资源
相似解决方案