明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3776|回复: 4

[原创]复合线运算合并程序!

[复制链接]
发表于 2003-9-13 19:22:00 | 显示全部楼层 |阅读模式
  1. ;;复合线合并
  2. (defun c:yad_plcomb(/ dxf chgent os qa entold kg s1 s2 n ss1 ss2 ent)
  3.   (defun dxf(en val)
  4.     (if (/= (type en) 'list) (setq en (entget en)))
  5.     (cdr (assoc val en))
  6.   )
  7.   (defun chgent(ent n new / en)
  8.     (setq en (entget ent))
  9.     (if (assoc n en)
  10.       (setq en (subst (cons n new) (assoc n en) en))
  11.       (setq en (append en (list (cons n new))))
  12.     )
  13.     (entmod en)
  14.   )
  15.   (command "_.undo" "_be")
  16.   (setq os (getvar "osmode")
  17.         qa (getvar "qaflags")
  18.   )
  19.   (setvar "osmode" 0)
  20.   (setvar "cmdecho" 0)
  21.   (setq entold (entlast))
  22.   (initget "1 2 3")
  23.   (setq kg (getkword "\n选择合并方式[1 并集/2 差集/3 交集]:<1>"))
  24.   (if (not kg) (setq kg "1"))
  25.   (prompt "\n请选择复合线:")
  26.   (if (setq s1 (ssget '((0 . "LWPOLYLINE"))))
  27.     (progn
  28.       (if (= kg "2")
  29.         (progn
  30.           (prompt "\n请选择要减去的复合线:")
  31.           (setq s2 (ssget '((0 . "LWPOLYLINE"))))
  32.         )
  33.       )
  34.       (if (not (and (= kg "2") (not s2)))
  35.         (progn
  36.           (setq n -1 ss1 (ssadd))
  37.           (repeat (sslength s1)
  38.             (setq ent (ssname s1 (setq n (1+ n))))
  39.             (if (= (dxf ent 70) 0) (chgent ent 70 1))
  40.             (command "_.region" ent "")
  41.             (ssadd (entlast) ss1)
  42.           )
  43.         )
  44.       )
  45.       (if s2
  46.         (progn
  47.           (setq n -1 ss2 (ssadd))
  48.           (repeat (sslength s2)
  49.             (setq ent (ssname s2 (setq n (1+ n))))
  50.             (if (= (dxf ent 70) 0) (chgent ent 70 1))
  51.             (command "_.region" ent "")
  52.             (ssadd (entlast) ss2)
  53.           )
  54.         )
  55.       )
  56.       (if (= kg "2")
  57.         (if ss2 (command "_.subtract" ss1 "" ss2 ""))
  58.         (command (if (= kg "1") "_.union" "_.intersect") ss1 "")
  59.       )
  60.       (setq ent (entlast))
  61.       (if (and ent (= (dxf ent 0) "REGION") (not (equal ent entold)))
  62.         (progn
  63.           (command "_.explode" ent)
  64.           (setq ss1 (ssget "p"))
  65.           (if (= (dxf (ssname ss1 0) 0) "REGION")
  66.             (progn
  67.               (setvar "qaflags" 1)
  68.               (command "_.explode" ss1 "")
  69.               (setq ss1 (ssget "p"))
  70.             )
  71.           )
  72.           (setq n -1)
  73.           (while (setq ent (ssname ss1 (setq n (1+ n))))
  74.             (if (entget ent)
  75.               (command "_.pedit" ent "y" "j" ss1 "" "")
  76.             )
  77.           )
  78.         )
  79.       )
  80.     )
  81.   )
  82.   (setvar "osmode" os)
  83.   (setvar "qaflags" qa)
  84.   (command "_.undo" "_e")
  85.   (princ)
  86. )
  87. (prompt "\n***复合线合并yad_plcomb***  YAD建筑")
  88. (princ)

"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2003-9-16 03:35:00 | 显示全部楼层
老兄我用了你的lsp程序只是图形里含有圆形就不可联集和差集能不能改进。另外可不可以让互相重叠的几何图形个自形成独立的线框就象 bo命令所重新生成的那样。
 楼主| 发表于 2003-9-16 08:45:00 | 显示全部楼层
程序是针对lwpolyline复合线的,如果要考虑circle可增加相应的circle转lwpolyline代码。
另外让互相重叠的几何图形个自形成独立的线框可以参考
“[讨论]征求轮廓线的lisp思路”一贴里的“边界轮廓线”程序!
发表于 2013-7-17 13:26:22 | 显示全部楼层
下载来,学习一下,里面有对我有益的东东。
发表于 2014-1-23 09:24:57 | 显示全部楼层
可惜了..如果可以批量就好了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-9-26 04:48 , Processed in 0.150333 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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