工具箱相关
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

咪咪 dgx1.lsp 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. (defun c:zh();转换新线形
  2. (prompt "请选择线: ")
  3. (setq object (entsel))
  4. (SETQ SSS (ssget "x" '((-4 . "<OR")
  5. (0 . "LWPOLYLINE")
  6. (0 . "POLYLINE")
  7. (-4 . "OR>"))
  8. ))
  9. (setq i 0)
  10. (if sss
  11. (while (< i (sslength sss))
  12. (setq OBJ (ssname sss i))
  13. (huan2)
  14. (setq i (+ i 1))
  15. ) ;WHILE
  16. ) ;IF SSS
  17. (setq b (itoa i) )
  18. (setq b1 (strcat "图中共检查修改旧line线划有:" b "条" ) )
  19. )
  20. (defun huan2()
  21. (setvar "CMDECHO" 0)
  22. (command"osnap" "off")
  23. (setq obj_38 nil)
  24. (setq obj_b(entget obj '("SHANXI" "SOUTH")))
  25. (setq obj_la (cdr(assoc 8 obj_b)))
  26. (setq obj_lt (cdr(assoc 6 obj_b)))
  27. (setq obj_color (cdr(assoc 62 obj_b)))
  28. (setq obj_70 (cdr(assoc 70 obj_b)))
  29. (setq obj_40 (cdr(assoc 40 obj_b)))
  30. (setq obj_38 (cdr(assoc 38 obj_b)))
  31. (if(= obj_38 nil)
  32. (setq obj_38 (nth 2 (cdr(assoc 10 obj_b))))
  33. )
  34. (setq obj_xdata (assoc -3 obj_b) )
  35. (command "layer" "S" obj_la "")
  36. (setq obj_b (qd_b1 obj) )
  37. (setq nnn(length obj_b))
  38. (setq j (- nnn 1))
  39. (if(or(= obj_70 5)(= obj_70 133)) (setq nnn (- nnn 1)))
  40. (setq p0(nth j obj_b))
  41. (command "pline")
  42. (repeat nnn
  43. (setq p1(nth j obj_b))
  44. (command p1)
  45. (setq j (- j 1))
  46. )
  47. (if( /= (/ obj_70 2) (/ obj_70 2.0) )
  48. (command p0))
  49. (command)
  50. (command"erase" obj "")
  51. (if (/= obj_lt nil)(command"change" (entlast) "" "p" "lt" obj_lt "") )
  52. (if (/= obj_color nil) (command"change" (entlast) "" "p" "c" obj_color "") )
  53. (if (/= obj_40 nil) (command"pedit" (entlast) "w" obj_40 "") )
  54. (if (/= obj_38 nil) (command"change" (entlast) "" "p" "e" obj_38 "") )
  55. (setq object (entget (entlast)))
  56. (if (/= obj_xdata nil)(progn
  57. (setq xdata (list obj_xdata))
  58. (setq nent (append object xdata))
  59. (entmod nent)
  60. ))
  61. (setq object (entlast) )
  62. )
  63. (defun huan3()
  64. (setvar "CMDECHO" 0)
  65. (command"osnap" "off")
  66. (setq obj_38 nil)
  67. (setq obj_b(entget obj '("SHANXI" "SOUTH")))
  68. (setq obj_la (cdr(assoc 8 obj_b)))
  69. (setq obj_lt (cdr(assoc 6 obj_b)))
  70. (setq obj_color (cdr(assoc 62 obj_b)))
  71. (setq obj_70 (cdr(assoc 70 obj_b)))
  72. (setq obj_40 (cdr(assoc 40 obj_b)))
  73. (setq obj_38 (cdr(assoc 38 obj_b)))
  74. (if(= obj_38 nil)
  75. (setq obj_38 (nth 2 (cdr(assoc 10 obj_b))))
  76. )
  77. (setq obj_xdata (assoc -3 obj_b) )
  78. (command "layer" "S" obj_la "")
  79. (setq obj_b (qd_b1 obj) )
  80. (setq nnn(length obj_b))
  81. (setq j 0)
  82. (if(or(= obj_70 5)(= obj_70 133)) (setq nnn (- nnn 1)))
  83. (setq p0(nth j obj_b))
  84. (command "pline")
  85. (repeat nnn
  86. (setq p1(nth j obj_b))
  87. (command p1)
  88. (setq j (+ j 1))
  89. )
  90. (if( /= (/ obj_70 2) (/ obj_70 2.0) )
  91. (command p0))
  92. (command)
  93. (command"erase" obj "")
  94. (if (/= obj_lt nil)(command"change" (entlast) "" "p" "lt" obj_lt "") )
  95. (if (/= obj_color nil) (command"change" (entlast) "" "p" "c" obj_color "") )
  96. (if (/= obj_40 nil) (command"pedit" (entlast) "w" obj_40 "") )
  97. (if (/= obj_38 nil) (command"change" (entlast) "" "p" "e" obj_38 "") )
  98. (setq object (entget (entlast)))
  99. (if (/= obj_xdata nil)(progn
  100. (setq xdata (list obj_xdata))
  101. (setq nent (append object xdata))
  102. (entmod nent)
  103. ))
  104. (setq object (entlast) )
  105. )
  106. (defun qd_b1(obj_1971); 获取新旧线坐标
  107. (setq dxfb_1971(entget obj_1971))
  108. (setq obty_1971 (cdr (assoc 0 dxfb_1971)) )
  109. (SETQ DB_PL '())
  110. (Cond
  111. ((= obty_1971 "POLYLINE")
  112. (setq obj_1971 (entnext obj_1971))
  113. (setq dxfb_1971 (entget obj_1971))
  114. (setq po_1971 (cdr (assoc 10 dxfb_1971)))
  115. (SETQ DB_PL '())
  116. (while (/= (cdr (assoc 0 dxfb_1971)) "SEQEND")
  117. (setq po_1971(list (nth 0 po_1971) (nth 1 po_1971) (nth 2 po_1971)))
  118. (SETQ DB_PL(APPEND DB_PL (list po_1971)))
  119. (setq obj_1971 (entnext obj_1971))
  120. (setq dxfb_1971 (entget obj_1971))
  121. (while(= (cdr (assoc 70 dxfb_1971)) 16)
  122. (setq obj_1971 (entnext obj_1971))
  123. (setq dxfb_1971 (entget obj_1971))
  124. )
  125. (setq po_1971 (cdr (assoc 10 dxfb_1971)))
  126. )
  127. )
  128. ((= obty_1971 "LWPOLYLINE")
  129. (SETQ NNN(length dxfb_1971))
  130. (SETQ K 0)
  131. (SETQ DB_PL '())
  132. (REPEAT NNN
  133. (SETQ po_1971 (NTH K dxfb_1971))
  134. (if(= (car po_1971) 10)
  135. (setq DB_PL(append DB_PL (list (cdr po_1971))))
  136. )
  137. (SETQ K (+ K 1))
  138. )
  139. )
  140. ((= obty_1971 "LINE")
  141. (SETQ NNN(length dxfb_1971))
  142. (SETQ K 0)
  143. (SETQ DB_PL '())
  144. (REPEAT NNN
  145. (SETQ po_1971 (NTH K dxfb_1971))
  146. (if( or (= (car po_1971) 10)(= (car po_1971) 11))
  147. (setq DB_PL(append DB_PL (list (cdr po_1971))))
  148. )
  149. (SETQ K (+ K 1))
  150. )
  151. )
  152. )
  153. DB_PL
  154. )
  155. (defun c:1();等高线连接修改
  156. (command "osnap" "off")
  157. (prompt "选择实体的断点处")
  158. (setq obj1(entsel))
  159. (setq ob_pp (car (cdr obj1)))
  160. (setq ddx (cdr( assoc 0 (entget (car obj1)'("*"))) ))
  161. (setq obja (car obj1))
  162. (setq sxxx ( assoc -3(entget obja'("*"))) )
  163. (if (= ddx "POLYLINE" )
  164. (progn
  165. (command "tolwpoly" obj1 "")
  166. (setq obja nil)
  167. (setq obja (entlast))) )
  168. (SETQ OBJC OBJA) (setq obj_b(entget obja))
  169. (setq obj_la (cdr(assoc 8 obj_b))) (setq obj_lt (cdr(assoc 6 obj_b)))
  170. (setq wid (cdr(assoc 40 obj_b))) (setq w38 (cdr(assoc 38 obj_b)))
  171. (setq c70 (cdr(assoc 70 obj_b)))
  172. (if (= c70 129) (setq c70 1))
  173. (command"linetype" "s" obj_lt "") (command"layer" "s" obj_la "")
  174. (setq p1 (list (nth 0 ob_pp) (nth 1 ob_pp)))
  175. ; (command "pedit" obja "d" "x")
  176. (setq ssb (ssget "x" (LIST (cons 0 "polyline,lwpolyline")(cons 38 w38)(cons 8 obj_la))))
  177. (setq i 0) (if ssb (while (< i (sslength ssb)) (redraw (ssname ssb i) 3) (setq i (+ i 1)) ))
  178. (plin2a)
  179. (setq i 0) (if ssb (while (< i (sslength ssb)) (redraw (ssname ssb i) 4) (setq i (+ i 1)) ))
  180. (setq ssb nil)
  181. (setq vwi (getvar "VIEWSIZE"))
  182. (setq pzjl (/ vwi 50))
  183. (setq zbd nil) (setq zbd (qd_b1 object) )
  184. (setq pb1 (nth 0 zbd))
  185. (setq pb2 (nth (- (length zbd) 1) zbd))
  186. ''''''''''''
  187. (setq zbb nil) (setq zbb (qd_b1 obja) )
  188. (if (= c70 1) (setq zbb (append zbb (list (nth 0 zbb)))) )
  189. (if (equal (nth 0 zbb) (nth (- (length zbb) 1) zbb) 1) (setq c70 1))
  190. (setq p1 pb1) (setq i 1) (jdjs) (setq ds i)
  191. (setq jda (/ (* (angle (nth (- i 1) zbb) (nth i zbb)) 180) pi))
  192. (setq jdb (/ (* (angle (nth 0 zbd) (nth 1 zbd)) 180) pi))
  193. (setq jdc (- jda jdb))
  194. (if (< jdc 0) (setq jdc (- 0 jdc)))
  195. (if (> jdc 180) (setq jdc (- 360 jdc)))
  196. (setq xxfz 0)
  197. (if (> jdc 90) (progn (setq zbb (reverse zbb)) (setq ds (- (length zbb) ds)) (setq xxfz 1) ))
  198. (if (= c70 1) (progn
  199. (setq zbs '()) (setq i (- ds 1))
  200. (repeat (- (length zbb) ds) (setq zbs (append zbs (list (nth i zbb)))) (setq i (+ i 1)))
  201. (setq i 0)
  202. (repeat ds (setq zbs (append zbs (list (nth i zbb)))) (setq i (+ i 1)))
  203. (setq zbb zbs) (setq zbs nil) (setq ds 1)
  204. ))
  205. (setq zb '())
  206. (setq i 0) (repeat (- ds 1) (setq zb (append zb (list (nth i zbb)))) (setq i (+ 1 i)) )
  207. (entdel object) (setq i 0) (command "pline") (command (nth (- ds 1) zbb))
  208. (repeat (length zbd) (command (nth i zbd)) (setq i (+ i 1)) ) (command "")
  209. (setq object (entlast)) (setq zbd nil) (setq zbd (qd_b1 object) )
  210. (setq jdzb nil)
  211. (setq q1 (polar pb2 3.97 pzjl)) (setq q2 (polar pb2 0.83 pzjl))
  212. (setq ssa (ssget "c" q1 q2 (LIST (cons 0 "polyline,lwpolyline")(cons 38 w38)(cons 8 obj_la))))
  213. (if ssa (if (ssmemb object ssa) (setq ssa (ssdel object ssa)) ) )
  214. (if ssa (if (= (sslength ssa) 0) (setq ssa nil)))
  215. (if ssa
  216. (if (ssmemb obja ssa)
  217. (progn '''同一实体
  218. (setq p1 pb2) (setq i ds) (jdjs) (setq ds1 i)
  219. (entdel object) (setq i 0) (command "pline")
  220. (repeat (- (length zbd) 1) (command (nth i zbd)) (setq i (+ i 1)) )
  221. (command jdzb) (command (nth ds1 zbb))(command "")
  222. (setq object (entlast)) (setq zbd nil) (setq zbd (qd_b1 object) )
  223. )
  224. (progn '''不同实体
  225. (setq OBJb (ssname ssa 0))
  226. (setq zbb nil)
  227. (setq zbb (qd_b1 objb) )
  228. (setq p1 pb2) (setq i 1) (jdjs) (setq ds1 i)
  229. (setq jda (/ (* (angle (nth (- i 1) zbb) (nth i zbb)) 180) pi))
  230. (setq zbdl (- (length zbd) 1))
  231. (setq jdb (/ (* (angle (nth (- zbdl 1) zbd) (nth zbdl zbd)) 180) pi))
  232. (setq jdc (- jda jdb))
  233. (if (< jdc 0) (setq jdc (- 0 jdc)))
  234. (if (> jdc 180) (setq jdc (- 360 jdc)))
  235. (if (> jdc 90) (progn (setq zbb (reverse zbb)) (setq ds1 (- (length zbb) ds1) ) ))
  236. (entdel object) (setq i 0) (command "pline")
  237. (repeat (- (length zbd) 1) (command (nth i zbd)) (setq i (+ i 1)) )
  238. (command jdzb) (command (nth ds1 zbb))(command "")
  239. (setq object (entlast)) (setq zbd nil) (setq zbd (qd_b1 object) )
  240. (entdel objb)
  241. )
  242. )
  243. )
  244. (command"pedit" object "s" "") (setq obj object)(huan3)
  245. (setq obj object) (cd1) (setq object (entlast))
  246. (setq zba nil) (setq zba (qd_b1 object) )
  247. (setq i 1) (repeat (- (length zba) 1) (setq zb (append zb (list (nth i zba)))) (setq i (+ 1 i)) )
  248. (if jdzb (progn
  249. (setq i (+ ds1 1))
  250. (repeat (- (- (length zbb) ds1) 1) (setq zb (append zb (list (nth i zbb)))) (setq i (+ 1 i)) )
  251. ))
  252. (if (= xxfz 1) (setq zb (reverse zb)) )
  253. (setq i 0) (command "pline")
  254. (repeat (length zb) (command (nth i zb)) (setq i (+ i 1)) )
  255. (if (= c70 1) (command "c")(command ""))
  256. (if (/= wid nil) (command"pedit" (entlast) "w" wid "") )
  257. (if (/= w38 nil) (command"change" (entlast) "" "p" "e" w38 "") )
  258. (COMMAND "_matchprop" OBJ1 (entlast) "")
  259. (if (/= sxxx nil)
  260. (setq dww (entmod (append (entget (entlast)) (list sxxx))) ) )
  261. (command"linetype" "s" Continuous "") (command"layer" "s" 0 "")
  262. (command "redraw")
  263. (ENTDEL OBJECT) (ENTDEL OBJC )
  264. )
  265. (defun cd1()
  266. (setq obj_40 nil)
  267. (setq obj_lt nil)
  268. (setq obj_color nil)
  269. (setq obj_b(entget obj ))
  270. (setq obj_la (cdr(assoc 8 obj_b)))
  271. (setq obj_lt (cdr(assoc 6 obj_b)))
  272. (setq obj_color (cdr(assoc 62 obj_b)))
  273. (setq obj_70 (cdr(assoc 70 obj_b)))
  274. (setq obj_40 (cdr(assoc 40 obj_b)))
  275. (setq obj_xdata (assoc -3 obj_b) )
  276. (setq DB_zb (qd_b1 obj) )
  277. (setq nnn(length db_zb))
  278. (if(or(= obj_70 5)(= obj_70 133)) (setq nnn (- nnn 1)))
  279. (setq p0(nth 0 db_zb))
  280. (setq p2 p0)
  281. (command "osnap" "off")
  282. (command "pline" p0 "w" 0 0)
  283. (setq j 1)
  284. (setq jdd 0)
  285. (repeat (- nnn 2)
  286. (setq p1(nth j db_zb))
  287. (setq p3(nth (+ j 1) db_zb))
  288. (setq jda (angle p2 p1))
  289. (setq jdb (angle p2 p3))
  290. (setq jdc (abs (- jda jdb)))
  291. (if (> jdc pi) (setq jdc (- (* 2 pi) jdc)))
  292. (if (or (> (distance p1 p2) 4) (> (+ jdd jdc) 0.05))
  293. (progn
  294. (command p1)
  295. (setq jdd 0)
  296. (setq p2 p1)
  297. )
  298. (setq jdd (+ jdd jdc))
  299. )
  300. (setq j (+ j 1))
  301. )
  302. (setq p1 (nth (- nnn 1) db_zb))
  303. (command p1)
  304. (if( /= (/ obj_70 2) (/ obj_70 2.0) ) (command p0))
  305. (command)
  306. (command"erase" obj "")
  307. (setq object (entget (entlast)))
  308. (if obj_la
  309. (setq object (subst (cons 8 obj_la) (assoc 8 object) object))
  310. )
  311. (if obj_lt
  312. (setq object (subst (cons 6 obj_lt) (assoc 6 object) object))
  313. )
  314. (if obj_color
  315. (setq object (subst (cons 62 obj_color) (assoc 62 object) object))
  316. )
  317. (entmod object)
  318. (if (/= obj_xdata nil)(progn
  319. (setq xdata (list obj_xdata))
  320. (setq nent (append object xdata))
  321. (entmod nent)
  322. ))
  323. (if obj_40 (progn
  324. (command "pedit" (entlast) "w" obj_40 "x")
  325. ))
  326. )
  327. (defun plin2a()
  328. (command"pline" "near" p1 "w" wid wid)
  329. (setq i 1)
  330. (while (/= p1 nil)
  331. (initget 128)
  332. (setq p1 (getpoint p1 "\n/Undo退回/Point选择新点: "))
  333. (if (= 'STR (type p1))
  334. (progn
  335. (setq p1 (strcase p1))
  336. (if (= p1 "U")
  337. (progn
  338. (if (> i 1) (setq i (- i 1)))
  339. (command p1)(setq p1 p2)
  340. );progn
  341. )
  342. ) ;progn
  343. (progn
  344. (if (/= p1 nil)
  345. (setq p2 p1)
  346. )
  347. (command p1) (print p1)
  348. (setq i (+ i 1))
  349. ) ;progn
  350. ) ;if
  351. );while
  352. (setq object (entlast))
  353. )
  354. (defun jdjs()
  355. (setq jdzb nil)
  356. (setq q1 (nth (- i 1) zbb))
  357. (while (and (= jdzb nil) (< i (length zbb)))
  358. (setq q2 q1)
  359. (setq q1 (nth i zbb))
  360. (setq jd (angle q2 q1))
  361. (setq p2 (polar p1 (+ jd (/ pi 2)) pzjl)) (setq p3 (polar p1 (- jd (/ pi 2)) pzjl))
  362. (setq jdzb (inters q1 q2 p2 p3))
  363. (setq i (+ i 1))
  364. )
  365. (setq i (- i 1))
  366. )