Jump to content

Tạo menu những lệnh cơ bản

-Bạn load file này về và copy vào thư mục menu trong ổ E. (do mình gặp trở ngại trong việc xoá file bằng lisp nên bị hạn chế phải thư mục cố định mới được).
-Tên lệnh VMN
  • Tải lisp
  • 163338_vmn_xbmn_tlmn_slmn_glmn_btmn_sdmn_dtmn_xmn_xmnkxl_xmnxl_gtmn_gtmnxl.lsp

Cách dùng

  1. Tải tệp 163338_vmn_xbmn_tlmn_slmn_glmn_btmn_sdmn_dtmn_xmn_xmnkxl_xmnxl_gtmn_gtmnxl.lsp về máy.
  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 VMN XBMN TLMN SLMN GLMN BTMN SDMN DTMN XMN XMNKXL XMNXL GTMN GTMNXL để chạy lisp.

Mã nguồn 163338_vmn_xbmn_tlmn_slmn_glmn_btmn_sdmn_dtmn_xmn_xmnkxl_xmnxl_gtmn_gtmnxl.lsp

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/45066-y%C3%AAu-c%E1%BA%A7u-lisp-t%E1%BA%A1o-menu-nh%E1%BB%AFng-l%E1%BB%87nh-c%C6%A1-b%E1%BA%A3n/?page=2&tab=comments#comment-163338
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun docghigiuapop1xl ()
(setq filemenuchinhp1xl (open (strcat dauduongdan tenfilemodoc) "r"))
(while (setq noidungmenuchinhp1xl (read-line filemenuchinhp1xl))
(setq noidungnguyen noidungmenuchinhp1xl)
(setq dodainguyen (strlen noidungnguyen))
(setq dodainguyenl dodainguyen)
(doc@)

(cond
((= ndsau "menuxeplop") (setq tenfilemodoc (strcat "/menuxl" ndtruoc ".txt")) (write-line (strcat "[->" ndtruoc "]") filemns) (docghigiuapop1xla))
((/= ndsau "menuxeplop") 

(cond
((= ndsau "mnduongphancach") (write-line "[---]" filemns))
((/= ndsau "mnduongphancach")

(write-line (strcat "[" ndtruoc "\t(" ndsau ")]^C^C_" ndsau) filemns))
))
))

(close filemenuchinhp1xl)
(write-line (strcat "[<---]") filemns)
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun docghigiuapop1xla ()
(setq filemenuchinhp1xla (open (strcat dauduongdan tenfilemodoc) "r"))
(while (setq noidungmenuchinhp1xla (read-line filemenuchinhp1xla))
(setq noidungnguyen noidungmenuchinhp1xla)
(setq dodainguyen (strlen noidungnguyen))
(setq dodainguyenl dodainguyen)
(doc@)

(cond
((= ndsau "menuxeplop") (setq tenfilemodoc (strcat "/menuxl" ndtruoc ".txt")) (write-line (strcat "[->" ndtruoc "]") filemns) (docghigiuapop1xlb))
((/= ndsau "menuxeplop") 

(cond
((= ndsau "mnduongphancach") (write-line "[---]" filemns))
((/= ndsau "mnduongphancach")

(write-line (strcat "[" ndtruoc "\t(" ndsau ")]^C^C_" ndsau) filemns))
))
))

(close filemenuchinhp1xla)
(write-line (strcat "[<---]") filemns)
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun docghigiuapop1xlb ()
(setq filemenuchinhp1xlb (open (strcat dauduongdan tenfilemodoc) "r"))
(while (setq noidungmenuchinhp1xlb (read-line filemenuchinhp1xlb))
(setq noidungnguyen noidungmenuchinhp1xlb)
(setq dodainguyen (strlen noidungnguyen))
(setq dodainguyenl dodainguyen)
(doc@)

(cond
((= ndsau "menuxeplop") (setq tenfilemodoc (strcat "/menuxl" ndtruoc ".txt")) (write-line (strcat "[->" ndtruoc "]") filemns) (docghigiuapop1xlc))
((/= ndsau "menuxeplop") 

(cond
((= ndsau "mnduongphancach") (write-line "[---]" filemns))
((/= ndsau "mnduongphancach")

(write-line (strcat "[" ndtruoc "\t(" ndsau ")]^C^C_" ndsau) filemns))
))
))

