明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 795|回复: 3

[源码] (MBWP)打断于多边形(欢迎大佬们多给建议和意见)

  [复制链接]
发表于 2021-4-20 14:50 | 显示全部楼层 |阅读模式
本帖最后由 fangmin723 于 2021-4-20 18:56 编辑

  1. ;;说明:打断于多边形  by-忘霄 2021.4.20
  2. (defun C:MBWP(/ bf-list-split-3d breakapt edta ename ent eptlst getptlst interwithpt ss startbreak);c:MyBreakWithPolygon
  3.   (defun breakapt(ent elst iptlst / ilst)
  4.     (foreach e elst
  5.       (if (setq ilst (InterWithPt ent e))
  6.         (foreach p ilst
  7.           (if (not (member p iptlst))
  8.             (progn
  9.               (command "_.BREAK" e "_non" (trans p 0 1) "_non" (trans p 0 1))
  10.               ;(command "_.BREAK" e p "@")
  11.               (breakapt
  12.                 ent
  13.                 (if (and (= 1 (length (setq ips (InterWithPt ent e)))) (equal (car ips) p 1e-8))
  14.                   (vl-remove e (cons (entlast) elst))
  15.                   (if (and (= 1 (length (setq ips (InterWithPt ent (entlast))))) (equal (car ips) p 1e-8))
  16.                     elst
  17.                     (cons (entlast) elst)
  18.                   )
  19.                 )
  20.                 (cons p iptlst)
  21.               )
  22.             )
  23.           )
  24.         )
  25.       )
  26.     )
  27.   )
  28.   (defun InterWithPt(ent1 ent2 / bf-list-split-3d var)
  29.     (defun BF-list-split-3d (lst)
  30.       (if lst (cons (list (car lst) (cadr lst) (caddr lst)) (BF-list-split-3d (cdddr lst))))
  31.     )
  32.     (if (> (vlax-safearray-get-u-bound (setq var (vlax-variant-value (vla-IntersectWith (vlax-ename->vla-object ent1) (vlax-ename->vla-object ent2) acExtendNone))) 1) 1)
  33.       (BF-list-split-3d (vlax-safearray->list var))
  34.       nil
  35.     )
  36.   )
  37.   (defun getptlst(e) (mapcar 'cdr (vl-remove-if-not (function (lambda(x) (= 10 (car x)))) (entget e))))
  38.   (defun BF-list-split-3d (lst)
  39.     (if lst (cons (list (car lst) (cadr lst) (caddr lst)) (BF-list-split-3d (cdddr lst))))
  40.   )
  41.   (defun startbreak(ent ss / ient inlst n)
  42.     (setq n -1)
  43.     (while (setq ient (ssname ss (setq n (1+ n))))
  44.       (if (setq inlst (InterWithPt ent ient))
  45.         (breakapt ent (list ient) '())
  46.       )
  47.     )
  48.   )
  49.   (command "_.UNDO" "be")
  50.   (if (setq ent (car (entsel "\n请选择【直线】或者【由多段线构成的多边形】:")))
  51.     (progn
  52.       (setq ename (cdr (assoc 0 (setq edta (entget ent)))))
  53.       (cond
  54.         ((equal ename "LINE")
  55.           (setq ss (ssdel ent (ssget "F" (list (cdr (assoc 10 edta)) (cdr (assoc 11 edta))))))
  56.           (startbreak ent ss)
  57.         )
  58.         ((equal ename "LWPOLYLINE")
  59.           (if (<= (length (setq eptlst (getptlst ent))) 2)
  60.             (setq ss (ssdel ent (ssget "F" eptlst)))
  61.             (setq ss (ssdel ent (ssget "CP" (append (setq eptlst (getptlst ent)) (list (car eptlst))))))
  62.           )
  63.           (startbreak ent ss)
  64.         )
  65.       )
  66.     )
  67.   )
  68.   (command "_.UNDO" "e")
  69.   (prin1)
  70. )

本帖子中包含更多资源

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

x

评分

参与人数 4明经币 +4 收起 理由
xj6019 + 1 很给力!
zixuan203344 + 1 小青春牛逼!
USER2128 + 1 赞一个!
bssurvey + 1 很给力!

查看全部评分

"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2021-4-22 02:54 | 显示全部楼层
又不能生成面域,否则功能会十分强大
发表于 2021-4-22 07:28 | 显示全部楼层
感谢大佬的分享精神
 楼主| 发表于 2021-4-22 08:52 | 显示全部楼层
meja 发表于 2021-4-22 02:54
又不能生成面域,否则功能会十分强大

生成面域论坛应该有,我记得G版写过一个
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-5 05:20 , Processed in 0.175988 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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