找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1848|回复: 0

[他山之石] Elevate Blocks using Nearest Elevation Text

[复制链接]

已领礼包: 1268个

财富等级: 财源广进

发表于 2013-10-10 17:59:21 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

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

×
  1. (defun c:elBlk()
  2. (command "_.Undo" "M")
  3. (setq sel_rad 2)
  4. (setq how_far 0.5)
  5. (princ "\nSelect blocks to elevate :")
  6. (setq selset(ssget (list (Cons 0 "Insert"))))
  7. (princ "\n***Note***:Elevations need to be in 'Elev' Layer :")
  8. (if (= selset nil)
  9.   (princ "\nYou have not selected text or block!")
  10.   (progn
  11.    (setq len(sslength selset))
  12.    (setq cou 0)
  13.    (princ "\nElevating Blocks .. ")
  14.    (repeat len
  15.     (setq ent(Ssname selset cou))
  16.     (setq cou(1+ cou))
  17.     (setq entl(entget ent))
  18.     (setq insPt(cdr (assoc 10 entl)))
  19.     (setq curPtVal(TextAtPoint (list (car inspt) (cadr inspt)) "ELEV" sel_rad how_far T))
  20.     (if (= curPtVal nil)
  21.      (progn
  22.       (princ (strcat "\nNo Elevation Text Found with in 0.5 Radius in 'Elev' Layer at : " (rtos (car insPt) 2 3) "," (rtos (cadr inspt) 2 3)))
  23.      )
  24.      (progn
  25.       (setq newIns(list (car insPt) (cadr inspt) curPtVal))
  26.       (setq entl(subst (cons 10 newIns) (assoc 10 entl) entl))
  27.       (entmod entl)
  28.       (entupd ent)
  29.      )
  30.     )
  31.    )
  32.   )
  33. )
  34. (princ)
  35. )
  36. (princ "\nType \"ElBlk\" at the command Prompt:") (princ)
  37. (defun TextAtPoint(verPt txLay cirValue distValue cirT)
  38. (setq TAselent(SelTextsScanR verPt cirValue txLay))
  39. (setq neaDist distValue)
  40. (if (= TAselent nil)
  41.   (progn
  42.    (setq blnError T)
  43.    (if cirT
  44.     (progn
  45.      (command "._Circle" verPt "2")
  46.      (cpl (entlast) "0")
  47.     )
  48.    )
  49.    (setq VertexValue nil)
  50.   )
  51.   (progn
  52.    (setq VertexValue nil)
  53.    (setq tentcntr 0)
  54.    (repeat (sslength TAselent)
  55.     (setq TAcurEnt(ssname TAselent tentcntr))
  56.     (setq TAcurIns(ExIns TAcurEnt))
  57.     (if (<= (distance TAcurIns verPt) neaDist)
  58.      (progn
  59.       (setq VertexValue(atof (cdr (assoc 1 (entget TAcurEnt)))))
  60.       (setq neaDist(distance TAcurIns verPt))
  61.      )
  62.     )
  63.     (setq tentcntr(1+ tentcntr))
  64.    )
  65.   )
  66. )
  67. (setq return VertexValue)
  68. )
  69. ;Function to Select Text with in given Scanning Radius and Point
  70. (defun SelTextsScanR(intC SRadius inLay)
  71. (setq cpPt1(polar intC 0 SRadius))
  72. (setq cpPt2(polar intC (* 1 (/ pi 8)) SRadius))
  73. (setq cpPt3(polar intC (* 2 (/ pi 8)) SRadius))
  74. (setq cpPt4(polar intC (* 3 (/ pi 8)) SRadius))
  75. (setq cpPt5(polar intC (* 4 (/ pi 8)) SRadius))
  76. (setq cpPt6(polar intC (* 5 (/ pi 8)) SRadius))
  77. (setq cpPt7(polar intC (* 6 (/ pi 8)) SRadius))
  78. (setq cpPt8(polar intC (* 7 (/ pi 8)) SRadius))
  79. (setq cpPt9(polar intC (* 8 (/ pi 8)) SRadius))
  80. (setq cpPt10(polar intC (* 9 (/ pi 8)) SRadius))
  81. (setq cpPt11(polar intC (* 10 (/ pi 8)) SRadius))
  82. (setq cpPt12(polar intC (* 11 (/ pi 8)) SRadius))
  83. (setq cpPt13(polar intC (* 12 (/ pi 8)) SRadius))
  84. (setq cpPt14(polar intC (* 13 (/ pi 8)) SRadius))
  85. (setq cpPt15(polar intC (* 14 (/ pi 8)) SRadius))
  86. (setq cpPt16(polar intC (* 15 (/ pi 8)) SRadius))
  87. (setq elevSet(ssget "CP" (list cpPt1 cpPt2 cpPt3 cpPt4 cpPt5 cpPt6 cpPt7 cpPt8 cpPt9 cpPt10 cpPt11 cpPt12 cpPt13 cpPt14 cpPt15 cpPt16 cpPt1)))
  88. (setq return(ssget "P" (list (Cons 0 "Text") (Cons 8 inLay))))
  89. )
  90. ;Function to Change the Layer of Specified Entity to Specified Layer
  91. (defun CPL(ent entlay)
  92. (command "._change" ent "" "p" "layer" entlay "")
  93. )
  94. ;Function to Extract the insertion point of the Text
  95. (defun ExIns(TEnt)
  96. (setq TDetails(entget Tent))
  97. (setq check(assoc 11 TDetails))
  98. (if (= check nil)
  99.   (setq Check(cdr (assoc 10 TDetails)))
  100.   (progn
  101.    (setq check(cdr check))
  102.    (if (and (= (car check) 0) (= (cadr check) 0))
  103.     (setq Check(cdr (assoc 10 TDetails)))
  104.     (setq Check(cdr (assoc 11 TDetails)))
  105.    )
  106.   )
  107. )
  108. (setq Check(list (car Check) (cadr Check)))
  109. (setq return check)
  110. )
  111. (princ)

原文地址: http://www.surveydrawing.net/free-lisp-elevate-block.html
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-11-15 11:30 , Processed in 0.330687 second(s), 33 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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