chpmould 发表于 2010-12-5 21:15:03

定义一个直线的函数

如何定义以下二种方法画一个直线的函数

chpmould 发表于 2010-12-5 21:16:10

本帖最后由 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));

雪山飞狐_lzh 发表于 2010-12-5 21:34:32

这个没有必要做函数的

chpmould 发表于 2010-12-5 21:41:24

狐哥请示范一下: 我是想学习一下方法...

雪山飞狐_lzh 发表于 2010-12-5 22:01:42

这个还真没有做过,也没必要
只需要做个添加的
public static ObjectId AddEntity(this BlockTableRecord btr, Transaction tr, Entity entity)
{
    ObjectId id = btr.AppendEntity(entity);
    tr.AddNewlyCreatedDBObject(entity, true);
    return id;
}

chpmould 发表于 2010-12-5 22:19:23

谢谢!!! 我再去学习一下做一些子函,这样以后会方便很多...

cdinten 发表于 2010-12-7 10:43:00

你可以重载该函数

cdinten 发表于 2010-12-7 10:45:00


//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;

}

chpmould 发表于 2010-12-7 12:25:17

谢谢楼上的朋友,这种方法我知道,我现在的遇到的问题是,在新建一个块时无法选取ObjectId Cir03 返回的ID
页: [1]
查看完整版本: 定义一个直线的函数