(close filemenuchinhp1xlb)
(write-line (strcat "[<---]") filemns)
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun docghigiuapop1xlc ()
(setq filemenuchinhp1xlc (open (strcat dauduongdan tenfilemodoc) "r"))
(while (setq noidungmenuchinhp1xlc (read-line filemenuchinhp1xlc))
(setq noidungnguyen noidungmenuchinhp1xlc)
(setq dodainguyen (strlen noidungnguyen))
(setq dodainguyenl dodainguyen)
(doc@)

(cond
((= ndsau "menuxeplop") (setq tenfilemodoc (strcat "/menuxl" ndtruoc ".txt")) (write-line (strcat "[->" ndtruoc "]") filemns) (docghigiuapop1xld))
((/= ndsau "menuxeplop") 

(cond
((= ndsau "mnduongphancach") (write-line "[---]" filemns))
((/= ndsau "mnduongphancach")

(write-line (strcat "[" ndtruoc "\t(" ndsau ")]^C^C_" ndsau) filemns))
))
))

(close filemenuchinhp1xlc)
(write-line (strcat "[<---]") filemns)
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun docghigiuapop1xld ()
(setq filemenuchinhp1xld (open (strcat dauduongdan tenfilemodoc) "r"))
(while (setq noidungmenuchinhp1xld (read-line filemenuchinhp1xld))
(setq noidungnguyen noidungmenuchinhp1xld)
(setq dodainguyen (strlen noidungnguyen))
(setq dodainguyenl dodainguyen)
(doc@)

(cond
((= ndsau "menuxeplop") (setq tenfilemodoc (strcat "/menuxl" ndtruoc ".txt")) (write-line (strcat "[->" ndtruoc "]") filemns) (docghigiuapop1xle))
((/= ndsau "menuxeplop") 

(cond
((= ndsau "mnduongphancach") (write-line "[---]" filemns))
((/= ndsau "mnduongphancach")

(write-line (strcat "[" ndtruoc "\t(" ndsau ")]^C^C_" ndsau) filemns))
))
))

(close filemenuchinhp1xld)
(write-line (strcat "[<---]") filemns)
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun docghigiuapop1xle ()
(setq filemenuchinhp1xle (open (strcat dauduongdan tenfilemodoc) "r"))
(while (setq noidungmenuchinhp1xle (read-line filemenuchinhp1xle))
(setq noidungnguyen noidungmenuchinhp1xle)
(setq dodainguyen (strlen noidungnguyen))
(setq dodainguyenl dodainguyen)
(doc@)

(cond
((= ndsau "mnduongphancach") (write-line "[---]" filemns))
((/= ndsau "mnduongphancach")

(write-line (strcat "[" ndtruoc "\t(" ndsau ")]^C^C_" ndsau) filemns))
))

(close filemenuchinhp1xle)
(write-line (strcat "[<---]") filemns)
)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun docghigiuapop2xl ()
(setq filemenuchinhp2xl (open (strcat dauduongdan tenfilemodoc) "r"))
(while (setq noidungmenuchinhp2xl (read-line filemenuchinhp2xl))
(setq noidungnguyen noidungmenuchinhp2xl)
(setq dodainguyen (strlen noidungnguyen))
(setq dodainguyenl dodainguyen)
(doc@)

(cond
((= ndsau "menuxeplop")  
(setq tenfilemodoca (strcat "/menuxl" ndtruoc ".txt")) 
(write-line (strcat "[->" ndtruoc "]") filemns) 
(setq tenmnxlhthia ndtruoc) 
(docghigiuapop2xla))
((/= ndsau "menuxeplop") 

(cond
((= ndsau "mnduongphancach") (write-line (strcat "[Xoa duong phan cach]^C^C_" "xmn" "\;" "\"" noidungmenuchinhp2xl "\"" "\;" "\"" tenfilemodoc "\"" "\;" "\"" "x" "\"" "\;") filemns) (write-line "[---]" filemns))
((/= ndsau "mnduongphancach")

(write-line (strcat "[" ndtruoc "\t<<Bien Tap]^C^C_" "xmn" "\;" "\"" noidungmenuchinhp2xl "\"" "\;" "\"" tenfilemodoc "\"" "\;") filemns))  
))
))

