public void CreateRegion1() { ObjectId loopId1 = ModelSpace.AddLine(new Point3d(100, 0, 0), new Point3d(0, 0, 0)); ObjectId loopId2 = ModelSpace.AddLine(new Point3d(100, 0, 0), new Point3d(80, 60, 0)); ObjectId loopId3 = ModelSpace.AddLine(new Point3d(80, 60, 0), new Point3d(0, 0, 0)); DBObject ent1; DBObject ent2; DBObject ent3; Database db = HostApplicationServices.WorkingDatabase; using (Transaction trans = db.TransactionManager.StartTransaction()) { ent1 = (Entity)trans.GetObject(loopId1, OpenMode.ForWrite); ent2 = (Entity)trans.GetObject(loopId2, OpenMode.ForWrite); ent3 = (Entity)trans.GetObject(loopId3, OpenMode.ForWrite); trans.Commit(); } DBObjectCollection objIds = new DBObjectCollection(); objIds.Add(ent1); objIds.Add(ent2); objIds.Add(ent3); ObjectIdCollection regionId = ModelSpace.AddRegion(objIds); }
public void CreateRegion2() { // 在内存中创建面域的边界对象. Line ent1 = new Line(new Point3d(100, 0, 0), new Point3d(0, 0, 0)); Line ent2 = new Line(new Point3d(100, 0, 0), new Point3d(80, 60, 0)); Line ent3 = new Line(new Point3d(80, 60, 0), new Point3d(0, 0, 0)); Circle ent4 = new Circle(new Point3d(200, 50, 0), Vector3d.ZAxis, 60); // 边界对象添加到对象集合. DBObjectCollection ents = new DBObjectCollection(); ents.Add(ent1); ents.Add(ent2); ents.Add(ent3); ents.Add(ent4); // 创建面域并加入到图形数据库. ObjectIdCollection regionIds = ModelSpace.AddRegion(ents); }