将实体添加到集合中的方法
请问老师:我按以下方式创建的两个圆,能否分别添加到ObjectIdCollection cir01 = new ObjectIdCollection();
或
DBObjectCollection objs = new DBObjectCollection();
本帖最后由 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, OpenMode.ForWrite);
Circle cr = new Circle(cenPt, Vector3d.ZAxis, radius);
btr.AppendEntity(cr);
tr.AddNewlyCreatedDBObject(cr, true);
tr.Commit();
}
} 看来你还是没有理解Cad的Database的结构,还是先把我前面贴过的代码仔细研究下吧 btr.AppendEntity(cr)会返回cr的objectid 本帖最后由 chpmould 于 2010-12-7 07:32 编辑
请问老师: 我现在主要是想先搞懂,如何去自定义一些子函数...
比喻:现在需要画一个比较复杂的图形,一般需要如何去定义,能否给出一个学习思路,因为我是刚接触C#,所以我想先找到一个好的方法来学习,从而养成一个好的编程习惯...
页:
[1]