haoxuan 发表于 2024-1-26 11:09

如何获得分堆分组后包围盒的四个角点,然后用直线连接起来

本帖最后由 haoxuan 于 2024-2-8 15:37 编辑

http://bbs.mjtd.com/forum.php?mo ... 448&fromuid=7332155 (出处: 明经CAD社区)]【K:RtnBox4SSGroup】矩形分堆/方框分堆 http://bbs.mjtd.com/forum.php?mo ... 448&fromuid=7332155 (出处: 明经CAD社区)

如何取出分堆分组后包围盒的四个角点,然后赋予变量P1、P2、P3、P4

飞雪神光 发表于 2024-1-26 11:09

(setq lst (K:RtnBox4SSGroup(ssget) 5))
(foreach pts lst
        (setq
                zx(car pts)
                ys(cadr pts)
                zs(list (car zx)(cadr ys))
                yx(list (car ys)(cadr zx))
        )
        (entmake (list '(0 . "line") (cons 10 zx) (cons 11 zs)))
        (entmake (list '(0 . "line") (cons 10 zs) (cons 11 ys)))
        (entmake (list '(0 . "line") (cons 10 ys) (cons 11 yx)))
        (entmake (list '(0 . "line") (cons 10 zx) (cons 11 yx)))
)

haoxuan 发表于 2024-3-5 14:38

谁知道啊谁知道啊谁知道啊谁知道啊

d1742647821 发表于 2024-3-11 11:09

本帖最后由 d1742647821 于 2024-3-11 11:11 编辑

powered by IFoxCAD
https://gitee.com/inspirefunction/ifoxcad
https://www.kdocs.cn/l/cc6ZXSa0vMgD


var r1 = Env.Editor.GetSelection();
if (r1.Status != PromptStatus.OK)
    return;
using var tr = new DBTrans();
var entList = r1.Value.GetEntities<Entity>().Select(e =>
{
    var bi = e.GetBoundingBoxEx();
    if (bi.HasValue)
      return bi.Value;
    var e3d = new Extents3d();
    foreach (var stretchPoint in e.GetStretchPoints())
    {
      e3d.AddPoint(stretchPoint);
    }
    return new BoundingInfo(e3d);
}).ToList();
var boxGroup = entList.Friends((e1, e2) =>
{
    var vec = e1.MidCenter.GetVectorTo(e2.MidCenter);
    return vec.X < (e1.Width * 0.5 + e2.Width * 0.5) &&
         vec.Y < (e1.Height * 0.5 + e2.Height * 0.5);
});
foreach (var list in boxGroup)
{
    var e3d = new Extents3d();
    foreach (var info in list)
    {
      e3d.AddExtents(info.Extents3d);
    }
    tr.CurrentSpace.AddEntity(e3d.GetRecPoint2ds().ToPolyline(0, true));
}

loveu515 发表于 2024-3-15 17:16

能把要求再写清楚点吗?

LPACMQ 发表于 2024-4-6 13:52

(setq lst (K:RtnBox4SSGroup(ssget) 6))

(foreach pp lst

        ;;赋值P1~4
        (setq p1(carpp) p3(cadr pp))
        (setq p2(list (car p3) (cadr p1)))
        (setq p4(list (car p1) (cadr p3)))
        (setq 4pt(list p1 p2 p3 p4))
       
        ;;测试
        (foreach p 4pt (getpoint p))

)
页: [1]
查看完整版本: 如何获得分堆分组后包围盒的四个角点,然后用直线连接起来