(close filemenuchinhp2xl)
(write-line (strcat "[---]") filemns)
(write-line (strcat "[<-Xoa menu xep lop  " tenmnxlhthi "  nay]^C^C_" "xmnxl" "\;" "\"" tenmnxlhthi "@menuxeplop" "\"" "\;" "\"" "/menuchinh.txt" "\"" "\;") filemns)
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun docghigiuapop2xla ()
(setq filemenuchinhp2xla (open (strcat dauduongdan tenfilemodoca) "r"))
(while (setq noidungmenuchinhp2xla (read-line filemenuchinhp2xla))
(setq noidungnguyen noidungmenuchinhp2xla)
(setq dodainguyen (strlen noidungnguyen))
(setq dodainguyenl dodainguyen)
(doc@)

(cond
((= ndsau "menuxeplop") 
(setq tenfilemodocb (strcat "/menuxl" ndtruoc ".txt")) 
(write-line (strcat "[->" ndtruoc "]") filemns) 
(setq tenmnxlhthib ndtruoc) 
(docghigiuapop2xlb))
((/= ndsau "menuxeplop") 

(cond
((= ndsau "mnduongphancach") (write-line (strcat "[Xoa duong phan cach]^C^C_" "xmn" "\;" "\"" noidungmenuchinhp2xla "\"" "\;" "\"" tenfilemodoca "\"" "\;" "\"" "x" "\"" "\;") filemns) (write-line "[---]" filemns))
((/= ndsau "mnduongphancach")

(write-line (strcat "[" ndtruoc "\t<<Bien Tap]^C^C_" "xmn" "\;" "\"" noidungmenuchinhp2xla "\"" "\;" "\"" tenfilemodoca "\"" "\;") filemns))  
))
))

(close filemenuchinhp2xla)
(write-line (strcat "[---]") filemns)
(write-line (strcat "[<-Xoa menu xep lop  " tenmnxlhthia "  nay]^C^C_" "xmnxl" "\;" "\"" tenmnxlhthia "@menuxeplop" "\"" "\;" "\"" tenfilemodoc "\"" "\;") filemns)
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun docghigiuapop2xlb ()
(setq filemenuchinhp2xlb (open (strcat dauduongdan tenfilemodocb) "r"))
(while (setq noidungmenuchinhp2xlb (read-line filemenuchinhp2xlb))
(setq noidungnguyen noidungmenuchinhp2xlb)
(setq dodainguyen (strlen noidungnguyen))
(setq dodainguyenl dodainguyen)
(doc@)

(cond
((= ndsau "menuxeplop") 
(setq tenfilemodocc (strcat "/menuxl" ndtruoc ".txt")) 
(write-line (strcat "[->" ndtruoc "]") filemns) 
(setq tenmnxlhthic ndtruoc) 
(docghigiuapop2xlc))
((/= ndsau "menuxeplop") 

(cond
((= ndsau "mnduongphancach") (write-line (strcat "[Xoa duong phan cach]^C^C_" "xmn" "\;" "\"" noidungmenuchinhp2xlb "\"" "\;" "\"" tenfilemodocb "\"" "\;" "\"" "x" "\"" "\;") filemns) (write-line "[---]" filemns))
((/= ndsau "mnduongphancach")

(write-line (strcat "[" ndtruoc "\t<<Bien Tap]^C^C_" "xmn" "\;" "\"" noidungmenuchinhp2xlb "\"" "\;" "\"" tenfilemodocb "\"" "\;") filemns))  
))
))

(close filemenuchinhp2xlb)
(write-line (strcat "[---]") filemns)
(write-line (strcat "[<-Xoa menu xep lop  " tenmnxlhthib "  nay]^C^C_" "xmnxl" "\;" "\"" tenmnxlhthib "@menuxeplop" "\"" "\;" "\"" tenfilemodoca "\"" "\;") filemns)
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun docghigiuapop2xlc ()
(setq filemenuchinhp2xlc (open (strcat dauduongdan tenfilemodocc) "r"))
(while (setq noidungmenuchinhp2xlc (read-line filemenuchinhp2xlc))
(setq noidungnguyen noidungmenuchinhp2xlc)
(setq dodainguyen (strlen noidungnguyen))
(setq dodainguyenl dodainguyen)
(doc@)

(cond
((= ndsau "menuxeplop") 
(setq tenfilemodocd (strcat "/menuxl" ndtruoc ".txt")) 
(write-line (strcat "[->" ndtruoc "]") filemns) 
(setq tenmnxlhthid ndtruoc) 
(docghigiuapop2xld))
((/= ndsau "menuxeplop") 

(cond
((= ndsau "mnduongphancach") (write-line (strcat "[Xoa duong phan cach]^C^C_" "xmn" "\;" "\"" noidungmenuchinhp2xlc "\"" "\;" "\"" tenfilemodocc "\"" "\;" "\"" "x" "\"" "\;") filemns) (write-line "[---]" filemns))
((/= ndsau "mnduongphancach")

(write-line (strcat "[" ndtruoc "\t<<Bien Tap]^C^C_" "xmn" "\;" "\"" noidungmenuchinhp2xlc "\"" "\;" "\"" tenfilemodocc "\"" "\;") filemns))  
))
))

