Lisp lệnh AL9 trong chủ đề “Nhờ tạo lisp tự động vẽ pline theo điểm, block, text có sẵn”
Lisp của bạn đây, lệnh là AL9
;;; Lisp add lwpolyline promt insertpoint of texts blocks === by Trân Thiêp 05/2020
(defun DXF (code en) (cdr (assoc code (entget en))))
(defun TD:Text (ent / X11)
(setq Ma10 (dxf 10 ent))
(setq Ma11 (dxf 11 ent))
(setq X11 (car Ma11))
(setq Ma71 (dxf 71 ent))
(setq Ma72 (dxf 72 ent))
(if (or (and (= Ma71 0) (= Ma72 0) (= X11 0))
(and (= Ma71 0) (= Ma72 3))
(and (= Ma71 0) (= Ma72 5))
)
Ma10
Ma11
)
)
;;;=================================================
(defun c:al9 (/ doc ss entlst lstpo po)
(defun *error* (msg)
(and doc (_EndUndo doc))
(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n** Error: " msg " **"))
)
(princ)
)
(defun _EndUndo (doc)
(if (= 8 (logand 8 (getvar 'UNDOCTL)))
(vla-EndUndomark doc)
)
)
(acet-sysvar-set '("cmdecho" 0 "osmode" 0))
(setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
(vla-StartUndoMark doc)
(command "_ucs" "w")
(prompt
"\nCh\U+1ECDn t\U+1EADp h\U+1EE3p các text, block b\U+1EB1ng ph\U+01B0\U+01A1ng th\U+1EE9c FENC:"
)
(setq lstpo nil)
(if (setq ss (ssget "F" (ACET-UI-FENCE-SELECT) '((0 . "TEXT,INSERT"))))
(progn (setq entlst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
(foreach ent entlst
(cond ((= (dxf 0 ent) "TEXT") (setq po (TD:Text ent)))
((= (dxf 0 ent) "INSERT") (setq po (dxf 10 ent)))
)
(setq lstpo (cons po lstpo))
)
(acet-lwpline-make (list lstpo))
)
(prompt "\nCh\U+01B0a ch\U+1ECDn t\U+1EADp h\U+1EE3p texts, blocks")
)
(acet-sysvar-restore)
(command "_ucs" "P")
(_EndUndo doc)
(princ "\nOk")
)
Chúc bạn vui.
- Tải lisp
- 457275_al9.lsp
Cách dùng
- Tải tệp 457275_al9.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 AL9 để chạy lisp.
Mã nguồn 457275_al9.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/187267-nh%E1%BB%9D-t%E1%BA%A1o-lisp-t%E1%BB%B1-%C4%91%E1%BB%99ng-v%E1%BA%BD-pline-theo-%C4%91i%E1%BB%83m-block-text-c%C3%B3-s%E1%BA%B5n/
;;; Lisp add lwpolyline promt insertpoint of texts blocks === by Trân Thiêp 05/2020
(defun DXF (code en) (cdr (assoc code (entget en))))
(defun TD:Text (ent / X11)
(setq Ma10 (dxf 10 ent))
(setq Ma11 (dxf 11 ent))
(setq X11 (car Ma11))
(setq Ma71 (dxf 71 ent))
(setq Ma72 (dxf 72 ent))
(if (or (and (= Ma71 0) (= Ma72 0) (= X11 0))
(and (= Ma71 0) (= Ma72 3))
(and (= Ma71 0) (= Ma72 5))
)
Ma10
Ma11
)
)
;;;=================================================
(defun c:al9 (/ doc ss entlst lstpo po)
(defun *error* (msg)
(and doc (_EndUndo doc))
(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n** Error: " msg " **"))
)
(princ)
)
(defun _EndUndo (doc)
(if (= 8 (logand 8 (getvar 'UNDOCTL)))
(vla-EndUndomark doc)
)
)
(acet-sysvar-set '("cmdecho" 0 "osmode" 0))
(setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
(vla-StartUndoMark doc)
(command "_ucs" "w")
(prompt
"\nCh\U+1ECDn t\U+1EADp h\U+1EE3p các text, block b\U+1EB1ng ph\U+01B0\U+01A1ng th\U+1EE9c FENC:"
)
(setq lstpo nil)
(if (setq ss (ssget "F" (ACET-UI-FENCE-SELECT) '((0 . "TEXT,INSERT"))))
(progn (setq entlst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
(foreach ent entlst
(cond ((= (dxf 0 ent) "TEXT") (setq po (TD:Text ent)))
((= (dxf 0 ent) "INSERT") (setq po (dxf 10 ent)))
)
(setq lstpo (cons po lstpo))
)
(acet-lwpline-make (list lstpo))
)
(prompt "\nCh\U+01B0a ch\U+1ECDn t\U+1EADp h\U+1EE3p texts, blocks")
)
(acet-sysvar-restore)
(command "_ucs" "P")
(_EndUndo doc)
(princ "\nOk")
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề Nhờ tạo lisp tự động vẽ pline theo điểm, block, text có sẵn. Xem đúng bài viết #457275 để đọc hướng dẫn và trao đổi thêm.