Jump to content

Nhờ hoàn thiện lisp phun điểm mia địa chính ra Autocad

Em tìm thấy hàm (defun DPGTOD rồi nhưng vẫn không được vậy bác ketxu nhỉ?

;******\\\\\\\\\**chuong trinh che bien cho may TOPCON 223*********\\\\\\\\\\\\\\*********////////
;khong dung chenh cao, chi su dung de thanh lap ban do dia chinh
(defun c:chay()
(c:cb) ;1
(c:pdm) ;2
(c:vl) ;3
(c:tm) ;4
(c:pdm) ;5
)
(defun c:cb (/ ch i FN FD sosanh j trammay
ccmay tramdh ccguong canhng hm hg goctd
canhb gocdung cd dem tam
)
(setq
FN (getfiled "NhËp file nguån : "
""
""
4
)
)
(setq i (strlen FN))
(setq ch "")
(while (/= ch "\\")
(setq ch (substr FN i 1))
(setq i (- i 1))
)
(setq xuat (substr FN 1 (+ i 1)))
(setq FD (strcat (getstring "Nhap ten file ket qua (khong can .txt): ") ".txt" ) )
(setq FD (strcat xuat FD))
(setq FD (open FD "w"))
; (setq mo (getreal "Nhap sai so MO cua may (giay) : "))
(if (= mo nil)
(progn (setq mo 0)
(princ "\n")
(princ " Lay MO=0")
(princ "\n")
)
)
(setq mo (/ mo 3600))
(setq FN (open FN "r"))
(while (and (setq PR (read-line FN)) (/= PR ""))
(progn
(setq i 1)
(setq sosanh "")
(setq ch "")
(while (/= ch " ")
(setq ch (substr PR i 1))
(setq i (+ i 1))
)
(setq sosanh (substr PR 1 (- i 2)))
(cond ((= sosanh "STN")
(progn
;///////////////////////lay ten tram may//////////
(setq j i)
(while (/= ch ",")
(setq ch (substr PR j 1))
(setq j (+ j 1))
(if (or (= ch "`") (= ch " "))
(setq i j)
)
)
(setq trammay (substr PR i (- j i 1)))
;//////////////////////lay chieu cao may/////////
(setq i j)
(while (/= ch "")
(setq ch (substr PR j 1))
(setq j (+ j 1))
)
(setq ccmay (substr PR i (- j i 2)))
(write-line (strcat "TR " trammay) FD)
) ;end progn
) ;end cond1
((= sosanh "BS")
(progn
;///////////////////////lay ten tram dinh huong//////////
(setq j i)
(while (/= ch ",")
(setq ch (substr PR j 1))
(setq j (+ j 1))
(if (or (= ch "`") (= ch " "))
(setq i j)
)
)
(setq tramdh (substr PR i (- j i 1)))
;//////////////////////lay chieu cao guong/////////
(setq i j)
(while (/= ch "")
(setq ch (substr PR j 1))
(setq j (+ j 1))
)
(setq ccguong (substr PR i (- j i 2)))
(setq tam "bs")
) ;end progn
) ;end cond2
((= sosanh "SD")
(progn
(setq j i)
(while (/= ch ",")
(setq ch (substr PR j 1))
(setq j (+ j 1))
(if (= ch " ")
(setq i j)
)
)
(setq gocbang (substr PR i (- j i 1)))
;///////////////////////////////
(setq i j)
(setq j (+ j 2))
(setq ch "")
(while (/= ch ",")
(setq ch (substr PR j 1))
(setq j (+ j 1))
)
(setq goctd (substr PR i (- j i 1)))
;////////////////////////////////
(setq i j)
(setq j (+ j 2))
(setq ch " ")
(while (/= ch "")
(setq ch (substr PR j 1))
(setq j (+ j 1))
)
(setq canhng (substr PR i (- j i 1)))
;/////////////////////////////////////
(setq hg (atof ccguong))
(setq hm (atof ccmay))
(setq gocdung (- (- 90.0 (dpgtod (atof goctd))) mo))
(setq gocdung (/ (* gocdung pi) 180))
(setq canhng (atof canhng))
(setq canhb (* canhng (cos gocdung)))
(setq h (+ (- hg hm) (* canhng (sin gocdung))))
(setq cd (strlen gocbang))
(setq i cd)
(setq dem 0)
(setq ch "")
(while (/= ch ".")
(setq ch (substr gocbang i 1))
(setq i (- i 1))
(setq dem (+ dem 1))
)
(if (= dem 6)
(setq gocbang (substr gocbang 1 (- cd 1)))
)
(if (= tam "bs")
(write-line
(strcat "DH "
(dd tramdh)
(dd gocbang)
" "
(rtos canhb 2 3)
)
FD
)
(write-line
(strcat (dd stt)
(dd gocbang)
" "
(rtos canhb 2 3)
)
FD
)
)
) ;end progn
) ;end cond3
((= sosanh "SS")
(progn
(setq j i)
(while (/= ch ",")
(setq ch (substr PR j 1))
(setq j (+ j 1))
(if (or (= ch "`") (= ch " "))
(setq i j)
)
)
(setq stt (substr PR i (- j i 1)))
(setq i j)
(while (/= ch "")
(setq ch (substr PR j 1))
(setq j (+ j 1))
)
(setq ccguong (substr PR i (- j i 2)))
(setq tam "ss")
) ;end progn
) ;end cond4
)
) ;end progn
) ;end while
(close FN)
(close FD)
(princ "\n")
(princ "\nOK!")
(princ)
)
------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------
;******chuong trinh phun diem mia cho file duoc che bien tu may TOPCON 223**********
; DUNG CHO BAN DO DIA CHINH *
;* TR DCII-04 1014424.593 516275.846 *
;* TR DCII-07 1014339.861 516213.914 *
;* TR DCII-03 1014491.054 516180.297 *
;* TR DCII-06 1014670.141 516433.592 *
;* TR DCTI-04 *
;* DH DCII-03 *
;* 1 355.1447 66.896 *
;* 2 355.1519 47.576 *
;* 3 1.4545 48.375 *
;************************************************************************
(defun c:pdm (/ tam ms PR FN thunhat
tentram caodotram xtram ytram htram
tentrammay tendh
)
(bdau)
(setq tam ())
(setq ms (getreal "Nhap vao mau so ty le : "))
(setq
FN (getfiled "NhËp file nguån : "
""
""
4
)
)
(progn
(command "-osnap" "")
(setvar "cmdecho" 0)
(setvar "luprec" 8)
(setvar "pdmode" 0)
(command "-layer" "m" "diem" "c" "red" "" "")
; (command "-layer" "m" "caodo" "c" "cyan" "" "")
(command "-layer" "m" "sothutu" "c" "magenta" "" "")
(command "-layer" "m" "khongche" "c" "red" "" "")
(setq st (/ ms 1000))
(setq st1 st)
(command "-style" "mota" "txt.shx" st1 "1" "0" "n" "n" "n")
(setq FN (open FN "r"))
(while (and (setq PR (read-line FN)) (/= PR ""))
(progn
(setq PR (strcat "(" PR ")"))
(setq PR (read PR))
(setq thunhat (nth 0 PR))
(if
(numberp thunhat)
(gapsoA)
(gaptramA)
)
) ;end progn
) ;end while
) ;end progn
;;;;;ket thuc viet lenh
(close FN)
(command "zoom" "e")
(kthuc)
(princ "\nVAY LA XONG!)*****")
(princ)
)
(defun gaptramA (/ x y)
(setq thunhat (convtostr thunhat))
(if (= thunhat "TR")
(progn
(setq ktra (nth 3 PR))
(if (/= ktra nil) ;GAP TRAM CHUA TOA DO GOC
(progn
(setq tentram (convtostr (nth 1 PR)))
(setq Y (nth 2 PR))
(setq X ktra)
; (setq h (nth 4 PR))
(setq tam (append tam (list (list tentram x y ))))
) ;GAP TRAM DO THUC TE
(progn
(setq tentrammay (convtostr (nth 1 PR)))
; (if (/= (nth 2 PR) nil)
; (setq caodotram (nth 2 PR))
; (setq caodotram 0)
; )
(laytdgoc tentrammay)
(setq tdtram1 (list (+ xtram (* 2 st)) ytram ))
(setq xxtram xtram)
(setq yytram ytram)
(setq tdtram (list xtram ytram))
(command "-layer" "s" "khongche" "")
;(command "point" tdtram)
(command "insert" "cdkc" tdtram st st "")
(setq sss (strlen tentrammay))
(setq tdtram2 (list (+ xtram (* 2 st) );(* (/ sss 2) st))
(- ytram (* 0.65 st))
)
)
; (command "insert"
; "l"
; tdtram1
; (* st sss)
; (* st sss)
; ""
; )
(command "-style"
"mota"
"txt.shx"
st
"1"
"0"
"n"
"n"
"n"
)
(command "text" "j" "bl" tdtram1 "" tentrammay)
(command "-style" "mota" "txt.shx" st1 "1" "0" "n" "n" "n")
; (command "-layer" "s" "khongche" "")
; (command "text" "j" "tl" tdtram2 "" (rtos htram 2 2))
)
)
) ;end progn
(if (= thunhat "DH") ;else
(progn
(setq tendh (convtostr (nth 1 PR)))
(laytdgoc tendh)
(setq tddh (list xtram ytram ))
(setq tddh1 (list (+ xtram (* 2 st)) ytram ))
(command "-layer" "s" "khongche" "")
(command "insert" "cdkc" tddh st st "")
;(command "point" tddh)
(setq sss (strlen tendh))
(setq tddh2 (list (+ xtram (* 2 st)); (* (/ sss 2) st))
(- ytram (* 0.65 st))
)
)
;(command "insert"
; "l"
; tddh1
; (* st sss)
; (* st sss)
; ""
;)
(command "-style"
"mota"
"txt.shx"
st
"1"
"0"
"n"
"n"
"n"
)
(command "text" "j" "bl" tddh1 "" tendh)
(command "-style" "mota" "txt.shx" st1 "1" "0" "n" "n" "n")
; (command "-layer" "s" "khongche" "")
; (command "text" "j" "tl" tddh2 "" (rtos htram 2 1))
)
)
)
)
(defun gapsoA (/ gocbang kc goctd tdx tdy tdz td dentah)
(setq gocbang (nth 1 PR))
(setq kc (nth 2 PR))
; (setq dentah (nth 3 PR))
(setq gocbang (dpgtod gocbang))
(setq gocbang (- 360 gocbang))
(setq gocbang (+ (/ (* gocbang pi) 180) (angle tdtram tddh)))
(setq tdX (+ xxtram (* kc (cos gocbang))))
(setq tdY (+ yytram (* kc (sin gocbang))))
; (if (/= dentah nil)
; (setq tdz (+ caodotram (nth 2 tdtram) dentah))
; (setq tdz 0)
; )
(setq td (list tdx tdy))
(setq td1 (list (+ tdx (* 0.5 st)) (+ tdy (* 0.3 st)) ))
(setq td2 (list (+ tdx (* 0.5 st)) (- tdy (* 0.3 st)) ))
(command "-layer" "s" "diem" "")
;(command "insert" "cdc" td st st "")
(command "point" td)
(command "-style"
"mota"
"txt.shx"
(* st 2)
"1"
"0"
"n"
"n"
"n"
)
(command "-style" "mota" "txt.shx" st1 "1" "0" "n" "n" "n")
(command "-layer" "s" "sothutu" "")
(command "text" td "" thunhat)
; (command "-style" "mota" "txt.shx" st1 "1" "0" "n" "n" "n")
; (command "-layer" "s" "caodo" "")
; (command "text" "tl" td "" (rtos tdz 2 1))
)
------------------------------------------------------------------------------------
chuong trinh tinh toa do diem dua vao goc va canh nhap vao
(defun c:vl () ;/ diemgoc diemdh goc canh)
(bdau)
(command "-layer" "m" "veluoi" "c" "cyan" "" "")
(command "-layer" "m" "point" "c" "red" "" "")
(command "-layer" "m" "text" "c" "yellow" "" "")
(setq diemgoc (getpoint "\nChon diem goc : "))
(setq diemdh (getpoint "\nChon diem dinh huong : "))
(setq goc (getreal "\nNhap goc(do.phutgiay) : "))
(setq canh (getreal "\nNhap chieu dai canh : "))
(setq tendiem (getstring "Nhap ten diem : "))
(setq goc2 (dpgtod goc))
(setq goc1 (/ (* goc2 pi) 180))
(setq gocbang (- (* 2 pi) goc1))
(setq gocbang (+ gocbang (angle diemgoc diemdh)))
(setq x1 (nth 0 diemgoc))
(setq y1 (nth 1 diemgoc))
(setq x2 (nth 0 diemdh))
(setq y2 (nth 1 diemdh))
(setq x3 (+ x1 (* canh (cos gocbang))))
(setq y3 (+ y1 (* canh (sin gocbang))))
(setq td3 (list x3 y3))
(command "-layer" "s" "point" "")
(command "point" td3)
(command "-layer" "s" "veluoi" "")
(command "line" diemgoc td3 "")
(command "-layer" "s" "text" "")
(command "-style" "mota" "txt.shx" 2 "1" "0" "n" "n" "n")
(command "text" td3 "" tendiem)
(kthuc)
)
------------------------------------------------------------------------------------
; CHUONG TRINH LAY TOA DO 1 DIEM SAP XEP THEO X : Y : Z XUAT TRANG TEXT
(defun C:TM (/ DIEM)
(command "osnap" "endpoint")
(setq DIEM (getpoint "Chon tram may can lay toa do"))
(princ "\n TOA DO TRAM MAY: ")
(princ (rtos (cadr DIEM) 2 3))
(princ " ")
(princ (rtos (car DIEM) 2 3))
(princ " ")
(princ (rtos (caddr DIEM) 2 3))
(princ)
) ;END DEFUN
---------------------------------------------------------------------------------------
CHUONG TRINH CON:
---------------------------------------------------------------------------------------
(defun c:thuhoi (/ tenfile tenfile1 timfile dodaichuoi)
(setq dodaichuoi (strlen (getvar "dwgname")))
(setq tenfile1 (strcat (substr (getvar "dwgname") 1 (- dodaichuoi 3)) "xls"))
(setq tenfile (strcat (getvar "dwgprefix") (getvar "dwgname")))
(setq timfile (findfile (strcat (getvar "dwgprefix") tenfile1)))
(if (/= timfile nil)
(vl-file-delete timfile)
)
;(command "-eattext" "" "n" "n" "C:\\Program Files\\thuhoi.blk" "X" tenfile);Ghi file nhung bo bot vai cot
(command "-eattext" "" "n" "n" "" "X" tenfile);Ghi file nhung khong bo bot cot
)
(defun laytdgoc (tentrammay / len i sosanh)
(setq len (length tam))
(setq i 0)
(setq j 0)
(while (< i len)
(progn
(setq sosanh (car (nth i tam)))
(if (= tentrammay sosanh)
(progn
(setq j (+ j 1))
(setq xtram (cadr (nth i tam)))
(setq ytram (caddr (nth i tam)))
(if (/= (cadddr (nth i tam)) nil)
(setq htram (cadddr (nth i tam)))
(setq htram 0.0)
)
)
(progn
(if (= j 0)
(progn
(setq xtram 0)
(setq ytram 0)
(setq htram 0)
)
)
)
)
(setq i (+ i 1))
)
)
)
(defun ConvtoStr (Sym)
(setq ftemp "temp.tmp")
(setq ftmp (open ftemp "w"))
(princ Sym ftmp)
(close ftmp)
(setq ftmp (open ftemp "r"))
(setq sym (read-line ftmp))
(close ftmp)
(princ sym)
)
(defun *error* (msg)
(princ "\nerror:")
(princ msg)
(command "osmode" h "")
(command "_.undo" "end")
(command "clayer" clay)
(command "u" "")
(alert " - - - - ha ha ha- - - -"
)
(setq *error* olderr)
(princ)
)
(defun bdau ()
;(setq FNr "c:\\program files\\sr.txt")
;(setq FNr (open FNr "r"))
;(setq PRr (read-line FNr))
;(if (/= PRr "0909.446.887")
;(alert "VAY LA OK!" )

;)
;(close FNr)
(command "_.undo" "begin")
(setq cmd (getvar "cmdecho"))
(setq plwid (getvar "plinewid"))
(setq elev (getvar "elevation"))
(setq thick (getvar "thickness"))
(setq hh (getvar "osmode"))
(setq clay (getvar "clayer"))
)
(defun kthuc ()
(command "plinewid" plwid)
(command "elevation" elev)
(command "thickness" thick)
(command "osmode" hh)
(command "_.undo" "end")
(command "clayer" clay)
(command "cmdecho" cmd)
)
(defun dpgtod (nhap / do phut giay)
(setq do (fix nhap))
(setq phut (fix (* (- nhap do) 100)))
(setq giay (* (- (* (- nhap do) 100) phut) 100))
(setq xuat (+ do (/ (* phut 1.0) 60) (/ giay 3600)))
)
(defun dtodpg (nhap / do phut giay)
(setq do (fix nhap))
(setq phut (fix (* (- nhap do) 60)))
(setq giay (* (- (* (- nhap do) 60) phut) 60))
(setq xuat (strcat (rtos do 2 0) "." (rtos phut 2 0) (rtos giay 2 0)))
)
(defun dd (nhap)
(setq len (strlen nhap))
(cond ((= len 1) (setq xuat (strcat nhap " ")))
((= len 2) (setq xuat (strcat nhap " ")))
((= len 3) (setq xuat (strcat nhap " ")))
((= len 4) (setq xuat (strcat nhap " ")))
((= len 5) (setq xuat (strcat nhap " ")))
((= len 6) (setq xuat (strcat nhap " ")))
((= len 7) (setq xuat (strcat nhap " ")))
((= len 8) (setq xuat (strcat nhap " ")))
((= len 9) (setq xuat (strcat nhap " ")))
((= len 10) (setq xuat (strcat nhap " ")))
((= len 11) (setq xuat (strcat nhap "")))
; ((= len 12) (setq xuat (strcat nhap " ")))
; ((= len 13) (setq xuat (strcat nhap " ")))
; ((= len 14) (setq xuat (strcat nhap " ")))
; ((= len 15) (setq xuat (strcat nhap " ")))
; ((= len 16) (setq xuat (strcat nhap " ")))
; ((= len 17) (setq xuat (strcat nhap " ")))
; ((= len 18) (setq xuat (strcat nhap " ")))
; ((= len 19) (setq xuat (strcat nhap " ")))
; ((= len 20) (setq xuat (strcat nhap " ")))
; ((= len 21) (setq xuat (strcat nhap "")))
)
)
(defun dd1 (nhap)
(setq len (strlen nhap))
(cond ((= len 1) (setq xuat (strcat nhap " ")))
((= len 2) (setq xuat (strcat nhap " ")))
((= len 3) (setq xuat (strcat nhap " ")))
((= len 4) (setq xuat (strcat nhap " ")))
((= len 5) (setq xuat (strcat nhap " ")))
((= len 6) (setq xuat (strcat nhap " ")))
((= len 7) (setq xuat (strcat nhap " ")))
((= len 8) (setq xuat (strcat nhap " ")))
((= len 9) (setq xuat (strcat nhap " ")))
((= len 10) (setq xuat (strcat nhap " ")))
((= len 11) (setq xuat (strcat nhap " ")))
((= len 12) (setq xuat (strcat nhap " ")))
((= len 13) (setq xuat (strcat nhap " ")))
((= len 14) (setq xuat (strcat nhap " ")))
((= len 15) (setq xuat (strcat nhap " ")))
((= len 16) (setq xuat (strcat nhap " ")))
((= len 17) (setq xuat (strcat nhap " ")))
((= len 18) (setq xuat (strcat nhap " ")))
((= len 19) (setq xuat (strcat nhap " ")))
((= len 20) (setq xuat (strcat nhap " ")))
((= len 21) (setq xuat (strcat nhap "")))
)
)


