- UID
- 658062
- 积分
- 2147
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2008-10-22
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
[ 本帖最后由 csharp 于 2014-5-15 10:12 编辑 ]\n\n[ 本帖最后由 csharp 于 2014-5-15 10:11 编辑 ]\n\n[ 本帖最后由 csharp 于 2014-5-9 06:53 编辑 ]\n\n[url=http://through-the-interface.typepad.com/through_the_interface/2012/11/creating-the-smallest-possible-rectangle-around-2d-autocad-geometry-using-net.html]http://through-the-interface.typepad.com/through_the_interface/2012/11/creating-the-smallest-possible-rectangle-around-2d-autocad-geometry-using-net.html[/url]
Creating the smallest possible rectangle around 2D AutoCAD geometry using .NET
There was a follow-up comment on this previous post, requesting that it also create a rectangular boundary around selected geometry. This is a much simpler problem to solve that dealing with a minimum enclosing circle, so I was happy enough to oblige. :-)
Rather than duplicate code from the previous implement, I went ahead and generalised it to contain a core set of functions that get called from different commands: MEC in the existing case where circular boundaries are required and MER for the new case of a rectangular polyline boundary.
I’ve also adjusted the prompts and code to be more general – including renaming the system variable to ENCLOSINGBOUNDARYBUFFER, although I only tested via the fallback USERI1 variable – and it all seems to work as expected.
Here’s the updated C# code:
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Geometry;
using System.Collections.Generic;
using System.Linq;
using System;
namespace MinimumEnclosingBoundary
Here’s the MER command in action, using a 15% boundary and choosing to create individual boundaries for each object:
Rectangular boundaries around geometry
|
-
|