Lisp lệnh LC+%C2%A0 trong chủ đề “vấn đề về lệnh tắt trong cad”
13 giờ trước, danhandoi đã nói:Giống bác trên, mình cũng làm như thế mà cái khung nó không to ra được?
Chắc là muốn như vầy:
(defun c:lc (/ LM:ListBox str lstData ST:SendKeys)
(defun c:Xformat nil
(alert "B\U+1EA1n có ch\U+1EAFc là XÓA S\U+1EA0CH \U+1ED5 c\U+1EE9ng không?")
(princ))
(setq lstData (acad_strlsort
(list ;Viet tiep cac lenh vao duoi dong nay theo mau "Ten lenh Noi dung"
"Erase \tXoa doi tuong" "Copy \tSao chep doi tuong" "Mirror \tLay doi xung" "CO \tCopy th\U+00F4ng minh"
"XFormat \tXóa s\U+1EA1ch \U+1ED5 c\U+1EE9ng, d\U+1EADp tan màn h\U+00ECnh...")))
(defun ST:SendKeys (keys / ws)
(vlax-invoke-method (setq ws (vlax-create-object "WScript.Shell")) 'sendkeys keys)
(vlax-release-object ws)
(princ))
(defun LM:ListBox (title data multiple / file tmp dch return)
(cond ((not
(and (setq file (open (setq tmp (vl-filename-mktemp nil nil ".dcl")) "w"))
(write-line (strcat "listbox : dialog { label = \""
title
"\"; spacer; : list_box { key = \"list\"; multiple_select = "
(if multiple
"true"
"false")
"; width = 100; height= 30; tabs = \"10 20 30\";
} spacer; ok_cancel;}")
file)
(not (close file))
(< 0 (setq dch (load_dialog tmp)))
(new_dialog "listbox" dch))))
(t
(start_list "list")
(mapcar 'add_list data)
(end_list)
(setq return (set_tile "list" "0"))
(action_tile "list" "(setq return $value)")
(setq return (if (= 1 (start_dialog))
(mapcar '(lambda (x) (nth x data)) (read (strcat "(" return ")")))))))
(if (< 0 dch)
(unload_dialog dch))
(if (setq tmp (findfile tmp))
(vl-file-delete tmp))
return)
(cond ((setq str (LM:ListBox "Ghi ch\U+00FA l\U+1EC7nh - lisp CAD - @ketxu - 2/6/2012 :" lstData nil))
(setq str (car str))
(ST:SendKeys (strcat (substr str 1 (vl-string-position 32 str)) "\n"))))
(princ))
- Tải lisp
- 425018_lc+%C2%A0.lsp
Cách dùng
- Tải tệp 425018_lc+%C2%A0.lsp về máy.
- Trong AutoCAD gõ lệnh APPLOAD, chọn tệp vừa tải rồi bấm Load. Cũng có thể kéo thả tệp .lsp vào cửa sổ bản vẽ.
- Gõ lệnh LC+%C2%A0 để chạy lisp.
Mã nguồn 425018_lc+%C2%A0.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/49784-v%E1%BA%A5n-%C4%91%E1%BB%81-v%E1%BB%81-l%E1%BB%87nh-t%E1%BA%AFt-trong-cad/?page=2
(defun c:lc (/ LM:ListBox str lstData ST:SendKeys)
(defun c:Xformat nil
(alert "B\U+1EA1n có ch\U+1EAFc là XÓA S\U+1EA0CH \U+1ED5 c\U+1EE9ng không?")
(princ))
(setq lstData (acad_strlsort
(list ;Viet tiep cac lenh vao duoi dong nay theo mau "Ten lenh Noi dung"
"Erase \tXoa doi tuong" "Copy \tSao chep doi tuong" "Mirror \tLay doi xung" "CO \tCopy th\U+00F4ng minh"
"XFormat \tXóa s\U+1EA1ch \U+1ED5 c\U+1EE9ng, d\U+1EADp tan màn h\U+00ECnh...")))
(defun ST:SendKeys (keys / ws)
(vlax-invoke-method (setq ws (vlax-create-object "WScript.Shell")) 'sendkeys keys)
(vlax-release-object ws)
(princ))
(defun LM:ListBox (title data multiple / file tmp dch return)
(cond ((not
(and (setq file (open (setq tmp (vl-filename-mktemp nil nil ".dcl")) "w"))
(write-line (strcat "listbox : dialog { label = \""
title
"\"; spacer; : list_box { key = \"list\"; multiple_select = "
(if multiple
"true"
"false")
"; width = 100; height= 30; tabs = \"10 20 30\";
} spacer; ok_cancel;}")
file)
(not (close file))
(< 0 (setq dch (load_dialog tmp)))
(new_dialog "listbox" dch))))
(t
(start_list "list")
(mapcar 'add_list data)
(end_list)
(setq return (set_tile "list" "0"))
(action_tile "list" "(setq return $value)")
(setq return (if (= 1 (start_dialog))
(mapcar '(lambda (x) (nth x data)) (read (strcat "(" return ")")))))))
(if (< 0 dch)
(unload_dialog dch))
(if (setq tmp (findfile tmp))
(vl-file-delete tmp))
return)
(cond ((setq str (LM:ListBox "Ghi ch\U+00FA l\U+1EC7nh - lisp CAD - @ketxu - 2/6/2012 :" lstData nil))
(setq str (car str))
(ST:SendKeys (strcat (substr str 1 (vl-string-position 32 str)) "\n"))))
(princ))Thảo luận gốc
Lisp được chia sẻ trong chủ đề vấn đề về lệnh tắt trong cad. Xem đúng bài viết #425018 để đọc hướng dẫn và trao đổi thêm.