本帖最后由 chpmould 于 2010-12-6 22:43 编辑
以下是我创建的两个圆的方法:- // 创建圆
- AddCircle(new Point3d(0, 0, 0), 6);
- AddCircle(new Point3d(0, 0, 0), 8);
- public static void AddCircle(Point3d cenPt, double radius)
- {
- Database db = HostApplicationServices.WorkingDatabase;
- using (Transaction tr = db.TransactionManager.StartTransaction())
- {
- BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
- BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
- Circle cr = new Circle(cenPt, Vector3d.ZAxis, radius);
- btr.AppendEntity(cr);
- tr.AddNewlyCreatedDBObject(cr, true);
- tr.Commit();
- }
- }
|