Lisp sắp xếp các Text được chọn trong một vùng ra một bảng giá trị?
em chịu thôi hàm này khó em nhờ quá bác ráp zô lisp này giùm em với sort chỗ các polyline được chọn biến (dt) ấy
(defun c:yeah ( / dt dt1 dt2 rec1 rec2 pt ss)
(if (not sc3) (setq sc3 2))
(setq sc1 (getreal (strcat "\nChi\U+1EC1u cao Text <")))
(if (not sc1) (setq sc1 sc3) (setq sc3 sc1))
(setq sc9 (cdr (assoc 1 (entget (car (entsel "\nChon Text Ly Trinh : "))))))
(setq dt (ssget '((0 . "LWPOLYLINE"))))
(setq sdt (sslength dt)
K SDT
i 0)
(while
(setq dt1 (ssname dt i)
dt2 (ssname dt (1+ i))
i (1+ i)
K (- K 1)
rec1 (acet-geom-vertex-list dt1)
rec2 (acet-geom-vertex-list dt2)
pt (nth 0 rec1)
)
(if (and (< (car (nth 0 rec1)) (car (nth 2 rec1))) (< (car (nth 0 rec2)) (car (nth 2 rec2))))
(setq ss (append rec1 (reverse rec2) (list pt))))
(if (and (> (car (nth 0 rec1)) (car (nth 2 rec1))) (> (car (nth 0 rec2)) (car (nth 2 rec2))))
(setq ss (append rec1 (reverse rec2) (list pt))))
(if (and (< (car (nth 0 rec1)) (car (nth 2 rec1))) (> (car (nth 0 rec2)) (car (nth 2 rec2))))
(setq ss (append rec1 rec2 (list pt))))
(if (and (> (car (nth 0 rec1)) (car (nth 2 rec1))) (< (car (nth 0 rec2)) (car (nth 2 rec2))))
(setq ss (append rec1 rec2 (list pt))))
(acet-pline-make (list ss))
(command "area" "o" (entlast))
(setq dientich (getvar "area"))
(setq s (strcat (rtos dientich 2 2)))
(command "INSERT" "DIENTICHL" (nth 1 rec2) SC1 SC1 0 sc9 K S)
)
(princ "\nThanks for Using - Ho\U+00E0ng Long Auto Lisp
Phone:0933118500
Mail:[email protected]")
(PRINC))
Tệp .lsp gốc không còn trên máy chủ. Hãy chép mã nguồn bên dưới (lấy từ bài viết gốc) vào một tệp văn bản, lưu với đuôi .lsp.
Cách dùng
- Chép mã nguồn, lưu thành tệp 396736_yeah.lsp.
- Trong AutoCAD gõ lệnh APPLOAD, chọn tệp vừa tải rồi bấm Load. Cũng có thể kéo thả tệp .lsp vào cửa sổ bản vẽ.
- Gõ lệnh YEAH để chạy lisp.
Mã nguồn 396736_yeah.lsp (trích từ bài viết gốc)
(defun c:yeah ( / dt dt1 dt2 rec1 rec2 pt ss)
(if (not sc3) (setq sc3 2))
(setq sc1 (getreal (strcat "\nChi\U+1EC1u cao Text <")))
(if (not sc1) (setq sc1 sc3) (setq sc3 sc1))
(setq sc9 (cdr (assoc 1 (entget (car (entsel "\nChon Text Ly Trinh : "))))))
(setq dt (ssget '((0 . "LWPOLYLINE"))))
(setq sdt (sslength dt)
K SDT
i 0)
(while
(setq dt1 (ssname dt i)
dt2 (ssname dt (1+ i))
i (1+ i)
K (- K 1)
rec1 (acet-geom-vertex-list dt1)
rec2 (acet-geom-vertex-list dt2)
pt (nth 0 rec1)
)
(if (and (< (car (nth 0 rec1)) (car (nth 2 rec1))) (< (car (nth 0 rec2)) (car (nth 2 rec2))))
(setq ss (append rec1 (reverse rec2) (list pt))))
(if (and (> (car (nth 0 rec1)) (car (nth 2 rec1))) (> (car (nth 0 rec2)) (car (nth 2 rec2))))
(setq ss (append rec1 (reverse rec2) (list pt))))
(if (and (< (car (nth 0 rec1)) (car (nth 2 rec1))) (> (car (nth 0 rec2)) (car (nth 2 rec2))))
(setq ss (append rec1 rec2 (list pt))))
(if (and (> (car (nth 0 rec1)) (car (nth 2 rec1))) (< (car (nth 0 rec2)) (car (nth 2 rec2))))
(setq ss (append rec1 rec2 (list pt))))
(acet-pline-make (list ss))
(command "area" "o" (entlast))
(setq dientich (getvar "area"))
(setq s (strcat (rtos dientich 2 2)))
(command "INSERT" "DIENTICHL" (nth 1 rec2) SC1 SC1 0 sc9 K S)
)
(princ "\nThanks for Using - Ho\U+00E0ng Long Auto Lisp
Phone:0933118500
Mail:[email protected]")
(PRINC))Thảo luận gốc
Lisp được chia sẻ trong chủ đề [Yêu cầu] Lisp sắp xếp các Text được chọn trong một vùng ra một bảng giá trị?. Xem đúng bài viết #396736 để đọc hướng dẫn và trao đổi thêm.