Jump to content

lisp pick tọa độ từ hệ tọa độ cad sang vn2000

Trước hết nhoc xin chân thành đa tạ pac Bình đã dìu dắt hướng dẫn thằng em nì ^^ tới tới .....:D, sau 1 đêm mày mò , hút hết 2 gói thuốc >> ngu người, cuối cùng nhoc cũng đã hoàn tất đc những gì pac Bình chỉ dạy. Cái nỳ để pac chắc mất 2 phút là xong, còn nhoc >> ko đếm nỗi >"<. Không dài dòng vô thẳng, pac Bình và bạn gaibo vô xem thử hàng nhé, trước khi xem nhoc xin đc show quá trình nhoc lên thiên đường, ah thật ra lên chưa tới đâu, đụng nóc mây thui, mà vậy là zui rùi ^^
Tấm đầu tiên, cái bầu này sắp sinh rùi bự lắm ^^
https://www.cadviet.com/upfiles/3/104473_11111111111.jpg

Tấm thứ 2, rừng già amazon nhé :)
https://www.cadviet.com/upfiles/3/104473_22222222222.jpg

Tấm cuối cùng, mẹ tròn con vuông, cây cối đã đc tỉa gọn gàng :D :D :D
https://www.cadviet.com/upfiles/3/104473_333333333333.jpg
Sau cùng là file lsp tạm gọi là chấp nhận đc ^^