(close filemenuchinhp2xlc)
(write-line (strcat "[---]") filemns)
(write-line (strcat "[<-Xoa menu xep lop  " tenmnxlhthic "  nay]^C^C_" "xmnxl" "\;" "\"" tenmnxlhthic "@menuxeplop" "\"" "\;" "\"" tenfilemodocb "\"" "\;") filemns)
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun docghigiuapop2xld ()
(setq filemenuchinhp2xld (open (strcat dauduongdan tenfilemodocd) "r"))
(while (setq noidungmenuchinhp2xld (read-line filemenuchinhp2xld))
(setq noidungnguyen noidungmenuchinhp2xld)
(setq dodainguyen (strlen noidungnguyen))
(setq dodainguyenl dodainguyen)
(doc@)

(cond
((= ndsau "menuxeplop") 
(setq tenfilemodoce (strcat "/menuxl" ndtruoc ".txt")) 
(write-line (strcat "[->" ndtruoc "]") filemns) 
(setq tenmnxlhthie ndtruoc) 
(docghigiuapop2xle))
((/= ndsau "menuxeplop") 

(cond
((= ndsau "mnduongphancach") (write-line (strcat "[Xoa duong phan cach]^C^C_" "xmn" "\;" "\"" noidungmenuchinhp2xld "\"" "\;" "\"" tenfilemodocd "\"" "\;" "\"" "x" "\"" "\;") filemns) (write-line "[---]" filemns))
((/= ndsau "mnduongphancach")

(write-line (strcat "[" ndtruoc "\t<<Bien Tap]^C^C_" "xmn" "\;" "\"" noidungmenuchinhp2xld "\"" "\;" "\"" tenfilemodocd "\"" "\;") filemns))  
))
))

(close filemenuchinhp2xld)
(write-line (strcat "[---]") filemns)
(write-line (strcat "[<-Xoa menu xep lop  " tenmnxlhthid "  nay]^C^C_" "xmnxl" "\;" "\"" tenmnxlhthid "@menuxeplop" "\"" "\;" "\"" tenfilemodocc "\"" "\;") filemns)
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun docghigiuapop2xle ()
(setq filemenuchinhp2xle (open (strcat dauduongdan tenfilemodoce) "r"))
(while (setq noidungmenuchinhp2xle (read-line filemenuchinhp2xle))
(setq noidungnguyen noidungmenuchinhp2xle)
(setq dodainguyen (strlen noidungnguyen))
(setq dodainguyenl dodainguyen)
(doc@)

(cond
((= ndsau "mnduongphancach") (write-line (strcat "[Xoa duong phan cach]^C^C_" "xmn" "\;" "\"" noidungmenuchinhp2xle "\"" "\;" "\"" tenfilemodoce "\"" "\;" "\"" "x" "\"" "\;") filemns) (write-line "[---]" filemns))
((/= ndsau "mnduongphancach")

(write-line (strcat "[" ndtruoc "\t<<Bien Tap]^C^C_" "xmnkxl" "\;" "\"" noidungmenuchinhp2xle "\"" "\;" "\"" tenfilemodoce "\"" "\;") filemns))  
))

(close filemenuchinhp2xle)
(write-line (strcat "[---]") filemns)
(write-line (strcat "[<-Xoa menu xep lop  " tenmnxlhthie "  nay]^C^C_" "xmnxl" "\;" "\"" tenmnxlhthie "@menuxeplop" "\"" "\;" "\"" tenfilemodocd "\"" "\;") filemns)
)

;;;;;;;;;;;;;;;;;
(defun c:vmn ()
(doanvmn))
;;;;;;;;;;;;;
(setq dauduongdan "E:/menu")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun doanvmn ()

(setq filemns (open (strcat dauduongdan "/dslenh.mns") "w"))

