明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
12
返回列表 发新帖
楼主: bigboom

想取得所有(直接,间接)与指定线相交的线,但程序太慢

[复制链接]
发表于 2003-11-6 11:57:00 | 显示全部楼层
写了一下,你看看:

  1. (if (not olderr)
  2.   (setq olderr *error*)
  3. )

  4. (defun *error* (msg)
  5. (setq en (getvar "errno"))
  6. (setq errmsg (strcat "errno=" (itoa en) "\nError:" msg))
  7. (alert errmsg)
  8. (setq *error* olderr)
  9. )

  10. (defun getcolor()
  11.   (if (not c)
  12.     (setq c 1)
  13.     (progn
  14.       (if (< c 7)
  15.         (setq c (1+ c))
  16.         (setq c 1)
  17.       )
  18.     )
  19.   )
  20. )

  21. (defun setcolor(sname color / sinf)
  22.   (setq sinf (entget sname))
  23.   (if (assoc 62 sinf)
  24.     (setq sinf (subst (cons 62 color) (assoc 62 sinf) sinf))
  25.     (setq sinf (append sinf (list (cons 62 color))))
  26.   )
  27.   (entmod sinf)
  28. )

  29. (defun getinterLine(entMother entLine / ent pt1 pt2 ss n i entList)
  30.   (ssadd entLine ssAll)
  31.   (setq ent (entget entLine))
  32.   (setq pt1 (cdr (assoc 10 ent)))
  33.   (setq pt2 (cdr (assoc 11 ent)))
  34.   (setq ss (ssget "f" (list pt1 pt2) '((0 . "LINE"))))
  35.   (if entMother (ssdel entMother ss))
  36.   (ssdel entLine ss)
  37.   (setq n (sslength ss))
  38.   (setq i 0)  
  39.   (while (< i n)
  40.     (setq entList (append entList (list (ssname ss i))))
  41.     (setq i (1+ i))
  42.   )
  43.   (setq ss nil)
  44.   (setq i 0)
  45.   (repeat n
  46.     (if (not (ssmemb (setq ent (nth i entList)) ssAll))
  47.       (getinterLine entLine ent)
  48.     )
  49.     (setq i (1+ i))
  50.   )
  51.   ssAll
  52. )

  53. (defun c:main( / ent i)  
  54.   (setq ent (car (entsel "Select the Line...")))
  55.   (if (/= (cdr (assoc 0 (entget ent))) "LINE")
  56.     (exit)
  57.   )
  58.   (setq ssall (ssadd))
  59.   (Getinterline nil ent)
  60.   (setq i 0)
  61.   (setq c (getcolor))
  62.   (setcolor ent c)
  63.   (repeat (sslength ssAll)
  64.     (setcolor (ssname ssAll i) c)
  65.     (setq i (1+ i))
  66.   )
  67.   (setq ssAll nil)
  68.   (setq *error* olderr)
  69.   (princ)
  70. )
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-10-2 12:18 , Processed in 0.136077 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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