找回密码
 立即注册
查看: 4040|回复: 7

[分享] Tracing a boundary defined by AutoCAD geometry using .NET

[复制链接]
发表于 2014-5-8 15:31:52 来自手机 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
本帖最后由 csharp 于 2014-5-9 07:05 编辑

http://through-the-interface.typepad.com/through_the_interface/2010/06/tracing-a-boundary-defined-by-autocad-geometry-using-net.html

Tracing a boundary defined by AutoCAD geometry using .NET



As alluded to in this previous post, today we’re going to see some code that makes use of a very cool new API feature in AutoCAD 2011: the Editor.TraceBoundary() function. This little gem performs something developers have struggled with – and have asked us for – for many years. Previously you had to jump through significant hoops (or should that be loops? <groan>) to get this to work: one common approach would be to drive the BOUNDARY command programmatically and check the results appended to the database. All very messy.

Anyway, we got there eventually. This function takes a “seed” point and returns a collection of newly-created entities that define our boundary. We can then either pump these through the transient graphics sub-system or – and this is the approach we’re going to take – add them to the drawing to make them persistent.

You need to bear in mind that this function ultimately has similar constraints to the BOUNDARY and BHATCH commands: it also works off AutoCAD’s display list and so the user will need to be appropriately ZOOMed into the geometry that is to be used for boundary detection.

Here’s some C# code to create boundaries – with a lineweight applied and of an automatically incremented colour index – for points the user selects:

using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.Runtime; namespace TraceBoundary { public class Commands { static int _index = 1; [CommandMethod("TB")] public void TraceBoundary() { Document doc = Application.DocumentManager.MdiActiveDocument;
展开

Here’s our TB command in action.

Before…
untitled1.png
untitled2.png
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2014-5-9 11:41:53 | 显示全部楼层
LZ,没有lisp版的?

点评

可以写成一个lisp函数,就如xdrxapi  详情 回复 发表于 2014-5-9 11:46
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-5-9 11:46:38 来自手机 | 显示全部楼层
本帖最后由 csharp 于 2014-5-9 12:21 编辑
/db_自贡黄明儒_ 发表于 2014-5-9 11:41
LZ,没有lisp版的?


可以写成一个lisp函数,就如xdrxapi
低版本的Net没有这个函数,2011以上
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2019-4-23 09:02:48 来自手机 | 显示全部楼层
hpgaptol系统变量不能自动找到封闭区域,有办法自定义traceboundary吗?
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2019-6-30 16:26:41 | 显示全部楼层
非常感谢楼主,学习一下
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2019-9-1 11:51:54 来自手机 | 显示全部楼层
感谢楼主分享!学习中!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2019-9-1 11:53:36 来自手机 | 显示全部楼层
感谢楼主分享!学习中!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2019-10-17 19:48:11 来自手机 | 显示全部楼层
图很大的时候 这个会很慢吧
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2026-12-1 22:11 , Processed in 0.209078 second(s), 41 queries , Gzip On.

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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