;;;;;;;;;;;;;;;;;;;;;;;;;;;taofilechuamenuchinh
(setq tinhtrangfilechinh (findfile (strcat dauduongdan "/menuchinh.txt")))
(cond
 ((= nil tinhtrangfilechinh) 
  (setq taofilemenuchinh (open (strcat dauduongdan "/menuchinh.txt") "w"))
  (write-line "Gioi thieu menu @gtmn" taofilemenuchinh)
  (close taofilemenuchinh)
))

;;;;;;;;;;;;;;;;;;;;;;;;;;;taofilechuatenmenu
(setq tinhtrangfilechinh (findfile (strcat dauduongdan "/tenmenu.txt")))
(cond
 ((= nil tinhtrangfilechinh) 
  (setq taofiletenmenu (open (strcat dauduongdan "/tenmenu.txt") "w"))
  (write-line "Menu Duy782006" taofiletenmenu)
  (close taofiletenmenu)
))

;;;;;;;;;;;;;;;;;;;;;;;;;;;vietdaupop1
(setq mofiletieude (open (strcat dauduongdan "/tenmenu.txt") "r"))
(setq noidungtieude (read-line mofiletieude))
(close mofiletieude)
(write-line "***MENUGROUP=DSLenh" filemns)
(write-line "***POP1" filemns)
(write-line (strcat "ID_tieude      [" noidungtieude "]") filemns)

;;;;;;;;;;;;;;;;;;;;;;;;;;;vietgiuapop1
(setq filemenuchinhp1 (open (strcat dauduongdan "/menuchinh.txt") "r"))
(while (setq noidungmenuchinhp1 (read-line filemenuchinhp1))
(setq noidungnguyen noidungmenuchinhp1)
(setq dodainguyen (strlen noidungnguyen))
(setq dodainguyenl dodainguyen)
(doc@)

(cond
((= ndsau "menuxeplop") (setq tenfilemodoc (strcat "/menuxl" ndtruoc ".txt")) (write-line (strcat "[->" ndtruoc "]") filemns) (docghigiuapop1xl))
((/= ndsau "menuxeplop") 

(cond
((= ndsau "mnduongphancach") (write-line "[---]" filemns))
((/= ndsau "mnduongphancach")

(write-line (strcat "[" ndtruoc "\t(" ndsau ")]^C^C_" ndsau) filemns))
))
))
(close filemenuchinhp1)

;;;;;;;;;;;;;;;;;;;;;;;;;;;vietcuoipop1
(write-line "[---]" filemns)
(write-line "[Goi menu bien tap \t(BTMN)]^C^C_btmn" filemns)

;;;;;;;;;;;;;;;;;;;;;;;;;;;vietdaupop2
(write-line "***POP2" filemns)
(write-line (strcat "ID_tieude      [" noidungtieude "]") filemns)

;;;;;;;;;;;;;;;;;;;;;;;;;;;vietgiuapop2
(setq filemenuchinhp2 (open (strcat dauduongdan "/menuchinh.txt") "r"))
(while (setq noidungmenuchinhp2 (read-line filemenuchinhp2))
(setq noidungnguyen noidungmenuchinhp2)
(setq dodainguyen (strlen noidungnguyen))
(setq dodainguyenl dodainguyen)
(doc@)

(cond
((= ndsau "menuxeplop") 
(setq tenfilemodoc (strcat "/menuxl" ndtruoc ".txt")) 
(write-line (strcat "[->" ndtruoc "]") filemns) 
(setq tenmnxlhthi ndtruoc) 
(setq tenfilemoxoa "/menuchinh.txt") 
(docghigiuapop2xl))
((/= ndsau "menuxeplop")

(cond
((= ndsau "mnduongphancach") (write-line (strcat "[Xoa duong phan cach]^C^C_" "xmn" "\;" "\"" noidungmenuchinhp2 "\"" "\;" "\"" "/menuchinh.txt" "\"" "\;" "\"" "x" "\"" "\;") filemns) (write-line "[---]" filemns))
((/= ndsau "mnduongphancach")

(write-line (strcat "[" ndtruoc "\t<<Bien Tap]^C^C_" "xmn" "\;" "\"" noidungmenuchinhp2 "\"" "\;" "\"" "/menuchinh.txt" "\"" "\;") filemns))  
))
))
(close filemenuchinhp2)

