明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 865|回复: 1

一对文字加外围方框 73哥函数

[复制链接]
发表于 2015-9-14 21:58 | 显示全部楼层 |阅读模式
本帖最后由 树櫴希德 于 2015-9-14 22:05 编辑
  1. (defun get_inpoint (blockname)
  2.   (setq in_point(cdr (assoc 10 (entget blockname))))
  3.   in_point
  4. )
  5. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6. (defun get_inpointname (blockname)
  7.   (setq in_point(cdr(car(entget blockname))))
  8.   in_point
  9. )

  10. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  11. (defun testlsp(lst / a b d l)
  12.   (setq lst(vl-sort lst'(lambda(x y)(and(<(car (get_inpoint x))(car (get_inpoint y)))(<(cadr (get_inpoint x))(cadr (get_inpoint y))))))
  13. d(distance(get_inpoint(car lst))(get_inpoint(cadr lst))))
  14.   (while lst
  15.     (if(setq a(car lst)
  16.      b(vl-remove-if'(lambda(x)(>(distance (get_inpoint x) ( get_inpoint a))d))(cdr lst)))
  17.       (setq b(cons a b)
  18.     l(cons b l)
  19.     lst(repeat(length b)
  20. (setq a(car b)
  21.        b(cdr b)
  22.        lst(vl-remove a lst))))
  23.       (setq lst(cdr lst))))
  24.   l)
  25. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  26. (defun testlsp11(lst / a b d l)
  27.   (setq lst(vl-sort lst'(lambda(x y)(and(<(car (get_inpoint x))(car (get_inpoint y)))(<(cadr (get_inpoint x))(cadr (get_inpoint y))))))
  28. d(distance(get_inpoint(car lst))(get_inpoint(cadr lst))))
  29.   (while lst
  30.     (if(setq a(car lst)
  31.      b(vl-remove-if'(lambda(x)(>(distance (get_inpoint x) ( get_inpoint a))d))(cdr lst)))
  32.       (setq l(cons(cons a b)l)
  33.     lst(vl-remove-if'(lambda(x)(member x b))lst))
  34.       (setq lst(cdr lst))))
  35.   l)

  36. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  37. (defun c:wzjfk ( / ss i lst e insert_name ptlst biao1 ii ptt ptt1)
  38. (setq ss (ssget '((0 . "text")))   )

  39. (setq i 0)
  40. (setq lst '())
  41. (repeat (sslength ss)
  42. (setq insert_name (ssname ss i))
  43. (setq e(get_inpointname insert_name))
  44.   (setq lst (append lst (list e)))
  45. (setq i (1+ i))


  46.   )

  47. ;(setq dist (distance (getpoint "\n请选择起点") (getpoint "\n请选择终点")  ))

  48. ;(setq ptlst (vl-sort lst
  49.                    ;以下根据坐标差对表排序
  50.    ;'(lambda (e1 e2)
  51.          ; (and   (< (car (get_inpoint e1)) (car (get_inpoint e2)) )
  52.          ; (< (cadr (get_inpoint e1)) (cadr (get_inpoint e2)) ) (= (distance (get_inpoint e1) (get_inpoint e2) ) ) )
  53.        ; )   )    )

  54. (setq ptlst(testlsp lst))

  55. (setq biao '())
  56. (setq ii 0)
  57. (repeat (/ (length ptlst) 2)

  58. (setq lst2 (append (list(nth ii ptlst))  (list(nth (1+ ii) ptlst) ) ) )

  59. (setq biao (append (list lst2)  biao))
  60. (setq ii (+ ii 2))
  61.   
  62.   )

  63. (mapcar  '(lambda(x)
  64. (foreach n x

  65. (if (< (cadr(get_inpoint (car n)))  (cadr(get_inpoint (cadr n)))
  66.           )
  67. (progn  (setq ptt (mapcar '+  (get_inpoint (car n)) (car(textbox (entget(car n))) )  )  )
  68.   (setq ptt1 (mapcar '+  (get_inpoint (cadr n)) (cadr(textbox (entget(cadr n))) )  )  )

  69. (command "rectangle" ptt ptt1)

  70.   );;;;;;;;;;;;;;;;;;;;;;
  71. (if (> (cadr(get_inpoint (car n)))  (cadr(get_inpoint (cadr n)))          )
  72. (progn  (setq ptt (mapcar '+  (get_inpoint (cadr n)) (car(textbox (entget(cadr n))) )  )  )
  73.   (setq ptt1 (mapcar '+  (get_inpoint (car n)) (cadr(textbox (entget(car n))) )  )  )

  74. (command "rectangle" ptt ptt1)

  75.   )
  76.   )
  77.   ;;;;;;;;;;;;;;;;;;;;;;;

  78.   )
  79. )
  80.   )
  81.   biao)
  82. )

本帖子中包含更多资源

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

x

评分

参与人数 3明经币 +3 金钱 +30 收起 理由
yfy2003 + 1 + 30
USER2128 + 1 赞一个!
tryhi + 1 赞一个!

查看全部评分

发表于 2015-9-15 10:21 | 显示全部楼层
谢谢楼主分享好程序
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-4-26 23:52 , Processed in 0.173200 second(s), 29 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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