(defun C:tff (/ tencoc check-nova lytrinh accept nova baoloi node table style DCL_CDN DCL_ID FILE_DCL HTXT TEMP_CDN TSN
B1 B2 BB1 BB2 BBL BBR BK BL BLI BR BRI BT1 BT2 BTL BTR BTT BTX BTY EB1 EB2 EBK
PT1 PTE PTITLE PTL PTX PTY TD0 X Y SSNODE STTBTD TB ANG COL DEL DIX DIY EGPL EPL GR H K LST-TS N NAME
EVK OV SSC VBL VBR VK VLI VRI VTL VTR WH)
(command "style" "VnArial NarrowH" ".VnArial NarrowH" "" "" "" "" "")
(command "layer" "m" "QKHS" "c" "6" "" "")
(command "undo" "be")
(setvar "cmdecho" 0)

(command "undo" "begin")
(vl-load-com)
;======================= Defun ==========================
(defun rotate-text ( en ang / p1 p2 a e1)
(setq p1 (acet-geom-textbox (setq e1 (entget en)) 0)
p1 (acet-geom-midpoint (car p1) (caddr p1))
e1 (subst (cons 11 p1) (assoc 11 e1) e1)
a (cdr (assoc 50 e1))
a (+ ang a)
e1 (subst (cons 50 a) (assoc 50 e1) e1)
e1 (subst (cons 72 1) (assoc 72 e1) e1)
e1 (subst (cons 73 2) (assoc 73 e1) e1)
);setq
(entmod e1)
(entupd EN))
(defun DXF (code en) (cdr (assoc code (entget en))))
(defun angle-d2r (ANGD) (if ANGD (/ (* pi ANGD) 180) nil))
(defun angle-r2d (ANGR) (if ANGR (/ (* 180 ANGR) pi) nil))
(defun grnode (point radius color ang node fomp hightlight / ANGi PT0 PT1 PTg COL)
(if fomp
(setq ANGi 0)
(setq ANGi (* 0.5 (angle-d2r ang))))
(if (= color 0) (setq COL 10) (setq COL color))
(setq PT0 (polar point ANGi radius) PTg PT0)
(if node (grdraw point PT0 color hightlight))
(while (<= ANGi (* 2 Pi))
(setq ANGi (+ ANGi (angle-d2r ang))
PT1 (polar point ANGi radius))
(if (= color 0) (setq COL (1+ COL)))
(if node (grdraw point PT0 COL hightlight) (grdraw PT0 PT1 COL hightlight))
(setq PT0 PT1)
);while
(if (not node) (grdraw PT0 PTg COL hightlight))
);end grnode
(defun tencoc (EN) (if (check-nova EN) (cdr (nth 7 (car(cdr (assoc -3 (entget EN '("*"))))))) (prompt "Doi tuong chon khong co du lieu tuyen")))
(defun check-nova (EN) (if (= (car(car(cdr (assoc -3 (entget EN '("*")))))) "TDNW") T nil))
(defun lytrinh (EN) (if (check-nova EN) (rtos (cdr (nth 5 (car(cdr (assoc -3 (entget EN '("*"))))))) 2 2) (prompt "Doi tuong chon khong co du lieu tuyen")))
(defun accept ()
(setq TD-value (list (get_tile "node") (get_tile "table") (nth (fix (atof (get_tile "style"))) Lst-TS)
(get_tile "height") (get_tile "name") (get_tile "start") 0)) (done_dialog))
(defun nova ()
(setq TD-value (list (get_tile "node") (get_tile "table") (nth (fix (atof (get_tile "style"))) Lst-TS)
(get_tile "height") (get_tile "name") (get_tile "start") 1)) (done_dialog))
(defun node ()
(if (and (= (get_tile "table") "0") (= (get_tile "node") "0")) (set_tile "table" "1")))
(defun table ()
(if (and (= (get_tile "table") "0") (= (get_tile "node") "0")) (set_tile "node" "1")))
(defun style (/ htxt htxt0)
(setq htxt0 (get_tile "height"))
(if (/= (setq htxt (cdr (assoc 40 (tblsearch "style" (nth (fix (atof (get_tile "style"))) Lst-TS))))) 0)
(progn (set_tile "height" (rtos htxt 2 3)) (mode_tile "height" 1))
(progn (mode_tile "height" 0) (set_tile "height" htxt0))))
(defun baoloi (val key valkey)
(if (= "." (substr val 1 1)) (setq val (strcat "0" val)))
(if (not (or (= val "") (and (or (= (type (read val)) 'REAL) (= (type (read val)) 'INT)) (> (atof val) 0))))
(progn
(if (or (= key "height") (= key "start"))
(repeat 2
(set_tile "err" (strcat " "))
(ACET-SYS-SLEEP 70)
(set_tile "err" (strcat "Gia tri " valkey " phai la so thuc duong"))
(ACET-SYS-SLEEP 120))
(repeat 2
(set_tile "err" (strcat " "))
(ACET-SYS-SLEEP 70)
(set_tile "err" (strcat "Gia tri " valkey " phai la so nguyen duong"))
(ACET-SYS-SLEEP 120)))
(mode_tile key 2)
(mode_tile key 3)
);progn
(set_tile "err" (strcat "Statistical coordinates data record - \Toa do "))
);if
);end error
(if (not TD-value) (setq TD-value (list "1" "1" (getvar "textstyle") "2.00" "N" "1" 0)))
(setq DCL_CDn (list
"Coordinate : dialog { value = \"http://taybac.1talk.net - \<Thong ke Toa do>\"; key = \"err\";"
" : column { children_alignment = top;"
" : boxed_row { "
" : column {"
" : toggle { key = \"node\"; label = \"Chen diem\"; height = 1.4;}"
" : toggle { key = \"table\"; label = \"Chen bang\"; height = 2.5;}}"
" : column {"
" : popup_list { key = \"style\"; label = \"Text Style\"; edit_width = 10.1;}"
" : edit_box { key = \"height\"; label = \"Height Text\"; height = 1.1; edit_width = 11;}"
" : tile { label = \"-\"; alignment = centered;}} "
" : column {"
" : edit_box { key = \"name\"; label = \" Ten diem\"; height = 1.1; edit_width = 4;}"
" : edit_box { key = \"start\"; label = \" So bat dau\"; height = 1.1; edit_width = 4;}"
" : tile { label = \"-\"; alignment = centered;}} "
" } "
" : button { key = \"nova\"; label = \"Export Station coodinates from Road-Plan\";}"
" : row {"
" : button { key = \"cancel\"; label = \" Thoat \"; is_cancel = true;}"
" : button { key = \"accept\"; label = \" Bat dau \"; is_default = true;}}"
" }"
" }"
"helpTLuy : dialog { label = \"Help and Copyright\U+00A9 Information\";"
" : column {"
" : row { : list_box { key = \"helpList\"; edit_width = 95; width = 98; height = 25;}}"
" : row { : button { key = \"okayHelp\"; label = \"Okay\"; is_default = false; is_cancel = true;}}"
" }"
" }"
)
TEMP_CDn (vl-filename-mktemp "CDn.DCL")
FILE_DCL (open TEMP_CDn "W"))
(foreach LL DCL_CDn (write-line LL FILE_DCL))
(close FILE_DCL)
(setq DCL_ID (load_dialog TEMP_CDn))
(new_dialog "Coordinate" DCL_ID)
(set_tile "node" (nth 0 TD-value))
(set_tile "table" (nth 1 TD-value))
(set_tile "height" (nth 3 TD-value))
(if (/= (setq htxt (cdr (assoc 40 (tblsearch "style" (nth 2 TD-value))))) 0)
(progn (set_tile "height" (rtos htxt 2 2)) (mode_tile "height" 1)))
(set_tile "name" (nth 4 TD-value))
(set_tile "start" (nth 5 TD-value))
(start_list "style")
(setq Lst-TS (list (nth 2 TD-value) (cdr (assoc 2 (tblnext "Style" T)))))
(while (setq TSN (tblnext "Style"))
(if (and (/= (cdr (assoc 2 TSN)) (nth 2 TD-value)) (/= (cdr (assoc 2 TSN)) ""))
(setq Lst-TS (append Lst-TS (list (cdr (assoc 2 TSN))))))
);while
(mapcar 'add_list Lst-TS)
(end_list)
(action_tile "cancel" "(exit)")
(action_tile "accept" "(accept)")
(action_tile "nova" "(nova)")
(action_tile "node" "(node)")
(action_tile "table" "(table)")
(action_tile "style" "(style)")
(action_tile "height" "(baoloi (get_tile \"height\") \"height\" \"''Cao chu''\")")
(action_tile "start" "(baoloi (get_tile \"start\") \"start\" \"''STT''\")")
(start_dialog)
(unload_dialog DCL_ID)
(vl-file-delete TEMP_CDn)
(setq H (atof (nth 3 TD-value)))
(if (wcmatch (cdr (assoc 3 (tblsearch "style" (nth 2 TD-value)))) "*AVAN*,*ARIAL*,*BLACK*") (setq Wh (* 1.5 H)) (setq Wh 0))
(if (= (nth 6 TD-value) 0) (progn
(if (/= (nth 3 TD-value) "") (setq N (nth 3 TD-value)))
(command "UCS" "W")
(setvar "dimzin" 0)
(command "undo" "begin")
(if (= (nth 5 TD-value) "") (setq k 0) (setq k (- (atof (nth 5 TD-value)) 1)))
(if (= (nth 1 TD-value) "1") ; BEGIN TABLE
(progn (prompt "Chon diem dat bang toa do...")
(while
(if (= (car (setq GR (grread 't 15 0))) 5)
(progn
(if (or (not COL) (= 249 COL)) (setq COL 1) (setq COL (1+ COL)))
(redraw)
(setq BTR (cadr GR)
BTL (polar BTR 0 (* H -26))
BT1 (polar BTR 0 (* H -21))
BT2 (polar BTR 0 (* H -10.5))
BBR (polar BTR (* 0.5 pi) (* H -11))
BBL (polar BTL (* 0.5 pi) (* H -11))
BB1 (polar BT1 (* 0.5 pi) (* H -11))
BB2 (polar BT2 (* 0.5 pi) (* H -11))
BR (polar BTR (* 0.5 pi) (* H -2.4))
BL (polar BTL (* 0.5 pi) (* H -2.4))
OV (* H 0.3)
VTR (polar BTR (* 0.25 pi) OV)
VTL (polar BTL (* 0.75 pi) OV)
VBR (polar BR (* 1.75 pi) OV)
VBL (polar BL (* 1.25 pi) OV))
(grdraw BTL BTR COL 1)
(grdraw BTL BBL COL 1)
(grdraw BTR BBR COL 1)
(grdraw BT1 BB1 COL 1)
(grdraw BT2 BB2 COL 1)
(grdraw BR BL COL 1)
(repeat 3
(setq BR (polar BR (* 0.5 pi) (* H -2.0))
BL (polar BL (* 0.5 pi) (* H -2.0))
BB1 (polar BT1 (* 0.5 pi) (* H -2.4))
BB2 (polar BT2 (* 0.5 pi) (* H -2.4)))
(grdraw BR BL COL 1)) T)
(progn
(setq PTitle (list (- (car BTR) (* 13 H)) (+ (cadr BTR) (* 1.8 H)))
BTX (list (- (car BTR) (* 15.75 H)) (+ (cadr BTR) (* -1.2 H)))
BTY (list (- (car BTR) (* 5.25 H)) (+ (cadr BTR) (* -1.2 H)))
BTT (list (- (car BTR) (* 23.5 H)) (+ (cadr BTR) (* -1.2 H)))
BR (polar BTR (* 0.5 pi) (* H -2.4))
BL (polar BTL (* 0.5 pi) (* H -2.4)))
(setq VK (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(62 . 8) '(100 . "AcDbPolyline") '(90 . 4) '(70 . 1)
(cons 10 VBR) (cons 10 VTR) (cons 10 VTL) (cons 10 VBL))))
(setq BK (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 4) '(70 . 1)
(cons 10 BR) (cons 10 BTR) (cons 10 BTL) (cons 10 BL))))
(setq B1 (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 2)
(cons 10 BB1) (cons 10 BT1))))
(setq B2 (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 2)
(cons 10 BB2) (cons 10 BT2))))
(entmake (list '(0 . "TEXT") (cons 10 PTitle) (cons 11 PTitle) (cons 40 (* 1.2 H))
(cons 1 "%&#11;&#182;ng T&#228;a &#174;&#233; &#174;i&#211;m") (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
(entmake (list '(0 . "TEXT") (cons 10 BTT) (cons 11 BTT) (cons 40 (* 1 H))
(cons 1 "&#167;i&#211;m") (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
(entmake (list '(0 . "TEXT") (cons 10 BTX) (cons 11 BTX) (cons 40 (* 1 H))
(cons 1 "X") (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
(entmake (list '(0 . "TEXT") (cons 10 BTY) (cons 11 BTY) (cons 40 (* 1 H))
(cons 1 "Y") (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
(setq BTX (polar BTX (* -0.5 pi) (* 2.2 H))
BTY (polar BTY (* -0.5 pi) (* 2.2 H))
BTT (polar BTT (* -0.5 pi) (* 2.2 H)))
(prompt " OK Man!"))))));if END TABLE
(while
(progn
(initget 128 "u")
(setq TD0 (getpoint (strcat "\n Pick diem thu "(rtos (setq k (1+ k)) 2 0) " : ")))
(if (= TD0 "u") (vl-cmdf "undo" "Back") TD0))
(if (/= TD0 "u") (progn
(vl-cmdf "undo" "mark")
(princ TD0)
(setq X (rtos (car TD0) 2 3) Y (rtos (cadr TD0) 2 3))
(if (= (nth 1 TD-value) "1")
(progn ;put into table
(setq STTBTD (strcat (nth 4 TD-value) (rtos k 2 0)))
(entmake (list '(0 . "TEXT") (cons 10 BTT) (cons 11 BTT) (cons 40 (* 1 H))
(cons 1 STTBTD) (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
(entmake (list '(0 . "TEXT") (cons 10 BTX) (cons 11 BTX) (cons 40 (* 1 H))
(cons 1 X) (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
(entmake (list '(0 . "TEXT") (cons 10 BTY) (cons 11 BTY) (cons 40 (* 1 H))
(cons 1 Y) (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
(setq BTX (polar BTX (* -0.5 pi) (* 2 H))
BTY (polar BTY (* -0.5 pi) (* 2 H))
BTT (polar BTT (* -0.5 pi) (* 2 H)))
(entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 2) (cons 10 BR) (cons 10 BL)))
(setq EB1 (entget B1) EB1 (subst (cons 10 (setq BB1 (polar BB1 (* -0.5 pi) (* 2 H)))) (assoc 10 EB1) EB1))
(entmod EB1) (entupd B1)
(setq EB2 (entget B2) EB2 (subst (cons 10 (setq BB2 (polar BB2 (* -0.5 pi) (* 2 H)))) (assoc 10 EB2) EB2))
(entmod EB2) (entupd B2)
(setq EBK (entget BK)
BRi (polar BR (* -0.5 pi) (* 2 H))
BLi (polar BL (* -0.5 pi) (* 2 H))
EBK (reverse (subst (cons 10 BRi) (assoc 10 EBK) EBK))
EBK (reverse (subst (cons 10 BLi) (assoc 10 EBK) EBK))
BR Bri BL BLi)
(entmod EBK) (entupd BK)
(setq EVK (entget VK)
VRi (polar VBR (* -0.5 pi) (* 2 H))
VLi (polar VBL (* -0.5 pi) (* 2 H))
EVK (reverse (subst (cons 10 VRi) (assoc 10 EVK) EVK))
EVK (reverse (subst (cons 10 VLi) (assoc 10 EVK) EVK))
VBR Vri VBL VLi)
(entmod EVK) (entupd VK)
);progn
);if END put into table
(if (= (nth 0 TD-value) "1")
(progn
(setq SSnode (ssadd))
(setq PTX (polar TD0 0 (* H 0.7))
PTY (polar PTX (* pi -0.5) (* H 1.35)))
(entmake (list '(0 . "TEXT") (cons 10 PTX) (cons 11 PTX) (cons 40 H) (cons 1 (strcat "X:"X)) (cons 7 (nth 2 TD-value)) '(72 . 0) '(73 . 1)))
(setq TB (textbox (entget(entlast)))
DIX (distance (car TB) (cadr TB))
PTL (polar PTX 0 (+ DIX (* 0.12 H))))
(setq SSnode (ssadd (entlast) SSnode))
(entmake (list '(0 . "TEXT") (cons 10 PTY) (cons 40 H) (cons 1 (strcat "Y:"Y)) (cons 7 (nth 2 TD-value)) '(72 . 0)))
(setq TB (textbox (entget(entlast))))
(if (< DIX (setq DIY (distance (car TB) (cadr TB))))
(setq PTL (polar PTX 0 (+ DIY (* 0.12 H)))))
(setq SSnode (ssadd (entlast) SSnode))
(setq EPL (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline")
'(90 . 3) (cons 10 TD0) (cons 10 (polar TD0 0 (* 0.000000001 H))) (cons 10 PTL))))
(setq SSnode (ssadd EPL SSnode))
(if (/= (strcat (nth 4 TD-value) (nth 5 TD-value)) "")
(progn
(setq name (strcat (nth 4 TD-value) (rtos k 2 0)))
(entmake (list '(0 . "TEXT") (cons 10 PTL) (cons 11 (list (+ (car PTL) 0.65) (cadr PTL))) (cons 40 H)
(cons 1 name) (cons 7 (nth 2 TD-value)) '(72 . 0) '(73 . 2)))
(setq etext (entlast))
(setq len (abs (- (caar (textbox (list (assoc 1 (entget etext)) (assoc 40 (entget etext)) (assoc 50 (entget etext)))))
(caadr (textbox (list (assoc 1 (entget etext)) (assoc 40 (entget etext)) (assoc 50 (entget etext))))))))
(setq PTE (polar PTL 0 (/ len 1.7)))
(setq SSnode (ssadd (entlast) SSnode))
(entmake (list '(0 . "ELLIPSE") '(100 . "AcDbEntity") '(100 . "AcDbEllipse")
(cons 10 PTE) (cons 11 (list (/ len 1.7) 0 0)) (cons 40 0.75)))
(setq SSnode (ssadd (entlast) SSnode))
(entmake (list '(0 . "ELLIPSE") '(100 . "AcDbEntity") '(100 . "AcDbEllipse")
'(62 . 8) (cons 10 PTE) (cons 11 (list (/ len 1.8) 0 0)) (cons 40 0.75)))
(setq SSnode (ssadd (entlast) SSnode))))
(ACET-SS-REDRAW SSnode 2)
(if (not (setq PT1 (ACET-SS-DRAG-MOVE SSnode TD0 "" nil 0)))
(Setq PT1 TD0)
(setq del (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 3) (cons 10 TD0) (cons 10 PT1)))))
(vl-cmdf "move" SSnode "" TD0 PT1)
(ACET-SS-REDRAW SSnode 2)
(if (not (setq ANG (ACET-SS-DRAG-ROTATE SSnode PT1 "" nil 0)))
(if (< (* 0.5 pi) (angle PT1 (cadr (grread 't 15 0))) (* 1.5 pi)) (setq ANG pi) (setq ANG 0)))
(vl-cmdf "erase" del "")
(vl-cmdf "rotate" SSnode "" PT1 (rtos (angle-r2d ANG) 2 2))
(setq SSnode (acet-ss-to-list SSnode))
(if (< (* 0.5 pi) ANG (* 1.5 pi))
(foreach SSn SSnode (if (= (DXF 0 SSn) "TEXT") (rotate-text SSn pi))))
(setq EgPL (entget EPL) EgPL (subst (cons 10 TD0) (assoc 10 EgPL) EgPL))
(entmod EgPL) (entupd EPL)
);progn
(progn
(if (or (not COL) (= 249 COL)) (setq COL 1) (setq COL (1+ COL)))
(progn (grnode TD0 (/ (ACET-GEOM-PIXEL-UNIT) 0.09) COL 90 T nil 0)
(grnode TD0 (/ (ACET-GEOM-PIXEL-UNIT) 0.2) COL 45 T nil 0)))
))
(progn
(setq k (- k 2)
BTX (polar BTX (* 0.5 pi) (* 2 H))
BTY (polar BTY (* 0.5 pi) (* 2 H))
BTT (polar BTT (* 0.5 pi) (* 2 H))
BB1 (polar BB1 (* 0.5 pi) (* 2 H))
BB2 (polar BB2 (* 0.5 pi) (* 2 H))
BR (polar BR (* 0.5 pi) (* 2 H))
BL (polar BL (* 0.5 pi) (* 2 H))
VBR (polar VBR (* 0.5 pi) (* 2 H))
VBL (polar VBL (* 0.5 pi) (* 2 H))))
);if
);while
(prompt "Done\n \U+2022 Statistical coordinates data record - Copyright\U+00A9 2010 Thaistreetz")
(setq TD-value (ACET-LIST-PUT-NTH (rtos k 2 0) TD-value 5)))
;=== Xuat bang toa do coc tu binh do tuyen
(progn
(if (setq SSC (acet-ss-to-list (ssget '((0 . "LINE") (8 . "ENTCOC")))))
(progn
(setq BTR (cadr (grread 't 15 0))
BTL (polar BTR 0 (- (* H -26) Wh))
BT1 (polar BTR 0 (* H -21))
BT2 (polar BTR 0 (* H -10.5))
BB1 (polar BT1 (* 0.5 pi) (* H -2.4))
BB2 (polar BT2 (* 0.5 pi) (* H -2.4))
BR (polar BTR (* 0.5 pi) (* H -2.4))
BL (polar BTL (* 0.5 pi) (* H -2.4))
PTitle (list (- (car BTR) (+ (* 0.5 Wh) (* 13 H))) (+ (cadr BTR) (* 1.8 H)))
BTX (list (- (car BTR) (* 15.75 H)) (+ (cadr BTR) (* -1.2 H)))
BTY (list (- (car BTR) (* 5.25 H)) (+ (cadr BTR) (* -1.2 H)))
BTT (list (- (car BTR) (+ (* 0.5 Wh) (* 23.5 H))) (+ (cadr BTR) (* -1.2 H)))
OV (* H 0.3)
VTR (polar BTR (* 0.25 pi) OV)
VTL (polar BTL (* 0.75 pi) OV)
VBR (polar BR (* 1.75 pi) OV)
VBL (polar BL (* 1.25 pi) OV))
(setq SSnode (ssadd))
(setq VK (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(62 . 8) '(100 . "AcDbPolyline") '(90 . 4) '(70 . 1) (cons 10 VBR) (cons 10 VTR) (cons 10 VTL) (cons 10 VBL)))
SSnode (ssadd (entlast) SSnode))
(setq BK (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 4) '(70 . 1) (cons 10 BR) (cons 10 BTR) (cons 10 BTL) (cons 10 BL)))
SSnode (ssadd (entlast) SSnode))
(setq B1 (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 2) (cons 10 BB1) (cons 10 BT1)))
SSnode (ssadd (entlast) SSnode))
(setq B2 (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 2) (cons 10 BB2) (cons 10 BT2)))
SSnode (ssadd (entlast) SSnode))
(entmake (list '(0 . "TEXT") (cons 10 PTitle) (cons 11 PTitle) (cons 40 (* 1.2 H)) (cons 1 "%&#11;&#182;ng T&#228;a &#174;&#233; c&#228;c") (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
(setq SSnode (ssadd (entlast) SSnode))
(entmake (list '(0 . "TEXT") (cons 10 BTT) (cons 11 BTT) (cons 40 (* 1 H)) (cons 1 "T&#170;n c&#228;c") (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
(setq SSnode (ssadd (entlast) SSnode))
(entmake (list '(0 . "TEXT") (cons 10 BTX) (cons 11 BTX) (cons 40 (* 1 H)) (cons 1 "T&#228;a &#167;&#233; X") (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
(setq SSnode (ssadd (entlast) SSnode))
(entmake (list '(0 . "TEXT") (cons 10 BTY) (cons 11 BTY) (cons 40 (* 1 H)) (cons 1 "T&#228;a &#167;&#233; Y") (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
(setq SSnode (ssadd (entlast) SSnode))
(setq BTX (polar BTX (* -0.5 pi) (* 2.2 H))
BTY (polar BTY (* -0.5 pi) (* 2.2 H))
BTT (polar BTT (* -0.5 pi) (* 2.2 H)))
(prompt "OK Man! ")
(setq SSC (vl-sort SSC '(lambda (EN1 EN2) (< (atof (lytrinh EN1)) (atof (lytrinh EN2))))))
(foreach SSn SSC
(setq TD0 (acet-geom-midpoint (DXF 10 SSn) (DXF 11 SSn))
X (rtos (car TD0) 2 3)
Y (rtos (cadr TD0) 2 3)
STTBTD (tencoc SSn))
(entmake (list '(0 . "TEXT") (cons 10 BTT) (cons 11 BTT) (cons 40 (* 1 H)) (cons 1 STTBTD) (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
(setq SSnode (ssadd (entlast) SSnode))
(entmake (list '(0 . "TEXT") (cons 10 BTX) (cons 11 BTX) (cons 40 (* 1 H)) (cons 1 X) (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
(setq SSnode (ssadd (entlast) SSnode))
(entmake (list '(0 . "TEXT") (cons 10 BTY) (cons 11 BTY) (cons 40 (* 1 H)) (cons 1 Y) (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
(setq SSnode (ssadd (entlast) SSnode))
(setq BTX (polar BTX (* -0.5 pi) (* 2 H))
BTY (polar BTY (* -0.5 pi) (* 2 H))
BTT (polar BTT (* -0.5 pi) (* 2 H)))
(entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 2) (cons 10 BR) (cons 10 BL)))
(setq SSnode (ssadd (entlast) SSnode))
(setq EB1 (entget B1) EB1 (subst (cons 10 (setq BB1 (polar BB1 (* -0.5 pi) (* 2 H)))) (assoc 10 EB1) EB1))
(entmod EB1) (entupd B1)
(setq EB2 (entget B2) EB2 (subst (cons 10 (setq BB2 (polar BB2 (* -0.5 pi) (* 2 H)))) (assoc 10 EB2) EB2))
(entmod EB2) (entupd B2)
(setq EBK (entget BK)
BRi (polar BR (* -0.5 pi) (* 2 H))
BLi (polar BL (* -0.5 pi) (* 2 H))
EBK (reverse (subst (cons 10 BRi) (assoc 10 EBK) EBK))
EBK (reverse (subst (cons 10 BLi) (assoc 10 EBK) EBK))
BR Bri BL BLi)
(entmod EBK) (entupd BK)
(setq EVK (entget VK)
VRi (polar VBR (* -0.5 pi) (* 2 H))
VLi (polar VBL (* -0.5 pi) (* 2 H))
EVK (reverse (subst (cons 10 VRi) (assoc 10 EVK) EVK))
EVK (reverse (subst (cons 10 VLi) (assoc 10 EVK) EVK))
VBR Vri VBL VLi)
(entmod EVK) (entupd VK))
(acet-ss-redraw SSnode 2)
(setq OTHLAST (getvar "orthomode")) (setvar "orthomode" 0)
(if (setq PT1 (acet-ss-drag-move SSnode BTR "Chon diem dat bang toa do..."))
(vl-cmdf "move" SSnode "" BTR PT1)
(vl-cmdf "erase" SSnode ""))
(setvar "orthomode" OTHLAST)
);progn
));if End Xuat bang toa do coc tu binh do
);if
(command "UCS" "P")
(command "undo" "end")
(princ)
);end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Ps: 1 lần nữa thanks anh Bình rất nhiều đã tận tình với nhoc, còn 1 cái nữa là nếu lên tới Nut 100000 thì nhìn nó ko còn cân so với elip nữa, nhưng nhoc hết sức sức rùi ^^ ko còn biết cân sao rứa, thò đc cái đầu qua thiên đường xem thế lào thui cũng mừng ^^
https://www.cadviet.com/upfiles/3/104473_44444444444.jpg

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

  1. Chép mã nguồn, lưu thành tệp 225480_tff.lsp.
  2. 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ẽ.
  3. Gõ lệnh TFF để chạy lisp.

Mã nguồn 225480_tff.lsp (trích từ bài viết gốc)

(defun C:tff (/ tencoc check-nova lytrinh accept nova baoloi node table style DCL_CDN DCL_ID FILE_DCL HTXT TEMP_CDN TSN
     	B1 B2 BB1 BB2 BBL BBR BK BL BLI BR BRI BT1 BT2 BTL BTR BTT BTX BTY EB1 EB2 EBK
     	PT1 PTE PTITLE PTL PTX PTY TD0 X Y SSNODE STTBTD TB ANG COL DEL DIX DIY EGPL EPL GR H K LST-TS N NAME
     	EVK OV SSC VBL VBR VK VLI VRI VTL VTR WH)
(command "style" "VnArial NarrowH" ".VnArial NarrowH" "" "" "" "" "")
(command "layer" "m" "QKHS" "c" "6" "" "")
(command "undo" "be")
(setvar "cmdecho" 0)

(command "undo" "begin")
(vl-load-com)
;======================= Defun ==========================
(defun rotate-text ( en ang / p1 p2 a e1)
  (setq p1 (acet-geom-textbox (setq e1 (entget en)) 0)
    	p1 (acet-geom-midpoint (car p1) (caddr p1))
    	e1 (subst (cons 11 p1) (assoc 11 e1) e1)
    	a (cdr (assoc 50 e1))
    	a (+ ang a)
    	e1 (subst (cons 50 a) (assoc 50 e1) e1)
    	e1 (subst (cons 72 1) (assoc 72 e1) e1)
    	e1 (subst (cons 73 2) (assoc 73 e1) e1)
  );setq
(entmod e1)
(entupd EN))
(defun DXF (code en) (cdr (assoc code (entget en))))
(defun angle-d2r (ANGD) (if ANGD (/ (* pi ANGD) 180) nil))
(defun angle-r2d (ANGR) (if ANGR (/ (* 180 ANGR) pi) nil))
(defun grnode (point radius color ang node fomp hightlight / ANGi PT0 PT1 PTg COL)
  (if fomp
 	(setq ANGi 0)
 	(setq ANGi (* 0.5 (angle-d2r ang))))
 (if (= color 0) (setq COL 10) (setq COL color))
 (setq PT0 (polar point ANGi radius) PTg PT0)
 (if node (grdraw point PT0 color hightlight))
 (while (<= ANGi (* 2 Pi))
	(setq ANGi (+ ANGi (angle-d2r ang))
        	PT1 (polar point ANGi radius))
        	(if (= color 0) (setq COL (1+ COL)))
        	(if node (grdraw point PT0 COL hightlight) (grdraw PT0 PT1 COL hightlight))
	(setq PT0 PT1)
 );while
(if (not node) (grdraw PT0 PTg COL hightlight))
);end grnode
(defun tencoc (EN) (if (check-nova EN) (cdr (nth 7 (car(cdr (assoc -3 (entget EN '("*"))))))) (prompt "Doi tuong chon khong co du lieu tuyen")))
(defun check-nova (EN) (if (= (car(car(cdr (assoc -3 (entget EN '("*")))))) "TDNW") T nil))
(defun lytrinh (EN) (if (check-nova EN) (rtos (cdr (nth 5 (car(cdr (assoc -3 (entget EN '("*"))))))) 2 2) (prompt "Doi tuong chon khong co du lieu tuyen")))
(defun accept ()
  (setq TD-value (list (get_tile "node") (get_tile "table") (nth (fix (atof (get_tile "style"))) Lst-TS)
  (get_tile "height") (get_tile "name") (get_tile "start") 0)) (done_dialog))
(defun nova ()
  (setq TD-value (list (get_tile "node") (get_tile "table") (nth (fix (atof (get_tile "style"))) Lst-TS)
  (get_tile "height") (get_tile "name") (get_tile "start") 1)) (done_dialog))
(defun node ()
  (if (and (= (get_tile "table") "0") (= (get_tile "node") "0")) (set_tile "table" "1")))
(defun table ()
  (if (and (= (get_tile "table") "0") (= (get_tile "node") "0")) (set_tile "node" "1")))
(defun style (/ htxt htxt0)
  (setq htxt0 (get_tile "height"))
  (if (/= (setq htxt (cdr (assoc 40 (tblsearch "style" (nth (fix (atof (get_tile "style"))) Lst-TS))))) 0)
  (progn (set_tile "height" (rtos htxt 2 3)) (mode_tile "height" 1))
  (progn (mode_tile "height" 0) (set_tile "height" htxt0))))
(defun baoloi (val key valkey)
 (if (= "." (substr val 1 1)) (setq val (strcat "0" val)))
 (if (not (or (= val "") (and (or (= (type (read val)) 'REAL) (= (type (read val)) 'INT)) (> (atof val) 0))))
(progn
 	(if (or (= key "height") (= key "start"))
  	(repeat 2
   	(set_tile "err" (strcat " "))
   	(ACET-SYS-SLEEP 70)
   	(set_tile "err" (strcat "Gia tri " valkey " phai la so thuc duong"))
   	(ACET-SYS-SLEEP 120))
   	(repeat 2
   	(set_tile "err" (strcat " "))
   	(ACET-SYS-SLEEP 70)
   	(set_tile "err" (strcat "Gia tri " valkey " phai la so nguyen duong"))
   	(ACET-SYS-SLEEP 120)))
   	(mode_tile key 2)
   	(mode_tile key 3)
   	);progn
   	(set_tile "err" (strcat "Statistical coordinates data record - \Toa do "))
	);if
 );end error
 (if (not TD-value) (setq TD-value (list "1" "1" (getvar "textstyle") "2.00" "N" "1" 0)))
 (setq DCL_CDn (list
   	"Coordinate : dialog { value = \"http://taybac.1talk.net - \<Thong ke Toa do>\"; key = \"err\";"
   	" 	: column { children_alignment = top;"
   	"    	: boxed_row { "
   	"      	: column {"
   	"        	: toggle { key = \"node\"; label = \"Chen diem\"; height = 1.4;}"
   	"        	: toggle { key = \"table\"; label = \"Chen bang\"; height = 2.5;}}"
   	"      	: column {"
   	"       	: popup_list { key = \"style\"; label = \"Text Style\"; edit_width = 10.1;}"
   	"       	: edit_box { key = \"height\"; label = \"Height Text\"; height = 1.1; edit_width = 11;}"
   	"     	: tile { label = \"-\"; alignment = centered;}} "
   	"      	: column {"
   	"       	: edit_box { key = \"name\"; label = \"  Ten diem\"; height = 1.1; edit_width = 4;}"
   	"       	: edit_box { key = \"start\"; label = \"  So bat dau\"; height = 1.1; edit_width = 4;}"
   	"     	: tile { label = \"-\"; alignment = centered;}} "
   	"    	} "
" 	: button { key = \"nova\"; label = \"Export Station coodinates from Road-Plan\";}"
   	"    	: row {"
   	"         	: button { key = \"cancel\"; label = \"   Thoat	\"; is_cancel = true;}"
   	"         	: button { key = \"accept\"; label = \" 	Bat dau	\"; is_default = true;}}"
   	"     	}"
   	"  	}"   
   	"helpTLuy : dialog { label = \"Help and Copyright\U+00A9 Information\";"
   	"  : column {"
   	"	: row { : list_box { key = \"helpList\"; edit_width = 95; width = 98; height = 25;}}"
   	"	: row { : button { key = \"okayHelp\"; label = \"Okay\"; is_default = false; is_cancel = true;}}"
   	"	}"
   	"  }"
   	)
	TEMP_CDn (vl-filename-mktemp "CDn.DCL")
	FILE_DCL (open TEMP_CDn "W"))
 (foreach LL DCL_CDn (write-line LL FILE_DCL))
 (close FILE_DCL)
 (setq DCL_ID (load_dialog TEMP_CDn))
 (new_dialog "Coordinate" DCL_ID)
 (set_tile "node" (nth 0 TD-value))
 (set_tile "table" (nth 1 TD-value))
 (set_tile "height" (nth 3 TD-value))
 (if (/= (setq htxt (cdr (assoc 40 (tblsearch "style" (nth 2 TD-value))))) 0)
 (progn (set_tile "height" (rtos htxt 2 2)) (mode_tile "height" 1)))
 (set_tile "name" (nth 4 TD-value))
 (set_tile "start" (nth 5 TD-value))
 (start_list "style")
 (setq Lst-TS (list (nth 2 TD-value) (cdr (assoc 2 (tblnext "Style" T)))))
 (while (setq TSN (tblnext "Style"))
 (if (and (/= (cdr (assoc 2 TSN)) (nth 2 TD-value)) (/= (cdr (assoc 2 TSN)) ""))
 (setq Lst-TS (append Lst-TS (list (cdr (assoc 2 TSN))))))
 );while
 (mapcar 'add_list Lst-TS)
 (end_list)
 (action_tile "cancel" "(exit)")
 (action_tile "accept" "(accept)")
 (action_tile "nova" "(nova)")
 (action_tile "node" "(node)")
 (action_tile "table" "(table)")
 (action_tile "style" "(style)")
 (action_tile "height" "(baoloi (get_tile \"height\") \"height\" \"''Cao chu''\")")
 (action_tile "start" "(baoloi (get_tile \"start\") \"start\" \"''STT''\")")
 (start_dialog)
 (unload_dialog DCL_ID)
 (vl-file-delete TEMP_CDn)
 (setq H (atof (nth 3 TD-value)))
 (if (wcmatch (cdr (assoc 3 (tblsearch "style" (nth 2 TD-value)))) "*AVAN*,*ARIAL*,*BLACK*") (setq Wh (* 1.5 H)) (setq Wh 0))
 (if (= (nth 6 TD-value) 0) (progn
 (if (/= (nth 3 TD-value) "") (setq N (nth 3 TD-value)))
 (command "UCS" "W")
 (setvar "dimzin" 0)
(command "undo" "begin")
 (if (= (nth 5 TD-value) "") (setq k 0) (setq k (- (atof (nth 5 TD-value)) 1)))
 (if (= (nth 1 TD-value) "1") ; BEGIN TABLE
(progn (prompt "Chon diem dat bang toa do...")
(while
 	(if (= (car (setq GR (grread 't 15 0))) 5)
   	(progn
     	(if (or (not COL) (= 249 COL)) (setq COL 1) (setq COL (1+ COL)))
     	(redraw)
     	(setq BTR (cadr GR)
           	BTL (polar BTR 0 (* H -26))
           	BT1 (polar BTR 0 (* H -21))
           	BT2 (polar BTR 0 (* H -10.5))
           	BBR (polar BTR (* 0.5 pi) (* H -11))
           	BBL (polar BTL (* 0.5 pi) (* H -11))
           	BB1 (polar BT1 (* 0.5 pi) (* H -11))
           	BB2 (polar BT2 (* 0.5 pi) (* H -11))
           	BR (polar BTR (* 0.5 pi) (* H -2.4))
           	BL (polar BTL (* 0.5 pi) (* H -2.4))
           	OV (* H 0.3)
           	VTR (polar BTR (* 0.25 pi) OV)
           	VTL (polar BTL (* 0.75 pi) OV)
           	VBR (polar BR (* 1.75 pi) OV)
           	VBL (polar BL (* 1.25 pi) OV))
     	(grdraw BTL BTR COL 1)
     	(grdraw BTL BBL COL 1)
     	(grdraw BTR BBR COL 1)
     	(grdraw BT1 BB1 COL 1)
     	(grdraw BT2 BB2 COL 1)
     	(grdraw BR BL COL 1)
     	(repeat 3
     	(setq BR (polar BR (* 0.5 pi) (* H -2.0))
           	BL (polar BL (* 0.5 pi) (* H -2.0))
           	BB1 (polar BT1 (* 0.5 pi) (* H -2.4))
           	BB2 (polar BT2 (* 0.5 pi) (* H -2.4)))
     	(grdraw BR BL COL 1)) T)
  	(progn
     	(setq PTitle (list (- (car BTR) (* 13 H)) (+ (cadr BTR) (* 1.8 H)))
           	BTX (list (- (car BTR) (* 15.75 H)) (+ (cadr BTR) (* -1.2 H)))
           	BTY (list (- (car BTR) (* 5.25 H)) (+ (cadr BTR) (* -1.2 H)))
           	BTT (list (- (car BTR) (* 23.5 H)) (+ (cadr BTR) (* -1.2 H)))
           	BR (polar BTR (* 0.5 pi) (* H -2.4))
           	BL (polar BTL (* 0.5 pi) (* H -2.4)))
	(setq VK (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(62 . 8) '(100 . "AcDbPolyline") '(90 . 4) '(70 . 1)
              	(cons 10 VBR) (cons 10 VTR) (cons 10 VTL) (cons 10 VBL)))) 
	(setq BK (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 4) '(70 . 1)
              	(cons 10 BR) (cons 10 BTR) (cons 10 BTL) (cons 10 BL))))
	(setq B1 (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 2)
              	(cons 10 BB1) (cons 10 BT1))))
	(setq B2 (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 2)
              	(cons 10 BB2) (cons 10 BT2))))
	(entmake (list '(0 . "TEXT") (cons 10 PTitle) (cons 11 PTitle) (cons 40 (* 1.2 H))
              	(cons 1 "%¶ng Täa ®é ®iÓm") (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
	(entmake (list '(0 . "TEXT") (cons 10 BTT) (cons 11 BTT) (cons 40 (* 1 H))
              	(cons 1 "§iÓm") (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
	(entmake (list '(0 . "TEXT") (cons 10 BTX) (cons 11 BTX) (cons 40 (* 1 H))
              	(cons 1 "X") (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))  
	(entmake (list '(0 . "TEXT") (cons 10 BTY) (cons 11 BTY) (cons 40 (* 1 H))
              	(cons 1 "Y") (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
	(setq BTX (polar BTX (* -0.5 pi) (* 2.2 H))
      	BTY (polar BTY (* -0.5 pi) (* 2.2 H))
      	BTT (polar BTT (* -0.5 pi) (* 2.2 H)))
(prompt " OK Man!"))))));if END TABLE
(while
  (progn
	(initget 128 "u")
	(setq TD0 (getpoint (strcat "\n Pick diem thu "(rtos (setq k (1+ k)) 2 0) " : ")))
	(if (= TD0 "u") (vl-cmdf "undo" "Back") TD0))
(if (/= TD0 "u") (progn
(vl-cmdf "undo" "mark")
(princ TD0)
(setq X (rtos (car TD0) 2 3) Y (rtos (cadr TD0) 2 3))
(if (= (nth 1 TD-value) "1")
 (progn ;put into table
 (setq STTBTD (strcat (nth 4 TD-value) (rtos k 2 0)))
 (entmake (list '(0 . "TEXT") (cons 10 BTT) (cons 11 BTT) (cons 40 (* 1 H))
 (cons 1 STTBTD) (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
 (entmake (list '(0 . "TEXT") (cons 10 BTX) (cons 11 BTX) (cons 40 (* 1 H))
 (cons 1 X) (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))  
 (entmake (list '(0 . "TEXT") (cons 10 BTY) (cons 11 BTY) (cons 40 (* 1 H))
 (cons 1 Y) (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
 (setq BTX (polar BTX (* -0.5 pi) (* 2 H))
    	BTY (polar BTY (* -0.5 pi) (* 2 H))
    	BTT (polar BTT (* -0.5 pi) (* 2 H)))
 (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 2) (cons 10 BR) (cons 10 BL)))
 (setq EB1 (entget B1) EB1 (subst (cons 10 (setq BB1 (polar BB1 (* -0.5 pi) (* 2 H)))) (assoc 10 EB1) EB1))
 (entmod EB1) (entupd B1)
 (setq EB2 (entget B2) EB2 (subst (cons 10 (setq BB2 (polar BB2 (* -0.5 pi) (* 2 H)))) (assoc 10 EB2) EB2))
 (entmod EB2) (entupd B2)
 (setq EBK (entget BK)
    	BRi (polar BR (* -0.5 pi) (* 2 H))
    	BLi (polar BL (* -0.5 pi) (* 2 H))
    	EBK (reverse (subst (cons 10 BRi) (assoc 10 EBK) EBK))
    	EBK (reverse (subst (cons 10 BLi) (assoc 10 EBK) EBK))
    	BR Bri BL BLi)
 (entmod EBK) (entupd BK)
  (setq EVK (entget VK)
    	VRi (polar VBR (* -0.5 pi) (* 2 H))
    	VLi (polar VBL (* -0.5 pi) (* 2 H))
    	EVK (reverse (subst (cons 10 VRi) (assoc 10 EVK) EVK))
    	EVK (reverse (subst (cons 10 VLi) (assoc 10 EVK) EVK))
    	VBR Vri VBL VLi)
 (entmod EVK) (entupd VK)
 );progn
);if END put into table
(if (= (nth 0 TD-value) "1")
(progn
 (setq SSnode (ssadd))
 (setq PTX (polar TD0 0 (* H 0.7))
    	PTY (polar PTX (* pi -0.5) (* H 1.35)))
  (entmake (list '(0 . "TEXT") (cons 10 PTX) (cons 11 PTX) (cons 40 H) (cons 1 (strcat "X:"X)) (cons 7 (nth 2 TD-value)) '(72 . 0) '(73 . 1)))
 (setq TB  (textbox (entget(entlast)))
    	DIX (distance (car TB) (cadr TB))
    	PTL (polar PTX 0 (+ DIX (* 0.12 H))))
 (setq SSnode (ssadd (entlast) SSnode))
 (entmake (list '(0 . "TEXT") (cons 10 PTY) (cons 40 H) (cons 1 (strcat "Y:"Y)) (cons 7 (nth 2 TD-value)) '(72 . 0)))
 (setq TB  (textbox (entget(entlast))))
 (if (< DIX (setq DIY (distance (car TB) (cadr TB))))
  (setq PTL (polar PTX 0 (+ DIY (* 0.12 H)))))
 (setq SSnode (ssadd (entlast) SSnode))
 (setq EPL (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline")
                       	'(90 . 3) (cons 10 TD0) (cons 10 (polar TD0 0 (* 0.000000001 H))) (cons 10 PTL))))
 (setq SSnode (ssadd EPL SSnode))
 (if (/= (strcat (nth 4 TD-value) (nth 5 TD-value)) "")
(progn
 (setq name (strcat (nth 4 TD-value) (rtos k 2 0)))
 (entmake (list '(0 . "TEXT") (cons 10 PTL) (cons 11 (list (+ (car PTL) 0.65) (cadr PTL))) (cons 40 H)
 (cons 1 name) (cons 7 (nth 2 TD-value)) '(72 . 0) '(73 . 2)))
  (setq etext (entlast))
(setq len (abs (- (caar (textbox (list (assoc 1 (entget etext)) (assoc 40 (entget etext)) (assoc 50 (entget etext)))))
(caadr (textbox (list (assoc 1 (entget etext)) (assoc 40 (entget etext)) (assoc 50 (entget etext))))))))
(setq PTE (polar PTL 0 (/ len 1.7)))
(setq SSnode (ssadd (entlast) SSnode))
(entmake (list '(0 . "ELLIPSE") '(100 . "AcDbEntity") '(100 . "AcDbEllipse")
 (cons 10 PTE) (cons 11 (list (/ len 1.7) 0 0)) (cons 40 0.75)))
 (setq SSnode (ssadd (entlast) SSnode))
 (entmake (list '(0 . "ELLIPSE") '(100 . "AcDbEntity") '(100 . "AcDbEllipse")
         	'(62 . 8) (cons 10 PTE) (cons 11 (list (/ len 1.8) 0 0)) (cons 40 0.75)))
 (setq SSnode (ssadd (entlast) SSnode))))
 (ACET-SS-REDRAW SSnode 2)
 (if (not (setq PT1 (ACET-SS-DRAG-MOVE SSnode TD0 "" nil 0)))
	(Setq PT1 TD0)
	(setq del (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 3) (cons 10 TD0) (cons 10 PT1)))))
 (vl-cmdf "move" SSnode "" TD0 PT1)
 (ACET-SS-REDRAW SSnode 2)
 (if (not (setq ANG (ACET-SS-DRAG-ROTATE SSnode PT1 "" nil 0)))
 (if (< (* 0.5 pi) (angle PT1 (cadr (grread 't 15 0))) (* 1.5 pi)) (setq ANG pi) (setq ANG 0)))
 (vl-cmdf "erase" del "")
 (vl-cmdf "rotate" SSnode "" PT1 (rtos (angle-r2d ANG) 2 2))
 (setq SSnode (acet-ss-to-list SSnode))
 (if (< (* 0.5 pi) ANG (* 1.5 pi))
(foreach SSn SSnode (if (= (DXF 0 SSn) "TEXT") (rotate-text SSn pi))))
(setq EgPL (entget EPL) EgPL (subst (cons 10 TD0) (assoc 10 EgPL) EgPL))
(entmod EgPL)   (entupd EPL)
);progn
(progn
 (if (or (not COL) (= 249 COL)) (setq COL 1) (setq COL (1+ COL)))
 (progn (grnode TD0 (/ (ACET-GEOM-PIXEL-UNIT) 0.09) COL 90 T nil 0)
 (grnode TD0 (/ (ACET-GEOM-PIXEL-UNIT) 0.2) COL 45 T nil 0)))
))
(progn
 (setq k (- k 2)
   	BTX (polar BTX (* 0.5 pi) (* 2 H))
   	BTY (polar BTY (* 0.5 pi) (* 2 H))
   	BTT (polar BTT (* 0.5 pi) (* 2 H))
   	BB1 (polar BB1 (* 0.5 pi) (* 2 H))
   	BB2 (polar BB2 (* 0.5 pi) (* 2 H))
   	BR  (polar BR  (* 0.5 pi) (* 2 H))
   	BL  (polar BL  (* 0.5 pi) (* 2 H))
   	VBR (polar VBR (* 0.5 pi) (* 2 H))
   	VBL (polar VBL (* 0.5 pi) (* 2 H))))
);if
);while
(prompt "Done\n \U+2022 Statistical coordinates data record - Copyright\U+00A9 2010 Thaistreetz")
(setq TD-value (ACET-LIST-PUT-NTH (rtos k 2 0) TD-value 5)))
;=== Xuat bang toa do coc tu binh do tuyen
(progn
(if (setq SSC (acet-ss-to-list (ssget '((0 . "LINE") (8 . "ENTCOC")))))
(progn
  (setq BTR (cadr (grread 't 15 0))
    	BTL (polar BTR 0 (- (* H -26) Wh))
    	BT1 (polar BTR 0 (* H -21))
    	BT2 (polar BTR 0 (* H -10.5))
    	BB1 (polar BT1 (* 0.5 pi) (* H -2.4))
    	BB2 (polar BT2 (* 0.5 pi) (* H -2.4))
    	BR (polar BTR (* 0.5 pi) (* H -2.4))
    	BL (polar BTL (* 0.5 pi) (* H -2.4))
    	PTitle (list (- (car BTR) (+ (* 0.5 Wh) (* 13 H))) (+ (cadr BTR) (* 1.8 H)))
    	BTX (list (- (car BTR) (* 15.75 H)) (+ (cadr BTR) (* -1.2 H)))
    	BTY (list (- (car BTR) (* 5.25 H)) (+ (cadr BTR) (* -1.2 H)))
    	BTT (list (- (car BTR) (+ (* 0.5 Wh) (* 23.5 H))) (+ (cadr BTR) (* -1.2 H)))
    	OV (* H 0.3)
    	VTR (polar BTR (* 0.25 pi) OV)
    	VTL (polar BTL (* 0.75 pi) OV)
    	VBR (polar BR (* 1.75 pi) OV)
    	VBL (polar BL (* 1.25 pi) OV))
(setq SSnode (ssadd))
(setq VK (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(62 . 8) '(100 . "AcDbPolyline") '(90 . 4) '(70 . 1) (cons 10 VBR) (cons 10 VTR) (cons 10 VTL) (cons 10 VBL)))
     	SSnode (ssadd (entlast) SSnode))
(setq BK (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 4) '(70 . 1) (cons 10 BR) (cons 10 BTR) (cons 10 BTL) (cons 10 BL)))
     	SSnode (ssadd (entlast) SSnode))
(setq B1 (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 2) (cons 10 BB1) (cons 10 BT1)))
     	SSnode (ssadd (entlast) SSnode))
(setq B2 (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 2) (cons 10 BB2) (cons 10 BT2)))
     	SSnode (ssadd (entlast) SSnode))
(entmake (list '(0 . "TEXT") (cons 10 PTitle) (cons 11 PTitle) (cons 40 (* 1.2 H)) (cons 1 "%¶ng Täa ®é cäc") (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
(setq SSnode (ssadd (entlast) SSnode))
(entmake (list '(0 . "TEXT") (cons 10 BTT) (cons 11 BTT) (cons 40 (* 1 H)) (cons 1 "Tªn cäc") (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
(setq SSnode (ssadd (entlast) SSnode))
(entmake (list '(0 . "TEXT") (cons 10 BTX) (cons 11 BTX) (cons 40 (* 1 H)) (cons 1 "Täa §é X") (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
(setq SSnode (ssadd (entlast) SSnode))  
(entmake (list '(0 . "TEXT") (cons 10 BTY) (cons 11 BTY) (cons 40 (* 1 H)) (cons 1 "Täa §é Y") (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
(setq SSnode (ssadd (entlast) SSnode))
(setq BTX (polar BTX (* -0.5 pi) (* 2.2 H))
     	BTY (polar BTY (* -0.5 pi) (* 2.2 H))
     	BTT (polar BTT (* -0.5 pi) (* 2.2 H)))
(prompt "OK Man! ")
(setq SSC (vl-sort SSC '(lambda (EN1 EN2) (< (atof (lytrinh EN1)) (atof (lytrinh EN2))))))
(foreach SSn SSC
(setq TD0 (acet-geom-midpoint (DXF 10 SSn) (DXF 11 SSn))
     	X (rtos (car TD0) 2 3)
     	Y (rtos (cadr TD0) 2 3)     
     	STTBTD (tencoc SSn))
(entmake (list '(0 . "TEXT") (cons 10 BTT) (cons 11 BTT) (cons 40 (* 1 H)) (cons 1 STTBTD) (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
(setq SSnode (ssadd (entlast) SSnode))
(entmake (list '(0 . "TEXT") (cons 10 BTX) (cons 11 BTX) (cons 40 (* 1 H)) (cons 1 X) (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
(setq SSnode (ssadd (entlast) SSnode))
(entmake (list '(0 . "TEXT") (cons 10 BTY) (cons 11 BTY) (cons 40 (* 1 H)) (cons 1 Y) (cons 7 (nth 2 TD-value)) '(72 . 1) '(73 . 2)))
(setq SSnode (ssadd (entlast) SSnode))
(setq BTX (polar BTX (* -0.5 pi) (* 2 H))
     	BTY (polar BTY (* -0.5 pi) (* 2 H))
     	BTT (polar BTT (* -0.5 pi) (* 2 H)))
(entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 2) (cons 10 BR) (cons 10 BL)))
(setq SSnode (ssadd (entlast) SSnode))
(setq EB1 (entget B1) EB1 (subst (cons 10 (setq BB1 (polar BB1 (* -0.5 pi) (* 2 H)))) (assoc 10 EB1) EB1))
(entmod EB1) (entupd B1)
(setq EB2 (entget B2) EB2 (subst (cons 10 (setq BB2 (polar BB2 (* -0.5 pi) (* 2 H)))) (assoc 10 EB2) EB2))
(entmod EB2) (entupd B2)
(setq EBK (entget BK)
      	BRi (polar BR (* -0.5 pi) (* 2 H))
      	BLi (polar BL (* -0.5 pi) (* 2 H))
      	EBK (reverse (subst (cons 10 BRi) (assoc 10 EBK) EBK))
      	EBK (reverse (subst (cons 10 BLi) (assoc 10 EBK) EBK))
      	BR Bri BL BLi)
(entmod EBK) (entupd BK)
(setq EVK (entget VK)
      	VRi (polar VBR (* -0.5 pi) (* 2 H))
      	VLi (polar VBL (* -0.5 pi) (* 2 H))
      	EVK (reverse (subst (cons 10 VRi) (assoc 10 EVK) EVK))
      	EVK (reverse (subst (cons 10 VLi) (assoc 10 EVK) EVK))
      	VBR Vri VBL VLi)
	(entmod EVK) (entupd VK))
	(acet-ss-redraw SSnode 2)
	(setq OTHLAST (getvar "orthomode")) (setvar "orthomode" 0)
	(if (setq PT1 (acet-ss-drag-move SSnode BTR "Chon diem dat bang toa do..."))
	(vl-cmdf "move" SSnode "" BTR PT1)
	(vl-cmdf "erase" SSnode ""))
	(setvar "orthomode" OTHLAST)
);progn
));if End Xuat bang toa do coc tu binh do
);if
(command "UCS" "P")
(command "undo" "end")
(princ)
);end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Thảo luận gốc

Lisp được chia sẻ trong chủ đề [ nhờ chỉnh sửa ] lisp pick tọa độ từ hệ tọa độ cad sang vn2000. Xem đúng bài viết #225480 để đọc hướng dẫn và trao đổi thêm.

Về Thư viện AutoLisp (trang 116)