LISP tạo đường viền cho text
Sửa lại cho bạn đây :
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
- Chép mã nguồn, lưu thành tệp 200646_test.lsp.
- 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 TEST để chạy lisp.
Mã nguồn 200646_test.lsp (trích từ bài viết gốc)
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/index.php?showtopic=63121&pid=195690&st=0entry195690
;----- Example Calling Function: This example will create an LWPolyline describing the bounding box of the selected object.
(defun c:test ( / e ) (vl-load-com)
(if (setq e (car (entsel)))
(entmakex
(append
(list
(cons 0 "LWPOLYLINE")
(cons 100 "AcDbEntity")
(cons 100 "AcDbPolyline")
(cons 90 4)
(cons 70 1))
(mapcar '(lambda ( p ) (cons 10 p)) (LM:BoundingBox (vlax-ename->vla-object e))))))
(princ))
(defun LM:BoundingBox ( object / lowerleft upperright )
(if (vlax-method-applicable-p object 'GetBoundingBox)
((lambda ( boundingbox )
(mapcar
(function
(lambda ( _functionlist )
(mapcar
(function
(lambda ( _function ) ((eval _function) boundingbox)))
_functionlist)))
'((caar cadar) (caadr cadar)
(caadr cadadr) (caar cadadr))))
(mapcar 'vlax-safearray->list
(progn
(vla-getBoundingBox object 'lowerleft 'upperright) (list lowerleft upperright))))))
(defun c:test ( / e ss) (vl-load-com)
(setq i -1)
(if (setq ss (ssget '((0 . "*TEXT"))))
(while (setq e (ssname ss (setq i (1+ i))))
(entmakex
(append
(list
(cons 0 "LWPOLYLINE")
(cons 100 "AcDbEntity")
(cons 100 "AcDbPolyline")
(cons 90 4)
(cons 70 1))
(mapcar '(lambda ( p ) (cons 10 p)) (LM:BoundingBox (vlax-ename->vla-object e)))))))
(princ))
(defun LM:BoundingBox ( object / lowerleft upperright )
(if (vlax-method-applicable-p object 'GetBoundingBox)
((lambda ( boundingbox )
(mapcar
(function
(lambda ( _functionlist )
(mapcar
(function
(lambda ( _function ) ((eval _function) boundingbox)))
_functionlist)))
'((caar cadar) (caadr cadar)
(caadr cadadr) (caar cadadr))))
(mapcar 'vlax-safearray->list
(progn
(vla-getBoundingBox object 'lowerleft 'upperright) (list lowerleft upperright))))))Thảo luận gốc
Lisp được chia sẻ trong chủ đề [Nhờ chỉnh sửa] LISP tạo đường viền cho text. Xem đúng bài viết #200646 để đọc hướng dẫn và trao đổi thêm.