;;;;;;;;;;;;;;;;;;;;;;;;;;;vietcuoipop2
(write-line "[---]" filemns)
(write-line "[DOI TEN MENU CHINH \t(DTMN)]^C^C_dtmn" filemns)
(write-line "[xOA BO MENU \t(XBMN)]^C^C_xbmn" filemns)
(write-line "[LAM LAI MENU \t(TLMN)]^C^C_tlmn" filemns)
(write-line "[LUU MENU HIEN TAI \t(SLMN)]^C^C_slmn" filemns)
(write-line "[LOAD MENU DA LUU \t(GLMN)]^C^C_glmn" filemns)
(write-line "[---]" filemns)
(write-line "[Goi menu su dung \t(SDMN)]^C^C_sdmn" filemns)


;;;;;;;;;;;;;;;;;;;;;;;;;;;ketthucvietmns
(close filemns)

(command "_menuload" (strcat dauduongdan "/dslenh.mns")) 
(menucmd "P13=+DSlenh.pop1") 
  (princ)
)


;;;;;;;;;;;;;;
;;;;;;;;;;;;;;
;;;;;;;;;;;;;;
(Defun doc@ ( )  

(setq dodainguyen (- dodainguyen 1))
(setq noidungdocdc (substr noidungnguyen dodainguyen 1))
 (if (/= noidungdocdc "@")
 (doc@)
)
  (IF (= noidungdocdc "@") (PROGN
(setq ndtruoc (substr noidungnguyen 1 (- dodainguyen 1))) 
(setq ndsau (substr noidungnguyen (+ dodainguyen 1) (-  dodainguyenl dodainguyen))) 
)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:xbmn ()
(command "_menuunload" "DSLenh") 
(command "SHELL" (strcat "del " "E:\\menu\\dslenh.*" ))
(command "DELAY" "3000" "")
(command "SHELL" (strcat "del " "E:\\menu\\*.txt" ))
(command "DELAY" "3000" "")
(Princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:tlmn ()
(command "_menuunload" "DSLenh") 
(command "SHELL" (strcat "del " "E:\\menu\\dslenh.*" ))
(command "DELAY" "3000" "")
(command "SHELL" (strcat "del " "E:\\menu\\*.txt" ))
(command "DELAY" "3000" "")
(doanvmn)
(Princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:slmn ()
(command "SHELL" "MD E:\\menu\\saoluumenu" )
(command "DELAY" "1000" "")
(command "SHELL" "copy E:\\menu\\*.txt E:\\menu\\saoluumenu\\" )
(Princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:glmn ()
(command "_menuunload" "DSLenh") 
(command "SHELL" (strcat "del " "E:\\menu\\dslenh.*" ))
(command "DELAY" "3000" "")
(command "SHELL" (strcat "del " "E:\\menu\\*.txt" ))
(command "DELAY" "3000" "")
(command "SHELL" "copy E:\\menu\\saoluumenu\\*.txt E:\\menu\\" )
(command "DELAY" "3000" "")
(doanvmn)
(Princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:btmn ()
(command "_menuunload" "DSLenh") 
(command "_menuload" (strcat dauduongdan "/dslenh.mns")) 
(menucmd "P13=+DSlenh.pop2") 
(Princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:sdmn ()
(command "_menuunload" "DSLenh") 
(command "_menuload" (strcat dauduongdan "/dslenh.mns")) 
(menucmd "P13=+DSlenh.pop1") 
(Princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:dtmn ()
(setq tenmoi (getstring "\nNhap ten menu:")) 
(command "_menuunload" "DSLenh") 
(setq mofiletieude (open (strcat dauduongdan "/tenmenu.txt") "w"))
(write-line tenmoi mofiletieude)
(close mofiletieude)
(doanvmn)
(Princ)
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:xmn ()
(setq noidungtimxoa (getstring "\nNhap:"))
(setq filedocsua (getstring "\nNhap:"))

(setq mofilegiua (open (strcat dauduongdan filedocsua) "r"))
(setq mofiletrunggian (open (strcat dauduongdan "/trunggian.txt") "w"))
(setq kieutacdongmenu (strcase (getstring "\nChen muc don/ chen muc xep Lop/ Sua muc/ Xoa muc/ chen duong Phan cach:")))

(cond
((= kieutacdongmenu "X")
(while (setq noidunggiua (read-line mofilegiua))
 (if (/= noidungtimxoa noidunggiua)
(write-line noidunggiua mofiletrunggian)
)
)
 );dongcondxoamenu
((= kieutacdongmenu "S")
(setq noidunghienthi (getstring 5"\nNhap noi dung hien thi tren menu:")) 
(setq tenlenh (getstring "\nNhap ten lenh:")) 
(setq chuoivietthem (strcat noidunghienthi "@" tenlenh))

(while (setq noidunggiua (read-line mofilegiua))
 (if (/= noidungtimxoa noidunggiua)
(write-line noidunggiua mofiletrunggian)
)
 (if (= noidungtimxoa noidunggiua)
(write-line chuoivietthem mofiletrunggian)
)
)
 );dongcondchinhmenu
((= kieutacdongmenu "C")
(setq noidunghienthi (getstring 5"\nNhap noi dung hien thi tren menu:")) 
(setq tenlenh (getstring "\nNhap ten lenh:")) 
(setq chuoivietthem (strcat noidunghienthi "@" tenlenh))

(while (setq noidunggiua (read-line mofilegiua))
 (if (= noidungtimxoa noidunggiua)
(write-line chuoivietthem mofiletrunggian)
)
(write-line noidunggiua mofiletrunggian)
)
 );dongcondthemmenu

((= kieutacdongmenu "L")
(setq noidunghienthi (getstring 5"\nNhap tieu de menu xep lop nay:")) 
(setq chuoivietthem (strcat noidunghienthi "@menuxeplop"))

(while (setq noidunggiua (read-line mofilegiua))
 (if (= noidungtimxoa noidunggiua)
(write-line chuoivietthem mofiletrunggian)
)
(write-line noidunggiua mofiletrunggian)
)
(setq mofilexeplopghi (open (strcat dauduongdan "/menuxl" noidunghienthi ".txt") "w"))
(write-line "Gioi thieu menu xep lop@gtmnxl" mofilexeplopghi)
(close mofilexeplopghi)
 );dongcondthemmenuxeplop

((= kieutacdongmenu "P")
(setq thoigianhienhanh (menucmd "M=$(getvar, date)"))
(setq chuoivietthem (strcat thoigianhienhanh "@mnduongphancach"))

(while (setq noidunggiua (read-line mofilegiua))
 (if (= noidungtimxoa noidunggiua)
(write-line chuoivietthem mofiletrunggian)
)
(write-line noidunggiua mofiletrunggian)
)
 );dongcondthemmenuphancach



 );dongcond

(close mofilegiua)
(close mofiletrunggian)

(setq mofilegiua (open (strcat dauduongdan filedocsua) "w"))
(setq mofiletrunggian (open (strcat dauduongdan "/trunggian.txt") "r"))
(while (setq noidunggiua (read-line mofiletrunggian))
(write-line noidunggiua mofilegiua)
)
(close mofilegiua)
(close mofiletrunggian)
(command "SHELL" (strcat "del " "E:\\menu\\trunggian.txt" ))
;(command "SHELL" (strcat "del " dauduongdan "/trunggian.txt" ))

(command "_menuunload" "DSLenh") 
(doanvmn)

(Princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:xmnkxl ()
(setq noidungtimxoa (getstring "\nNhap:"))
(setq filedocsua (getstring "\nNhap:"))

(setq mofilegiua (open (strcat dauduongdan filedocsua) "r"))
(setq mofiletrunggian (open (strcat dauduongdan "/trunggian.txt") "w"))
(setq kieutacdongmenu (strcase (getstring "\nChen muc don/ Sua muc/ Xoa muc/ chen duong Phan cach:")))

(cond
((= kieutacdongmenu "X")
(while (setq noidunggiua (read-line mofilegiua))
 (if (/= noidungtimxoa noidunggiua)
(write-line noidunggiua mofiletrunggian)
)
)
 );dongcondxoamenu
((= kieutacdongmenu "S")
(setq noidunghienthi (getstring 5"\nNhap noi dung hien thi tren menu:")) 
(setq tenlenh (getstring "\nNhap ten lenh:")) 
(setq chuoivietthem (strcat noidunghienthi "@" tenlenh))

(while (setq noidunggiua (read-line mofilegiua))
 (if (/= noidungtimxoa noidunggiua)
(write-line noidunggiua mofiletrunggian)
)
 (if (= noidungtimxoa noidunggiua)
(write-line chuoivietthem mofiletrunggian)
)
)
 );dongcondchinhmenu
((= kieutacdongmenu "C")
(setq noidunghienthi (getstring 5"\nNhap noi dung hien thi tren menu:")) 
(setq tenlenh (getstring "\nNhap ten lenh:")) 
(setq chuoivietthem (strcat noidunghienthi "@" tenlenh))

(while (setq noidunggiua (read-line mofilegiua))
 (if (= noidungtimxoa noidunggiua)
(write-line chuoivietthem mofiletrunggian)
)
(write-line noidunggiua mofiletrunggian)
)
 );dongcondthemmenu

((= kieutacdongmenu "P")
(setq thoigianhienhanh (menucmd "M=$(getvar, date)"))
(setq chuoivietthem (strcat thoigianhienhanh "@mnduongphancach"))

(while (setq noidunggiua (read-line mofilegiua))
 (if (= noidungtimxoa noidunggiua)
(write-line chuoivietthem mofiletrunggian)
)
(write-line noidunggiua mofiletrunggian)
)
 );dongcondthemmenuphancach


 );dongcond

(close mofilegiua)
(close mofiletrunggian)

(setq mofilegiua (open (strcat dauduongdan filedocsua) "w"))
(setq mofiletrunggian (open (strcat dauduongdan "/trunggian.txt") "r"))
(while (setq noidunggiua (read-line mofiletrunggian))
(write-line noidunggiua mofilegiua)
)
(close mofilegiua)
(close mofiletrunggian)
(command "SHELL" (strcat "del " "E:\\menu\\trunggian.txt" ))
;(command "SHELL" (strcat "del " dauduongdan "/trunggian.txt" ))

(command "_menuunload" "DSLenh") 
(doanvmn)

(Princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:xmnxl ()
(setq noidungtimxoa (getstring "\nNhap:"))
(setq filedocsua (getstring "\nNhap:"))

(setq mofilegiua (open (strcat dauduongdan filedocsua) "r"))
(setq mofiletrunggian (open (strcat dauduongdan "/trunggian.txt") "w"))

(while (setq noidunggiua (read-line mofilegiua))
 (if (/= noidungtimxoa noidunggiua)
(write-line noidunggiua mofiletrunggian)
)
)

(close mofilegiua)
(close mofiletrunggian)

(setq mofilegiua (open (strcat dauduongdan filedocsua) "w"))
(setq mofiletrunggian (open (strcat dauduongdan "/trunggian.txt") "r"))
(while (setq noidunggiua (read-line mofiletrunggian))
(write-line noidunggiua mofilegiua)
)
(close mofilegiua)
(close mofiletrunggian)
(command "SHELL" (strcat "del " "E:\\menu\\trunggian.txt" ))
;(command "SHELL" (strcat "del " dauduongdan "/trunggian.txt" ))

(command "_menuunload" "DSLenh") 
(doanvmn)

(Princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 (Defun c:gtmn ( )   
(alert "*Tien ich bien tap va su dung menu truc quan.
*Co hai menu song song voi cac de muc giong nhau:
-Menu su dung: Dung nhu menu binh thuong.
-Menu bien tap: Co chuc nang bien tap, khi ban chon bien tap muc nao thi co 5 lua chon cho ban:
+Go C: Chen muc menu don tren muc vua chon.
+Go L: Chen muc menu xep lop tren muc vua chon.
+Go P: Chen duong phan cach tren muc vua chon.
+Go S: Chinh sua muc vua chon.
+Go X: Xoa bo muc vua chon khoi menu.
*Menu su dung co muc cuoi cung dung goi menu bien tap.
*Menu bien tap co muc cuoi cung dung goi menu su dung va cac chuc nang:
-Doi ten menu chinh.
-Xoa bo menu.
-Sao luu menu.
-Goi menu da luu.
-Khoi tao lai menu ban dau")
(princ))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 (Defun c:gtmnxl ( )   
(alert "-Khi khoi tao mot menu xep lop minh mac dinh cho no mot muc don hien hanh.
-Tu muc don nay ban dung chuc nang bien tap de co duoc menu ung y.
-Minh ho tro ban viec tao ra cac menu xep lop long trong nhau.
-Gioi han long menu xep lop o day minh goi han trong 5 cap.
-Khi ban tao 2 menu xep lop co ten trung nhau thi noi dung cua menu tao sau se thay the menu truoc.")
(princ))

Thảo luận gốc

Lisp được chia sẻ trong chủ đề [Yêu cầu] lisp tạo menu những lệnh cơ bản. Xem đúng bài viết #163338 để đọc hướng dẫn và trao đổi thêm.

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