定义一个直线的函数
如何定义以下二种方法画一个直线的函数本帖最后由 chpmould 于 2010-12-5 21:16 编辑
// 由两点创建直线的ObjectId函数(第一种)
ObjectId Cir03 = AddLineb(new Point3d(15, 0, 0), new Point3d(-15, 0, 0));
public static ObjectId AddLine(Point3d pt1, Point3d pt2)
{
Line ent = new Line(pt1, pt2);
ObjectId entId = AppendEntity(ent);
return entId;
}
// 如果需要定义一个,按以下方式由两点创建直线的函数,怎么定义函数(第二种)
Line Cir03 = new Line(new Point3d(15, 0, 0), new Point3d(-15, 0, 0)); 这个没有必要做函数的 狐哥请示范一下: 我是想学习一下方法... 这个还真没有做过,也没必要
只需要做个添加的
public static ObjectId AddEntity(this BlockTableRecord btr, Transaction tr, Entity entity)
{
ObjectId id = btr.AppendEntity(entity);
tr.AddNewlyCreatedDBObject(entity, true);
return id;
} 谢谢!!! 我再去学习一下做一些子函,这样以后会方便很多... 你可以重载该函数
//ObjectId Cir03 = AddLineb(new Point3d(15, 0, 0), new Point3d(-15, 0, 0));
public static ObjectId AddLine()
{
Point3d pt1=new Point3d(15, 0, 0),;
Point3d pt2=new Point3d(-15, 0, 0));
Line ent = new Line(pt1, pt2);
ObjectId entId = AppendEntity(ent);
return entId;
}
谢谢楼上的朋友,这种方法我知道,我现在的遇到的问题是,在新建一个块时无法选取ObjectId Cir03 返回的ID
页:
[1]