明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1208|回复: 8

[基础] 定义一个直线的函数

[复制链接]
发表于 2010-12-5 21:15 | 显示全部楼层 |阅读模式
如何定义以下二种方法画一个直线的函数

 楼主| 发表于 2010-12-5 21:16 | 显示全部楼层
本帖最后由 chpmould 于 2010-12-5 21:16 编辑
  1. // 由两点创建直线的ObjectId函数(第一种)
  2. ObjectId Cir03 = AddLineb(new Point3d(15, 0, 0), new Point3d(-15, 0, 0));
  3. public static ObjectId AddLine(Point3d pt1, Point3d pt2)
  4. {
  5.   Line ent = new Line(pt1, pt2);
  6.   ObjectId entId = AppendEntity(ent);
  7.   return entId;
  8. }

  9. // 如果需要定义一个,按以下方式由两点创建直线的函数,怎么定义函数(第二种)
  10. Line Cir03 = new Line(new Point3d(15, 0, 0), new Point3d(-15, 0, 0));
复制代码
发表于 2010-12-5 21:34 | 显示全部楼层
这个没有必要做函数的
 楼主| 发表于 2010-12-5 21:41 | 显示全部楼层
狐哥请示范一下: 我是想学习一下方法...
发表于 2010-12-5 22:01 | 显示全部楼层
这个还真没有做过,也没必要
只需要做个添加的
public static ObjectId AddEntity(this BlockTableRecord btr, Transaction tr, Entity entity)
{
    ObjectId id = btr.AppendEntity(entity);
    tr.AddNewlyCreatedDBObject(entity, true);
    return id;
}
 楼主| 发表于 2010-12-5 22:19 | 显示全部楼层
谢谢!!! 我再去学习一下做一些子函,这样以后会方便很多...
发表于 2010-12-7 10:43 | 显示全部楼层
你可以重载该函数
发表于 2010-12-7 10:45 | 显示全部楼层

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

}
 楼主| 发表于 2010-12-7 12:25 | 显示全部楼层
谢谢楼上的朋友,这种方法我知道,我现在的遇到的问题是,在新建一个块时无法选取ObjectId Cir03 返回的ID
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-17 12:03 , Processed in 0.169988 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表