KHI CHẠY ĐẾN BƯỚC PHUN ĐIỂM MIA THÌ NÓ HIỆN LÊN DÒNG NÀY LÀ SAO ANH NHỈ:

Command: chay
Nhap ten file ket qua (khong can .txt): hoanchinh


OK!Nhap vao mau so ty le : 200
Regenerating model.
TRA
error:bad argument type: numberp: nil
Requires an integer between 0 and 32767.
; error: An error has occurred inside the *error* functionFunction cancelled

Enter new value for OSMODE <0>:
NÓ KHÔNG PHUN ĐIỂM RA NGOÀI MÀN HÌNH ANH Ạ

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 193494_chay_cb_pdm_vl_tm_thuhoi.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 CHAY CB PDM VL TM THUHOI để chạy lisp.

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

;******\\\\\\\\\**chuong trinh che bien cho may TOPCON 223*********\\\\\\\\\\\\\\*********////////
	;khong dung chenh cao, chi su dung de thanh lap ban do dia chinh
(defun c:chay()
(c:cb) ;1
(c:pdm) ;2
(c:vl) ;3
(c:tm) ;4
(c:pdm) ;5
)
(defun c:cb (/ ch i FN FD sosanh j trammay
ccmay tramdh ccguong canhng hm hg goctd
canhb gocdung cd dem tam
)
(setq
FN (getfiled "NhËp file nguån : "
""
""
4
)
)
(setq i (strlen FN))
(setq ch "")
(while (/= ch "\\")
(setq ch (substr FN i 1))
(setq i (- i 1))
)
(setq xuat (substr FN 1 (+ i 1)))
(setq FD (strcat (getstring "Nhap ten file ket qua  (khong can .txt): ") ".txt" ) )
(setq FD (strcat xuat FD))
(setq FD (open FD "w"))
; (setq mo (getreal "Nhap sai so MO cua may (giay) : "))
(if (= mo nil)
(progn (setq mo 0)
(princ "\n")
(princ " Lay MO=0")
(princ "\n")
)
)
(setq mo (/ mo 3600))
(setq FN (open FN "r"))
(while (and (setq PR (read-line FN)) (/= PR ""))
(progn
(setq i 1)
(setq sosanh "")
(setq ch "")
(while (/= ch " ")
(setq ch (substr PR i 1))
(setq i (+ i 1))
)
(setq sosanh (substr PR 1 (- i 2)))
(cond ((= sosanh "STN")
(progn
;///////////////////////lay ten tram may//////////
(setq j i)
(while (/= ch ",")
(setq ch (substr PR j 1))
(setq j (+ j 1))
(if (or (= ch "`") (= ch " "))
(setq i j)
)
)
(setq trammay (substr PR i (- j i 1)))
;//////////////////////lay chieu cao may/////////
(setq i j)
(while (/= ch "")
(setq ch (substr PR j 1))
(setq j (+ j 1))
)
(setq ccmay (substr PR i (- j i 2)))
(write-line (strcat "TR " trammay) FD)
) ;end progn
) ;end cond1
((= sosanh "BS")
(progn
;///////////////////////lay ten tram dinh huong//////////
(setq j i)
(while (/= ch ",")
(setq ch (substr PR j 1))
(setq j (+ j 1))
(if (or (= ch "`") (= ch " "))
(setq i j)
)
)
(setq tramdh (substr PR i (- j i 1)))
;//////////////////////lay chieu cao guong/////////
(setq i j)
(while (/= ch "")
(setq ch (substr PR j 1))
(setq j (+ j 1))
)
(setq ccguong (substr PR i (- j i 2)))
(setq tam "bs")
) ;end progn
) ;end cond2
((= sosanh "SD")
(progn
(setq j i)
(while (/= ch ",")
(setq ch (substr PR j 1))
(setq j (+ j 1))
(if (= ch " ")
(setq i j)
)
)
(setq gocbang (substr PR i (- j i 1)))
;///////////////////////////////
(setq i j)
(setq j (+ j 2))
(setq ch "")
(while (/= ch ",")
(setq ch (substr PR j 1))
(setq j (+ j 1))
)
(setq goctd (substr PR i (- j i 1)))
;////////////////////////////////
(setq i j)
(setq j (+ j 2))
(setq ch " ")
(while (/= ch "")
(setq ch (substr PR j 1))
(setq j (+ j 1))
)
(setq canhng (substr PR i (- j i 1)))
;/////////////////////////////////////
(setq hg (atof ccguong))
(setq hm (atof ccmay))
(setq gocdung (- (- 90.0 (dpgtod (atof goctd))) mo))
(setq gocdung (/ (* gocdung pi) 180))
(setq canhng (atof canhng))
(setq canhb (* canhng (cos gocdung)))
(setq h (+ (- hg hm) (* canhng (sin gocdung))))
(setq cd (strlen gocbang))
(setq i cd)
(setq dem 0)
(setq ch "")
(while (/= ch ".")
(setq ch (substr gocbang i 1))
(setq i (- i 1))
(setq dem (+ dem 1))
)
(if (= dem 6)
(setq gocbang (substr gocbang 1 (- cd 1)))
)
(if (= tam "bs")
(write-line
(strcat "DH "
(dd tramdh)
(dd gocbang)
" "
(rtos canhb 2 3)
)
FD
)
(write-line
(strcat (dd stt)
(dd gocbang)
" "
(rtos canhb 2 3)
)
FD
)
)
) ;end progn
) ;end cond3
((= sosanh "SS")
(progn
(setq j i)
(while (/= ch ",")
(setq ch (substr PR j 1))
(setq j (+ j 1))
(if (or (= ch "`") (= ch " "))
(setq i j)
)
)
(setq stt (substr PR i (- j i 1)))
(setq i j)
(while (/= ch "")
(setq ch (substr PR j 1))
(setq j (+ j 1))
)
(setq ccguong (substr PR i (- j i 2)))
(setq tam "ss")
) ;end progn
) ;end cond4
)
) ;end progn
) ;end while
(close FN)
(close FD)
(princ "\n")
(princ "\nOK!")
(princ)
)
------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------
;******chuong trinh phun diem mia cho file duoc che bien tu may TOPCON 223**********
	;          	DUNG CHO BAN DO DIA CHINH 	*
	;* TR  DCII-04  1014424.593 516275.846       	*
	;* TR  DCII-07  1014339.861 516213.914       	*
	;* TR  DCII-03  1014491.054  516180.297        	*
	;* TR  DCII-06  1014670.141  516433.592         	*
	;* TR  DCTI-04       	*
	;* DH  DCII-03         	*
	;* 1    	355.1447 	66.896        	*
	;* 2    	355.1519 	47.576         	*
	;* 3    	1.4545   	48.375        	*
	;************************************************************************
