通过给定点和两已知直线做垂线段

 这个是在objectArx网站上看到别人提的问题,其实一开始我也不会,不过看了别人的提示之后,也就会了,废话少说,上代码:

[CommandMethod("test")]

public void test()

{

    Document doc = Application.DocumentManager.MdiActiveDocument;

    Database db = doc.Database;

    Transaction trans = db.TransactionManager.StartTransaction();

    BlockTable bt = trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;

    BlockTableRecord btr = trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;

    Line l1 = new Line(new Point3d(100, 400, 0), new Point3d(200, 600, 0));

    Line l2 = new Line(new Point3d(150, 400, 0), new Point3d(300, 700, 0));

    l1.ColorIndex = 2;

    l2.ColorIndex = 2;

    Point3d p1, p2;

    p1 = l1.GetClosestPointTo(new Point3d(500, 500, 0), true);

    p2 = l2.GetClosestPointTo(p1, true);

    Line c = new Line(p1,p2);

    c.ColorIndex = 1;

    btr.AppendEntity(l1);

    trans.AddNewlyCreatedDBObject(l1, true);

    btr.AppendEntity(l2);

    trans.AddNewlyCreatedDBObject(l2, true);

    btr.AppendEntity(c);

    trans.AddNewlyCreatedDBObject(c, true);

    trans.Commit();

    trans.Dispose();

}

 运行后效果如下,红色线段即是:

通过给定点和两已知直线做垂线段 - Castor - 趁年轻,多折腾~~

 

 

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值