创建新图层
public static void CreateLayer(string LayerName)
{
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 = LayerName;
if (acLyrTbl.Has(sLayerName) == false)
{
using (LayerTableRecord acLyrTblRec = new LayerTableRecord())
{
acLyrTblRec.Name = sLayerName;
acLyrTbl.UpgradeOpen();
acLyrTbl.Add(acLyrTblRec);
acTrans.AddNewlyCreatedDBObject(acLyrTblRec, true);
}
}
acTrans.Commit();
}
}
镜像CAD实体对象
public static Entity MirrorEntity(this ObjectId entId, Point3d point1, Point3d point2, bool isEraseSource)
{
Entity entR;
Matrix3d mt = Matrix3d.Mirroring(new Line3d(point1, point2));
using (Transaction trans = entId.Database.TransactionManager.StartTransaction())
{
if (isEraseSource)
{
Entity ent = (Entity)trans.GetObject(entId, OpenMode.ForWrite);
ent.TransformBy(mt);
entR = ent;
}
else
{