(defun c:pdm (/    	tam ms  PR   FN	thunhat
  	tentram  caodotram  xtram   ytram	htram
  	tentrammay tendh
 	)
 (bdau)
 (setq tam ())
 (setq ms (getreal "Nhap vao mau so ty le : "))
 (setq
FN (getfiled "NhËp file nguån : "
  ""
  ""
  4
  	)
 )
 (progn
(command "-osnap" "")
(setvar "cmdecho" 0)
(setvar "luprec" 8)
(setvar "pdmode" 0)
(command "-layer" "m" "diem" "c" "red" "" "")
;	(command "-layer" "m" "caodo" "c" "cyan" "" "")
(command "-layer" "m" "sothutu" "c" "magenta" "" "")
(command "-layer" "m" "khongche" "c" "red" "" "")
(setq st (/ ms 1000))
(setq st1 st)
(command "-style" "mota" "txt.shx" st1 "1" "0" "n" "n" "n")
(setq FN (open FN "r"))
(while (and (setq PR (read-line FN)) (/= PR ""))
 	(progn
(setq PR (strcat "(" PR ")"))
(setq PR (read PR))
(setq thunhat (nth 0 PR))
(if
  (numberp thunhat)
(gapsoA)
(gaptramA)
)
 	) 	;end progn
) 	;end while
 ) 	;end progn
;;;;;ket thuc viet lenh
 (close FN)
 (command "zoom" "e")
 (kthuc)
 (princ "\nVAY LA XONG!)*****")
 (princ)
)
(defun gaptramA (/ x y)
 (setq thunhat (convtostr thunhat))
 (if (= thunhat "TR")
(progn
 	(setq ktra (nth 3 PR))
 	(if (/= ktra nil) ;GAP TRAM CHUA TOA DO GOC
(progn
  (setq tentram (convtostr (nth 1 PR)))
  (setq Y (nth 2 PR))
  (setq X ktra)
;   (setq h (nth 4 PR))
  (setq tam (append tam (list (list tentram x y ))))
)   ;GAP TRAM DO THUC TE
(progn
  (setq tentrammay (convtostr (nth 1 PR)))
;   (if (/= (nth 2 PR) nil)
; 	(setq caodotram (nth 2 PR))
; 	(setq caodotram 0)
;   )
  (laytdgoc tentrammay)
  (setq tdtram1 (list (+ xtram (* 2 st)) ytram ))
  (setq xxtram xtram)
  (setq yytram ytram)
  (setq tdtram (list xtram ytram))
  (command "-layer" "s" "khongche" "")
;(command "point" tdtram)
  (command "insert" "cdkc" tdtram st st "")
  (setq sss (strlen tentrammay))
  (setq tdtram2 (list (+ xtram (* 2 st) );(* (/ sss 2) st))
    	(- ytram (* 0.65 st))       
  )
  )
;   (command "insert"
; 	"l"
; 	tdtram1
; 	(* st sss)
; 	(* st sss)
; 	""
;   )
  (command "-style"
	"mota"
	"txt.shx"
	st
	"1"
	"0"
	"n"
	"n"
	"n"
  )
  (command "text" "j" "bl" tdtram1 "" tentrammay)
  (command "-style" "mota" "txt.shx" st1 "1" "0" "n" "n" "n")
;   (command "-layer" "s" "khongche" "")
;   (command "text" "j" "tl" tdtram2 "" (rtos htram 2 2))
)
 	)
) 	;end progn
(if (= thunhat "DH")  ;else
 	(progn
(setq tendh (convtostr (nth 1 PR)))
(laytdgoc tendh)
(setq tddh (list xtram ytram ))
(setq tddh1 (list (+ xtram (* 2 st)) ytram ))
(command "-layer" "s" "khongche" "")
(command "insert" "cdkc" tddh st st "")
;(command "point" tddh)
(setq sss (strlen tendh))
(setq tddh2 (list (+ xtram (* 2 st)); (* (/ sss 2) st))
	(- ytram (* 0.65 st))    
 	)
)
;(command "insert"
;  "l"
;  tddh1
;  (* st sss)
;  (* st sss)
;  ""
;)
(command "-style"
  "mota"
  "txt.shx"
  st
  "1"
  "0"
  "n"
  "n"
  "n"
)
(command "text" "j" "bl" tddh1 "" tendh)
(command "-style" "mota" "txt.shx" st1 "1" "0" "n" "n" "n")
; (command "-layer" "s" "khongche" "")
; (command "text" "j" "tl" tddh2 "" (rtos htram 2 1))
 	)
)
 )
)
(defun gapsoA (/ gocbang kc goctd tdx tdy tdz td dentah)
 (setq gocbang (nth 1 PR))
 (setq kc (nth 2 PR))
;  (setq dentah (nth 3 PR))
 (setq gocbang (dpgtod gocbang))
 (setq gocbang (- 360 gocbang))
 (setq gocbang (+ (/ (* gocbang pi) 180) (angle tdtram tddh)))
 (setq tdX (+ xxtram (* kc (cos gocbang))))
 (setq tdY (+ yytram (* kc (sin gocbang))))
;  (if (/= dentah nil)
;	(setq tdz (+ caodotram (nth 2 tdtram) dentah))
;	(setq tdz 0)
;  )
 (setq td (list tdx tdy))
 (setq td1 (list (+ tdx (* 0.5 st)) (+ tdy (* 0.3 st)) ))
 (setq td2 (list (+ tdx (* 0.5 st)) (- tdy (* 0.3 st)) ))
 (command "-layer" "s" "diem" "")
 ;(command "insert" "cdc" td st st "")
 (command "point" td)
 (command "-style"
"mota"
"txt.shx"
(* st 2)
"1"
"0"
"n"
"n"
"n"
 )
 (command "-style" "mota" "txt.shx" st1 "1" "0" "n" "n" "n")
 (command "-layer" "s" "sothutu" "")
 (command "text" td "" thunhat)
;  (command "-style" "mota" "txt.shx" st1 "1" "0" "n" "n" "n")
;  (command "-layer" "s" "caodo" "")
;  (command "text" "tl" td "" (rtos tdz 2 1))
)
------------------------------------------------------------------------------------
chuong trinh tinh toa do diem dua vao goc va canh nhap vao
(defun c:vl ()	;/ diemgoc diemdh goc canh)
 (bdau)
 (command "-layer" "m" "veluoi" "c" "cyan" "" "")
 (command "-layer" "m" "point" "c" "red" "" "")
 (command "-layer" "m" "text" "c" "yellow" "" "")
 (setq diemgoc (getpoint "\nChon diem goc : "))
 (setq diemdh (getpoint "\nChon diem dinh huong : "))
 (setq goc (getreal "\nNhap goc(do.phutgiay) : "))
 (setq canh (getreal "\nNhap chieu dai canh : "))
 (setq tendiem (getstring "Nhap ten diem : "))
 (setq goc2 (dpgtod goc))
 (setq goc1 (/ (* goc2 pi) 180))
 (setq gocbang (- (* 2 pi) goc1))
 (setq gocbang (+ gocbang (angle diemgoc diemdh)))
 (setq x1 (nth 0 diemgoc))
 (setq y1 (nth 1 diemgoc))
 (setq x2 (nth 0 diemdh))
 (setq y2 (nth 1 diemdh))
 (setq x3 (+ x1 (* canh (cos gocbang))))
 (setq y3 (+ y1 (* canh (sin gocbang))))
 (setq td3 (list x3 y3))
 (command "-layer" "s" "point" "")
 (command "point" td3)
 (command "-layer" "s" "veluoi" "")
 (command "line" diemgoc td3 "")
 (command "-layer" "s" "text" "")
 (command "-style" "mota" "txt.shx" 2 "1" "0" "n" "n" "n")
 (command "text" td3 "" tendiem)
 (kthuc)
)
------------------------------------------------------------------------------------
; CHUONG TRINH LAY TOA DO 1 DIEM SAP XEP THEO X : Y : Z XUAT TRANG TEXT
(defun C:TM (/ DIEM)
 (command "osnap" "endpoint")
 (setq DIEM (getpoint "Chon tram may can lay toa do"))
 (princ "\n TOA DO TRAM MAY:   ")
 (princ (rtos (cadr DIEM) 2 3))
 (princ "  ")
 (princ (rtos (car DIEM) 2 3))
 (princ "  ")
 (princ (rtos (caddr DIEM) 2 3))
 (princ)
) 	;END DEFUN
---------------------------------------------------------------------------------------
CHUONG TRINH CON:
---------------------------------------------------------------------------------------
(defun c:thuhoi (/ tenfile tenfile1 timfile dodaichuoi)
 (setq dodaichuoi (strlen (getvar "dwgname")))
 (setq tenfile1 (strcat (substr (getvar "dwgname") 1 (- dodaichuoi 3)) "xls"))
 (setq tenfile (strcat (getvar "dwgprefix") (getvar "dwgname")))
 (setq timfile (findfile (strcat (getvar "dwgprefix") tenfile1)))
 (if (/= timfile nil)
 	(vl-file-delete timfile)
 )
 ;(command "-eattext" "" "n" "n" "C:\\Program Files\\thuhoi.blk" "X" tenfile);Ghi file nhung bo bot vai cot
 (command "-eattext" "" "n" "n" "" "X" tenfile);Ghi file nhung khong bo bot cot
)
(defun laytdgoc (tentrammay / len i sosanh)
 (setq len (length tam))
 (setq i 0)
 (setq j 0)
 (while (< i len)
(progn
 	(setq sosanh (car (nth i tam)))
 	(if (= tentrammay sosanh)
(progn
  (setq j (+ j 1))
  (setq xtram (cadr (nth i tam)))
  (setq ytram (caddr (nth i tam)))
  (if (/= (cadddr (nth i tam)) nil)
	(setq htram (cadddr (nth i tam)))
	(setq htram 0.0)
  )
)
(progn
  (if (= j 0)
	(progn
  	(setq xtram 0)
  	(setq ytram 0)
  	(setq htram 0)
	)
  )
)
 	)
 	(setq i (+ i 1))
)
 )
)
(defun ConvtoStr (Sym)
 (setq ftemp "temp.tmp")
 (setq ftmp (open ftemp "w"))
 (princ Sym ftmp)
 (close ftmp)
 (setq ftmp (open ftemp "r"))
 (setq sym (read-line ftmp))
 (close ftmp)
 (princ sym)
)
(defun *error* (msg)
 (princ "\nerror:")
 (princ msg)
 (command "osmode" h "")
 (command "_.undo" "end")
 (command "clayer" clay)
 (command "u" "")
 (alert "  - - - - ha ha ha- - - -"
 )
 (setq *error* olderr)
 (princ)
)
(defun bdau ()
;(setq FNr "c:\\program files\\sr.txt")
;(setq FNr (open FNr "r"))
;(setq PRr (read-line FNr))
;(if (/= PRr "0909.446.887")
;(alert "VAY LA OK!"  )

;)
;(close FNr)
 (command "_.undo" "begin")
 (setq cmd (getvar "cmdecho"))
 (setq plwid (getvar "plinewid"))
 (setq elev (getvar "elevation"))
 (setq thick (getvar "thickness"))
 (setq hh (getvar "osmode"))
 (setq clay (getvar "clayer"))
)
(defun kthuc ()
 (command "plinewid" plwid)
 (command "elevation" elev)
 (command "thickness" thick)
 (command "osmode" hh)
 (command "_.undo" "end")
 (command "clayer" clay)
 (command "cmdecho" cmd)
)
(defun dpgtod (nhap / do phut giay)
 (setq do (fix nhap))
 (setq phut (fix (* (- nhap do) 100)))
 (setq giay (* (- (* (- nhap do) 100) phut) 100))
 (setq xuat (+ do (/ (* phut 1.0) 60) (/ giay 3600)))
)
(defun dtodpg (nhap / do phut giay)
 (setq do (fix nhap))
 (setq phut (fix (* (- nhap do) 60)))
 (setq giay (* (- (* (- nhap do) 60) phut) 60))
 (setq xuat (strcat (rtos do 2 0) "." (rtos phut 2 0) (rtos giay 2 0)))
)
(defun dd (nhap)
 (setq len (strlen nhap))
 (cond ((= len 1)  (setq xuat (strcat nhap "      	")))
((= len 2)  (setq xuat (strcat nhap "     	")))
((= len 3)  (setq xuat (strcat nhap "    	")))
((= len 4)  (setq xuat (strcat nhap "   	")))
((= len 5)  (setq xuat (strcat nhap "  	")))
((= len 6)  (setq xuat (strcat nhap " 	")))
((= len 7)  (setq xuat (strcat nhap "	")))
((= len 8)  (setq xuat (strcat nhap "   ")))
((= len 9)  (setq xuat (strcat nhap "  ")))
((= len 10) (setq xuat (strcat nhap " ")))
((= len 11) (setq xuat (strcat nhap "")))
; ((= len 12) (setq xuat (strcat nhap "     	")))
; ((= len 13) (setq xuat (strcat nhap "    	")))
; ((= len 14) (setq xuat (strcat nhap "   	")))
; ((= len 15) (setq xuat (strcat nhap "  	")))
; ((= len 16) (setq xuat (strcat nhap " 	")))
; ((= len 17) (setq xuat (strcat nhap "	")))
; ((= len 18) (setq xuat (strcat nhap "   ")))
; ((= len 19) (setq xuat (strcat nhap "  ")))
; ((= len 20) (setq xuat (strcat nhap " ")))
; ((= len 21) (setq xuat (strcat nhap "")))
 )
)
(defun dd1 (nhap)
 (setq len (strlen nhap))
 (cond ((= len 1)  (setq xuat (strcat nhap "                	")))
((= len 2)  (setq xuat (strcat nhap "               	")))
((= len 3)  (setq xuat (strcat nhap "              	")))
((= len 4)  (setq xuat (strcat nhap "             	")))
((= len 5)  (setq xuat (strcat nhap "            	")))
((= len 6)  (setq xuat (strcat nhap "           	")))
((= len 7)  (setq xuat (strcat nhap "          	")))
((= len 8)  (setq xuat (strcat nhap "         	")))
((= len 9)  (setq xuat (strcat nhap "        	")))
((= len 10) (setq xuat (strcat nhap "       	")))
((= len 11) (setq xuat (strcat nhap "      	")))
((= len 12) (setq xuat (strcat nhap "     	")))
((= len 13) (setq xuat (strcat nhap "    	")))
((= len 14) (setq xuat (strcat nhap "   	")))
((= len 15) (setq xuat (strcat nhap "  	")))
((= len 16) (setq xuat (strcat nhap " 	")))
((= len 17) (setq xuat (strcat nhap "	")))
((= len 18) (setq xuat (strcat nhap "   ")))
((= len 19) (setq xuat (strcat nhap "  ")))
((= len 20) (setq xuat (strcat nhap " ")))
((= len 21) (setq xuat (strcat nhap "")))
 )
)

Thảo luận gốc

Lisp được chia sẻ trong chủ đề [Nhờ chỉnh sửa] Nhờ hoàn thiện lisp phun điểm mia địa chính ra Autocad. Xem đúng bài viết #193494 để đọc hướng dẫn và trao đổi thêm.

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