public class TestCommand {
[CommandMethod(nameof(CurveBoundDemo))]
public void CurveBoundDemo() {
using DBTrans tr = new();
var pl = Env.Editor.SelectEntity<Polyline>("\n请选择多段线");
if (pl is null) return;
Curve3d curve3d = pl.GetGeCurve();
CreateRect(curve3d.BoundBlock, 1);
CreateRect(curve3d.OrthoBoundBlock, 2);
Interval it = new Interval(1,1,0.1);
double[] bs = it.GetBounds();
for(int i = 0; i < bs.Length; i++) {
Env.PrintLine(bs[i]);
}
var box = curve3d.GetBoundBlockOf();
var box2 = curve3d.GetBoundBlockOf(it);
}
public void CreateRect(BoundBlock3d BoundBlock, int colorIndex) {
var tr = DBTrans.Top;
var left = BoundBlock.GetMinimumPoint().X;
var bottom = BoundBlock.GetMinimumPoint().Y;
var right = BoundBlock.GetMaximumPoint().X;
var top = BoundBlock.GetMaximumPoint().Y;
List<Point2d> pts = new();
pts.Add(new Point2d(left, bottom));
pts.Add(new Point2d(right, bottom));
pts.Add(new Point2d(right, top));
pts.Add(new Point2d(left, top));
Polyline polyline = new Polyline();
for(int i = 0; i < pts.Count; i++) {
polyline.AddVertexAt(i, pts[i], 0, 0, 0);
}
polyline.ColorIndex = colorIndex;
polyline.Closed = true;
tr.CurrentSpace.AddEntity(polyline);
}
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· 写一个简单的SQL生成工具